Fix sharp in container, add admin downloads and anchor mark
- ship libvips with the runtime image so POST /api/v1/media stops failing - admin downloads openapi.json and the style guide via session, no token - copy rows for both API addresses - anchor mark in the wordmark and a favicon
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { TbCheck, TbCopy } from 'react-icons/tb'
|
||||
import { ghostButtonClass } from '~/components/admin/styles'
|
||||
|
||||
export type CopyButtonProps = {
|
||||
value: string
|
||||
label: string
|
||||
doneLabel: string
|
||||
className?: string
|
||||
}
|
||||
|
||||
export function CopyButton({ value, label, doneLabel, className }: CopyButtonProps) {
|
||||
const [copied, setCopied] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
if (!copied) {
|
||||
return
|
||||
}
|
||||
|
||||
const timer = setTimeout(() => setCopied(false), 2000)
|
||||
|
||||
return () => clearTimeout(timer)
|
||||
}, [copied])
|
||||
|
||||
async function copy() {
|
||||
try {
|
||||
await navigator.clipboard.writeText(value)
|
||||
setCopied(true)
|
||||
} catch {
|
||||
setCopied(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<button type="button" onClick={copy} className={`${ghostButtonClass} ${className ?? ''}`}>
|
||||
{copied ? (
|
||||
<TbCheck aria-hidden="true" className="size-4 shrink-0" />
|
||||
) : (
|
||||
<TbCopy aria-hidden="true" className="size-4 shrink-0" />
|
||||
)}
|
||||
{copied ? doneLabel : label}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user