Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions src/components/frontmatter-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export function InlineFrontmatterEditor({
}
>
<Tooltip>
<TooltipTrigger>
<TooltipTrigger asChild>
<SelectTrigger
className="h-7 w-7 border-none bg-transparent p-0 [&_svg]:hidden"
asChild
Expand All @@ -178,6 +178,7 @@ export function InlineFrontmatterEditor({
className="[&_svg]:inline"
variant="ghost"
size="icon"
aria-label={`Property type: ${prop.type}`}
>
<HugeiconsIcon
icon={
Expand Down Expand Up @@ -226,14 +227,16 @@ export function InlineFrontmatterEditor({
onChange={(e) => handleKeyChange(index, e.target.value)}
onKeyDown={(e) => handleKeyDown(e, index)}
placeholder="key"
className="min-w-24 border-none outline-none"
aria-label={`Property key ${index + 1}`}
className="min-w-24 border-none outline-none bg-transparent"
/>
{prop.type === "checkbox" ? (
<Checkbox
checked={Boolean(prop.value)}
onCheckedChange={(checked) =>
handleValueChange(index, checked === true)
}
aria-label={`Value for ${prop.key || `property ${index + 1}`}`}
/>
) : prop.type === "number" ? (
<Input
Expand All @@ -243,14 +246,16 @@ export function InlineFrontmatterEditor({
handleValueChange(index, Number(e.target.value))
}
className="min-w-24"
aria-label={`Value for ${prop.key || `property ${index + 1}`}`}
/>
) : prop.type === "date" ? (
<Popover>
<PopoverTrigger>
<PopoverTrigger asChild>
<Button
type="button"
variant="outline"
className="min-w-24 justify-start text-left font-normal"
aria-label={`Select date for ${prop.key || `property ${index + 1}`}`}
>
{prop.value ? (
String(prop.value)
Expand Down Expand Up @@ -287,18 +292,27 @@ export function InlineFrontmatterEditor({
onChange={(e) => handleValueChange(index, e.target.value)}
onKeyDown={(e) => handleKeyDown(e, index)}
placeholder="value"
className="min-w-32 flex-1 outline-none"
className="min-w-32 flex-1 outline-none bg-transparent"
aria-label={`Value for ${prop.key || `property ${index + 1}`}`}
/>
)}
<Button
type="button"
variant="ghost"
size="icon"
className="opacity-0 group-focus-within:opacity-100"
onClick={() => removeProperty(index)}
>
<HugeiconsIcon icon={Cancel01Icon} />
</Button>
<Tooltip>
<TooltipTrigger asChild>
<Button
type="button"
variant="ghost"
size="icon"
className="opacity-0 group-focus-within:opacity-100"
onClick={() => removeProperty(index)}
aria-label={`Remove property ${prop.key || index + 1}`}
>
<HugeiconsIcon icon={Cancel01Icon} />
</Button>
</TooltipTrigger>
<TooltipContent side="right">
<p>Remove property</p>
</TooltipContent>
</Tooltip>
</div>
))}
<Button
Expand Down