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.

better types

Oleg Isonen76f5808eb2f9
diff --git a/apps/designer/app/designer/features/topbar/menu/menu.tsx b/apps/designer/app/designer/features/topbar/menu/menu.tsx
index f549529b5e..eb3fde05a6 100644
--- a/apps/designer/app/designer/features/topbar/menu/menu.tsx
+++ b/apps/designer/app/designer/features/topbar/menu/menu.tsx
@@ -20,7 +20,11 @@ import {
useIsPublishDialogOpen,
} from "~/designer/shared/nano-states";
import { isFeatureEnabled } from "~/shared/feature-flags";
-import { getThemeSetting, setThemeSetting } from "~/shared/theme";
+import {
+ getThemeSetting,
+ setThemeSetting,
+ type ThemeSetting,
+} from "~/shared/theme";
const menuItemCss = {
display: "flex",
@@ -37,14 +41,14 @@ const textCss = {
const ThemeMenuItem = () => {
if (isFeatureEnabled("theme") === false) return null;
- const currentOption = getThemeSetting();
- const labels = {
+ const currentSetting = getThemeSetting();
+ const labels: Record<ThemeSetting, string> = {
light: "Light",
dark: "Dark",
system: "System theme",
- } as const;
+ };
- const options = Object.keys(labels) as Array<keyof typeof labels>;
+ const settings = Object.keys(labels) as Array<ThemeSetting>;
return (
<DropdownMenu>
@@ -53,16 +57,16 @@ const ThemeMenuItem = () => {
<ChevronRightIcon />
</DropdownMenuTriggerItem>
<DropdownMenuContent>
- {options.map((option) => (
+ {settings.map((setting) => (
<DropdownMenuCheckboxItem
- key={option}
- checked={currentOption === option}
+ key={setting}
+ checked={currentSetting === setting}
css={menuItemCss}
onSelect={() => {
- setThemeSetting(option);
+ setThemeSetting(setting);
}}
>
- <Text css={textCss}>{labels[option]}</Text>
+ <Text css={textCss}>{labels[setting]}</Text>
</DropdownMenuCheckboxItem>
))}
</DropdownMenuContent>
diff --git a/apps/designer/app/shared/theme/index.ts b/apps/designer/app/shared/theme/index.ts
index 3797aeae07..66b920f045 100644
--- a/apps/designer/app/shared/theme/index.ts
+++ b/apps/designer/app/shared/theme/index.ts
@@ -1 +1,2 @@
export * from "./theme";
+export type { ThemeSetting } from "./shared";