Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

selected item

Oleg Isonen12572cde4f6f
diff --git a/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsx b/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsx
index a67f3dd2cb..ad664e05d9 100644
--- a/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsx
+++ b/apps/designer/app/designer/shared/fonts-manager/fonts-manager.tsx
@@ -3,7 +3,6 @@ import {
Flex,
TextField,
IconButton,
- Text,
useCombobox,
Separator,
} from "@webstudio-is/design-system";
@@ -123,6 +122,7 @@ export const FontsManager = ({ value, onChange }: FontsManagerProps) => {
<Flex css={{ py: "$2", px: "$3" }} gap="2" direction="column">
<AssetUpload type="font" />
<TextField
+ {...getInputProps()}
type="search"
autoFocus
placeholder="Search"
@@ -135,7 +135,6 @@ export const FontsManager = ({ value, onChange }: FontsManagerProps) => {
<MagnifyingGlassIcon />
</IconButton>
}
- {...getInputProps()}
/>
</Flex>
<Separator css={{ my: "$1" }} />
@@ -155,25 +154,26 @@ export const FontsManager = ({ value, onChange }: FontsManagerProps) => {
<Fragment key={index}>
{index !== 0 && <Separator css={{ my: "$1" }} />}
<ListboxItem {...getItemProps({ item, index })} disabled>
- <Text variant="label" truncate>
- {item.label}
- </Text>
+ {item.label}
</ListboxItem>
</Fragment>
);
}
return (
- <ListboxItem {...getItemProps({ item, index })} key={index}>
- <Text variant="label" color="contrast" truncate>
- {item.label}
- </Text>
- {item.type === "uploaded" && (
- <ItemMenu
- onDelete={() => {
- handleDeleteByLabel(item.label);
- }}
- />
- )}
+ <ListboxItem
+ {...getItemProps({ item, index })}
+ key={index}
+ suffix={
+ item.type === "uploaded" && (
+ <ItemMenu
+ onDelete={() => {
+ handleDeleteByLabel(item.label);
+ }}
+ />
+ )
+ }
+ >
+ {item.label}
</ListboxItem>
);
})}
diff --git a/apps/designer/app/designer/shared/fonts-manager/list.tsx b/apps/designer/app/designer/shared/fonts-manager/list.tsx
index f69adc19a7..11a405a761 100644
--- a/apps/designer/app/designer/shared/fonts-manager/list.tsx
+++ b/apps/designer/app/designer/shared/fonts-manager/list.tsx
@@ -1,4 +1,5 @@
-import { styled } from "@webstudio-is/design-system";
+import { Flex, styled, Text } from "@webstudio-is/design-system";
+import { CheckIcon } from "@webstudio-is/icons";
import { ComponentProps, forwardRef } from "react";
import { itemMenuVars } from "./item-menu";
@@ -17,11 +18,11 @@ export const Listbox = styled("ul", {
});
const ListboxItemBase = styled("li", {
- display: "flex",
+ display: "grid",
+ gridTemplateColumns: "$4 1fr",
alignItems: "center",
justifyContent: "space-between",
height: "$5",
- paddingLeft: "$4",
listStyle: "none",
borderRadius: "$1",
"&[data-highlighted], &[aria-selected=true]": {
@@ -31,7 +32,6 @@ const ListboxItemBase = styled("li", {
},
"&[disabled]": {
pointerEvents: "none",
- color: "$hint",
},
});
@@ -39,16 +39,38 @@ export const ListboxItem = forwardRef<
HTMLLIElement,
ComponentProps<typeof ListboxItemBase> & {
highlighted?: boolean;
- disabled?: boolean;
+ disabled: boolean;
+ selected: boolean;
+ suffix?: JSX.Element;
}
->(({ highlighted, disabled, ...props }, ref) => {
- return (
- <ListboxItemBase
- {...props}
- ref={ref}
- {...(highlighted ? { ["data-highlighted"]: true } : {})}
- {...(disabled ? { ["aria-disabled"]: true, disabled: true } : {})}
- />
- );
-});
+>(
+ (
+ {
+ highlighted,
+ disabled = false,
+ selected = false,
+ children,
+ suffix,
+ ...props
+ },
+ ref
+ ) => {
+ return (
+ <ListboxItemBase
+ {...props}
+ ref={ref}
+ {...(highlighted ? { ["data-highlighted"]: true } : {})}
+ {...(disabled ? { ["aria-disabled"]: true, disabled: true } : {})}
+ >
+ {selected && <CheckIcon />}
+ <Flex css={{ gridColumn: 2 }} align="center">
+ <Text variant="label" truncate color={disabled ? "hint" : "contrast"}>
+ {children}
+ </Text>
+ {suffix}
+ </Flex>
+ </ListboxItemBase>
+ );
+ }
+);
ListboxItem.displayName = "ListboxItem";