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.

Update Button (#751)

Roman Pominov5fac01020fa6
diff --git a/.lostpixel/baseline/components-button--simple.png b/.lostpixel/baseline/components-deprecated-button--simple.png
similarity index 100%
rename from .lostpixel/baseline/components-button--simple.png
rename to .lostpixel/baseline/components-deprecated-button--simple.png
diff --git a/.lostpixel/baseline/components-text-field--focus-events.png b/.lostpixel/baseline/components-text-field--focus-events.png
index f8d9877b37..9006114254 100644
Binary files a/.lostpixel/baseline/components-text-field--focus-events.png and b/.lostpixel/baseline/components-text-field--focus-events.png differ
diff --git a/.lostpixel/baseline/components-text-field--interactive.png b/.lostpixel/baseline/components-text-field--interactive.png
index ce559ea3f9..c67cb703f2 100644
Binary files a/.lostpixel/baseline/components-text-field--interactive.png and b/.lostpixel/baseline/components-text-field--interactive.png differ
diff --git a/.lostpixel/baseline/library-button--button.png b/.lostpixel/baseline/library-button--button.png
new file mode 100644
index 0000000000..c9b18b8308
Binary files /dev/null and b/.lostpixel/baseline/library-button--button.png differ
diff --git a/apps/designer/app/auth/login-button.tsx b/apps/designer/app/auth/login-button.tsx
index 745729932e..ea435bec83 100644
--- a/apps/designer/app/auth/login-button.tsx
+++ b/apps/designer/app/auth/login-button.tsx
@@ -23,7 +23,6 @@ export const LoginButton = ({
const button = (
<Button
{...props}
- size={3}
type="submit"
disabled={disabled}
css={{ width: "100%" }}
diff --git a/apps/designer/app/auth/login.tsx b/apps/designer/app/auth/login.tsx
index f376d1b5c7..9acc353e3f 100644
--- a/apps/designer/app/auth/login.tsx
+++ b/apps/designer/app/auth/login.tsx
@@ -89,7 +89,7 @@ export const Login = ({ errorMessage }: { errorMessage: string }) => {
placeholder="Auth secret"
css={{ flexGrow: 1 }}
/>
- <Button size={2}>Login</Button>
+ <Button>Login</Button>
</Flex>
) : (
<LoginButton
diff --git a/apps/designer/app/dashboard/components/card.tsx b/apps/designer/app/dashboard/components/card.tsx
index b86f478740..8a1cb12c60 100644
--- a/apps/designer/app/dashboard/components/card.tsx
+++ b/apps/designer/app/dashboard/components/card.tsx
@@ -68,7 +68,6 @@ export const SelectProjectCard = ({
newProject.length === 0 || transition.state === "submitting"
}
type="submit"
- size="2"
>
{transition.state === "submitting" ? "Creating..." : "Create"}
</Button>
@@ -80,9 +79,7 @@ export const SelectProjectCard = ({
) : null}
</Form>
) : (
- <Button onClick={handleOpen} size="2">
- Open
- </Button>
+ <Button onClick={handleOpen}>Open</Button>
)}
</Flex>
</Card>
diff --git a/apps/designer/app/dashboard/components/header.tsx b/apps/designer/app/dashboard/components/header.tsx
index 682a2a04a1..f6975ffb37 100644
--- a/apps/designer/app/dashboard/components/header.tsx
+++ b/apps/designer/app/dashboard/components/header.tsx
@@ -5,7 +5,7 @@ import {
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
- Button,
+ DeprecatedButton,
Text,
Flex,
} from "@webstudio-is/design-system";
@@ -37,7 +37,7 @@ export const DashboardHeader = ({ user }: { user: User }) => {
<Flex gap="1" align="center">
<DropdownMenu>
<DropdownMenuTrigger asChild>
- <Button variant="raw" aria-label="Menu Button">
+ <DeprecatedButton variant="raw" aria-label="Menu Button">
<Flex gap="1" align="center" css={{ height: "$spacing$11" }}>
<Avatar
src={user?.image || undefined}
@@ -46,7 +46,7 @@ export const DashboardHeader = ({ user }: { user: User }) => {
<ChevronDownIcon width={15} height={15} color="white" />
</Flex>
- </Button>
+ </DeprecatedButton>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem onSelect={() => navigate(logoutPath())}>
diff --git a/apps/designer/app/designer/features/breakpoints/breakpoints-editor.tsx b/apps/designer/app/designer/features/breakpoints/breakpoints-editor.tsx
index feac43d2c0..eb18ad6343 100644
--- a/apps/designer/app/designer/features/breakpoints/breakpoints-editor.tsx
+++ b/apps/designer/app/designer/features/breakpoints/breakpoints-editor.tsx
@@ -75,13 +75,12 @@ const BreakpointEditorItem = ({
/>
<Button
type="button"
- ghost
+ variant="ghost"
onClick={() => {
onDelete(breakpoint);
}}
- >
- <TrashIcon />
- </Button>
+ prefix={<TrashIcon />}
+ />
</Flex>
</form>
);
@@ -112,7 +111,7 @@ export const BreakpointsEditor = ({
>
<Text>Breakpoints</Text>
<Button
- ghost
+ variant="ghost"
onClick={() => {
setBreakpoints([
...breakpoints,
@@ -123,9 +122,8 @@ export const BreakpointsEditor = ({
},
]);
}}
- >
- <PlusIcon />
- </Button>
+ prefix={<PlusIcon />}
+ />
</Flex>
{breakpoints.map((breakpoint) => {
return (
diff --git a/apps/designer/app/designer/features/breakpoints/trigger-button.tsx b/apps/designer/app/designer/features/breakpoints/trigger-button.tsx
index 511f4c76d2..17e2dd8e95 100644
--- a/apps/designer/app/designer/features/breakpoints/trigger-button.tsx
+++ b/apps/designer/app/designer/features/breakpoints/trigger-button.tsx
@@ -6,7 +6,7 @@ import {
useSelectedBreakpoint,
} from "~/designer/shared/nano-states";
import { willRender } from "~/designer/shared/breakpoints";
-import { Button, Text } from "@webstudio-is/design-system";
+import { DeprecatedButton, Text } from "@webstudio-is/design-system";
import {
DesktopIcon,
LaptopIcon,
@@ -14,7 +14,7 @@ import {
TabletIcon,
} from "@webstudio-is/icons";
-type TriggerButtonProps = ComponentProps<typeof Button>;
+type TriggerButtonProps = ComponentProps<typeof DeprecatedButton>;
const renderIcon = (breakpoint: Breakpoint, variant: "contrast" | "hint") => {
const color = variant === "contrast" ? "white" : "hint";
@@ -31,7 +31,7 @@ const renderIcon = (breakpoint: Breakpoint, variant: "contrast" | "hint") => {
};
export const TriggerButton = forwardRef<
- ElementRef<typeof Button>,
+ ElementRef<typeof DeprecatedButton>,
TriggerButtonProps
>((props, ref) => {
const [zoom] = useZoom();
@@ -43,7 +43,7 @@ export const TriggerButton = forwardRef<
const variant = willRender(breakpoint, canvasWidth) ? "contrast" : "hint";
return (
- <Button
+ <DeprecatedButton
{...props}
ref={ref}
css={{ gap: "$spacing$3" }}
@@ -54,7 +54,7 @@ export const TriggerButton = forwardRef<
<Text color={variant}>
{`${breakpoint.label} ${canvasWidth}px / ${zoom}%`}
</Text>
- </Button>
+ </DeprecatedButton>
);
});
diff --git a/apps/designer/app/designer/features/footer/breadcrumbs.tsx b/apps/designer/app/designer/features/footer/breadcrumbs.tsx
index 58b360e1aa..21b03c0bef 100644
--- a/apps/designer/app/designer/features/footer/breadcrumbs.tsx
+++ b/apps/designer/app/designer/features/footer/breadcrumbs.tsx
@@ -1,5 +1,5 @@
import { ChevronRightIcon } from "@webstudio-is/icons";
-import { Button, Flex, Text } from "@webstudio-is/design-system";
+import { DeprecatedButton, Flex, Text } from "@webstudio-is/design-system";
import { type Publish } from "~/shared/pubsub";
import { useSelectedInstancePath } from "~/designer/shared/instance/use-selected-instance-path";
import { useSelectedInstanceData } from "~/designer/shared/nano-states";
@@ -12,7 +12,7 @@ type BreadcrumbProps = {
const Breadcrumb = ({ children, onClick }: BreadcrumbProps) => {
return (
<>
- <Button
+ <DeprecatedButton
ghost
onClick={onClick}
css={{
@@ -23,7 +23,7 @@ const Breadcrumb = ({ children, onClick }: BreadcrumbProps) => {
}}
>
{children}
- </Button>
+ </DeprecatedButton>
<ChevronRightIcon color="white" />
</>
);
diff --git a/apps/designer/app/designer/features/props-panel/props-panel.tsx b/apps/designer/app/designer/features/props-panel/props-panel.tsx
index 7ba117901c..5144de5a3c 100644
--- a/apps/designer/app/designer/features/props-panel/props-panel.tsx
+++ b/apps/designer/app/designer/features/props-panel/props-panel.tsx
@@ -204,13 +204,12 @@ const Property = ({
<Box />
) : (
<Button
- ghost
+ variant="ghost"
onClick={() => {
onDelete(userProp.id);
}}
- >
- <TrashIcon />
- </Button>
+ prefix={<TrashIcon />}
+ />
)}
</>
);
@@ -241,14 +240,13 @@ export const PropsPanel = ({
const addButton = (
<Button
- ghost
+ variant="ghost"
onClick={(event) => {
event.preventDefault();
addEmptyProp();
}}
- >
- <PlusIcon />
- </Button>
+ prefix={<PlusIcon />}
+ />
);
const existingProps = userProps.map((userProp) => userProp.prop);
diff --git a/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx b/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx
index 34fea34938..7dfa7d8300 100644
--- a/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx
+++ b/apps/designer/app/designer/features/sidebar-left/panels/pages/settings.tsx
@@ -290,13 +290,8 @@ const NewPageSettingsView = ({
</Tooltip>
)}
<ButtonContainer>
- <Button
- variant="blue"
- disabled={isSubmitting}
- onClick={onSubmit}
- tabIndex={2}
- >
- {isSubmitting ? "Creating..." : "Create page"}
+ <Button pending={isSubmitting} onClick={onSubmit} tabIndex={2}>
+ {isSubmitting ? "Creating" : "Create page"}
</Button>
</ButtonContainer>
</>
diff --git a/apps/designer/app/designer/features/style-panel/shared/property-name.tsx b/apps/designer/app/designer/features/style-panel/shared/property-name.tsx
index d135085149..47d65046c9 100644
--- a/apps/designer/app/designer/features/style-panel/shared/property-name.tsx
+++ b/apps/designer/app/designer/features/style-panel/shared/property-name.tsx
@@ -38,8 +38,8 @@ const PropertyPopoverContent = ({
return (
<>
<Flex align="start" css={{ px: "$spacing$4", py: "$spacing$3" }}>
- <Button onClick={onReset}>
- <UndoIcon /> &nbsp; Reset
+ <Button onClick={onReset} prefix={<UndoIcon />}>
+ Reset
</Button>
</Flex>
<Separator />
diff --git a/apps/designer/app/designer/features/style-panel/shared/show-more.tsx b/apps/designer/app/designer/features/style-panel/shared/show-more.tsx
index 11484c84ef..67e407e4da 100644
--- a/apps/designer/app/designer/features/style-panel/shared/show-more.tsx
+++ b/apps/designer/app/designer/features/style-panel/shared/show-more.tsx
@@ -15,8 +15,11 @@ export const ShowMore = ({
<Collapsible.Root asChild onOpenChange={setIsOpen}>
<Flex direction="column" gap="3">
<Collapsible.Trigger asChild>
- <Button css={{ width: "100%", gap: "$spacing$3" }}>
- {isOpen ? <TriangleDownIcon /> : <TriangleRightIcon />}Show more
+ <Button
+ css={{ width: "100%" }}
+ prefix={isOpen ? <TriangleDownIcon /> : <TriangleRightIcon />}
+ >
+ Show more
</Button>
</Collapsible.Trigger>
<Collapsible.Content asChild>
diff --git a/apps/designer/app/designer/features/style-panel/style-source-input/style-source.tsx b/apps/designer/app/designer/features/style-panel/style-source-input/style-source.tsx
index 24803c8657..82dfd02833 100644
--- a/apps/designer/app/designer/features/style-panel/style-source-input/style-source.tsx
+++ b/apps/designer/app/designer/features/style-panel/style-source-input/style-source.tsx
@@ -6,7 +6,7 @@ import {
DropdownMenuPortal,
DropdownMenuTrigger,
IconButton,
- Button,
+ DeprecatedButton,
Text,
styled,
} from "@webstudio-is/design-system";
@@ -201,7 +201,7 @@ const useForceRecalcStyle = <Element extends HTMLElement>(
return ref;
};
-const Item = styled(Button, {
+const Item = styled(DeprecatedButton, {
maxWidth: "100%",
position: "relative",
...menuCssVars({ show: false }),
diff --git a/apps/designer/app/designer/features/topbar/publish.tsx b/apps/designer/app/designer/features/topbar/publish.tsx
index 6723b4ab37..b87694bd6a 100644
--- a/apps/designer/app/designer/features/topbar/publish.tsx
+++ b/apps/designer/app/designer/features/topbar/publish.tsx
@@ -4,6 +4,7 @@ import { ExternalLinkIcon, RocketIcon } from "@webstudio-is/icons";
import {
Text,
Button,
+ DeprecatedButton,
Flex,
Label,
Link,
@@ -73,13 +74,9 @@ const Content = ({ project }: PublishButtonProps) => {
{fetcher.data?.errors !== undefined && (
<Text color="error">{fetcher.data?.errors}</Text>
)}
- {fetcher.state === "idle" ? (
- <Button variant="blue" type="submit">
- Publish
- </Button>
- ) : (
- <Button disabled>Publishing…</Button>
- )}
+ <Button pending={fetcher.state !== "idle"} type="submit">
+ {fetcher.state !== "idle" ? "Publishing" : "Publish"}
+ </Button>
</Flex>
</fetcher.Form>
</PopoverContent>
@@ -91,10 +88,10 @@ export const PublishButton = ({ project }: PublishButtonProps) => {
return (
<Popover open={isOpen} onOpenChange={setIsOpen}>
<PopoverTrigger asChild aria-label="Publish">
- <Button ghost css={{ display: "flex", gap: "$spacing$3" }}>
+ <DeprecatedButton ghost css={{ display: "flex", gap: "$spacing$3" }}>
<RocketIcon />
<Text>Publish</Text>
- </Button>
+ </DeprecatedButton>
</PopoverTrigger>
<PopoverPortal>
<Content project={project} />
diff --git a/apps/designer/app/designer/features/topbar/share.tsx b/apps/designer/app/designer/features/topbar/share.tsx
index ae17095228..771e4c1ce3 100644
--- a/apps/designer/app/designer/features/topbar/share.tsx
+++ b/apps/designer/app/designer/features/topbar/share.tsx
@@ -43,7 +43,7 @@ const Content = ({ url }: ShareButtonProps) => {
event?.target.select();
}}
/>
- <Button aria-label="Open in a new tab" variant="blue" type="submit">
+ <Button aria-label="Open in a new tab" type="submit">
Open
</Button>
</Flex>
diff --git a/apps/designer/app/designer/shared/assets/asset-upload.tsx b/apps/designer/app/designer/shared/assets/asset-upload.tsx
index 78afa07061..6e860d7220 100644
--- a/apps/designer/app/designer/shared/assets/asset-upload.tsx
+++ b/apps/designer/app/designer/shared/assets/asset-upload.tsx
@@ -1,5 +1,5 @@
import { ChangeEvent, useRef } from "react";
-import { Button, Flex, Text } from "@webstudio-is/design-system";
+import { Button, Flex } from "@webstudio-is/design-system";
import { UploadIcon } from "@webstudio-is/icons";
import { type AssetType } from "@webstudio-is/asset-uploader";
import { FONT_MIME_TYPES } from "@webstudio-is/fonts";
@@ -45,16 +45,12 @@ export const AssetUpload = ({ type }: AssetUploadProps) => {
style={{ display: "none" }}
/>
<Button
- variant="blue"
type="button"
onClick={() => inputRef?.current?.click()}
- size={2}
css={{ flexGrow: 1 }}
+ prefix={<UploadIcon />}
>
- <Flex align="center" gap={1}>
- <UploadIcon />
- <Text>Upload</Text>
- </Flex>
+ Upload
</Button>
</Flex>
</form>
diff --git a/apps/designer/app/designer/shared/design-tokens-manager/token-editor.tsx b/apps/designer/app/designer/shared/design-tokens-manager/token-editor.tsx
index 526b1b2d8e..aaf8f6190a 100644
--- a/apps/designer/app/designer/shared/design-tokens-manager/token-editor.tsx
+++ b/apps/designer/app/designer/shared/design-tokens-manager/token-editor.tsx
@@ -148,14 +148,13 @@ export const TokenEditor = ({
>
{trigger ?? (
<Button
- ghost
+ variant="ghost"
onClick={(event) => {
event.preventDefault();
onOpenChange(true);
}}
- >
- <PlusIcon />
- </Button>
+ prefix={<PlusIcon />}
+ />
)}
</PopoverTrigger>
<PopoverPortal>
@@ -186,11 +185,7 @@ export const TokenEditor = ({
name="description"
defaultValue={token?.description}
/>
- {token === undefined && (
- <Button type="submit" variant="blue">
- Create
- </Button>
- )}
+ {token === undefined && <Button type="submit">Create</Button>}
</Flex>
</form>
<PopoverHeader title={token?.name ?? "New Token"} />
diff --git a/apps/designer/app/designer/shared/image-manager/image-info-tigger.tsx b/apps/designer/app/designer/shared/image-manager/image-info-tigger.tsx
index 6409865835..78274b9960 100644
--- a/apps/designer/app/designer/shared/image-manager/image-info-tigger.tsx
+++ b/apps/designer/app/designer/shared/image-manager/image-info-tigger.tsx
@@ -1,6 +1,6 @@
import { useState } from "react";
import {
- Button,
+ DeprecatedButton,
Popover,
PopoverContent,
PopoverPortal,
@@ -29,7 +29,7 @@ export const ImageInfoTrigger = ({
return (
<Popover open={isInfoOpen} onOpenChange={setInfoOpen}>
<PopoverTrigger asChild>
- <Button
+ <DeprecatedButton
variant="raw"
title="Options"
onClick={() => setInfoOpen(true)}
@@ -48,7 +48,7 @@ export const ImageInfoTrigger = ({
}}
>
<GearIcon />
- </Button>
+ </DeprecatedButton>
</PopoverTrigger>
<PopoverPortal>
<PopoverContent css={{ zIndex: "$1" }}>
diff --git a/apps/designer/app/designer/shared/image-manager/image-info.tsx b/apps/designer/app/designer/shared/image-manager/image-info.tsx
index 9a4f1c55ab..44fe3a2bbe 100644
--- a/apps/designer/app/designer/shared/image-manager/image-info.tsx
+++ b/apps/designer/app/designer/shared/image-manager/image-info.tsx
@@ -47,11 +47,12 @@ export const ImageInfo = ({ asset, onDelete }: ImageInfoProps) => {
</Box>
) : null}
<Box css={{ p: "$spacing$5 $spacing$9" }}>
- <Button variant="red" size="2" onClick={() => onDelete([id])}>
- <Flex align="center" css={{ gap: "$spacing$3" }}>
- <TrashIcon />
- Delete
- </Flex>
+ <Button
+ variant="destructive"
+ onClick={() => onDelete([id])}
+ prefix={<TrashIcon />}
+ >
+ Delete
</Button>
</Box>
</>
diff --git a/packages/design-system/src/__generated__/figma-design-tokens.ts b/packages/design-system/src/__generated__/figma-design-tokens.ts
index f05f5494a0..16285218dc 100644
--- a/packages/design-system/src/__generated__/figma-design-tokens.ts
+++ b/packages/design-system/src/__generated__/figma-design-tokens.ts
@@ -53,7 +53,13 @@ export const fontFamilies = {
manrope: "Manrope",
} as const;
-export const lineHeights = { "0": 16, "1": 8, "2": 10, "3": "AUTO" } as const;
+export const lineHeights = {
+ "0": 16,
+ "1": 8,
+ "2": 10,
+ "3": "AUTO",
+ "4": 11,
+} as const;
export const fontWeights = {
inter0: "Regular",
@@ -89,7 +95,7 @@ export const typography = {
fontSize: 12,
letterSpacing: "0.5%",
paragraphSpacing: 0,
- paragraphIndent: "{paragraphIndent.0}",
+ paragraphIndent: "0px",
textCase: "none",
textDecoration: "none",
},
@@ -100,7 +106,7 @@ export const typography = {
fontSize: 12,
letterSpacing: "0.5%",
paragraphSpacing: 0,
- paragraphIndent: "{paragraphIndent.0}",
+ paragraphIndent: "0px",
textCase: "none",
textDecoration: "none",
},
@@ -111,7 +117,7 @@ export const typography = {
fontSize: 12,
letterSpacing: "1%",
paragraphSpacing: 0,
- paragraphIndent: "{paragraphIndent.0}",
+ paragraphIndent: "0px",
textCase: "none",
textDecoration: "none",
},
@@ -122,7 +128,7 @@ export const typography = {
fontSize: 12,
letterSpacing: "0%",
paragraphSpacing: 0,
- paragraphIndent: "{paragraphIndent.0}",
+ paragraphIndent: "0px",
textCase: "none",
textDecoration: "none",
},
@@ -133,7 +139,7 @@ export const typography = {
fontSize: 8,
letterSpacing: "1%",
paragraphSpacing: 0,
- paragraphIndent: "{paragraphIndent.0}",
+ paragraphIndent: "0px",
textCase: "none",
textDecoration: "none",
},
@@ -144,7 +150,7 @@ export const typography = {
fontSize: 10,
letterSpacing: 0,
paragraphSpacing: 0,
- paragraphIndent: "{paragraphIndent.0}",
+ paragraphIndent: "0px",
textCase: "uppercase",
textDecoration: "none",
},
@@ -155,7 +161,7 @@ export const typography = {
fontSize: 10,
letterSpacing: "0%",
paragraphSpacing: 0,
- paragraphIndent: "{paragraphIndent.0}",
+ paragraphIndent: "0px",
textCase: "none",
textDecoration: "none",
},
@@ -166,7 +172,7 @@ export const typography = {
fontSize: 8,
letterSpacing: "1%",
paragraphSpacing: 0,
- paragraphIndent: "{paragraphIndent.0}",
+ paragraphIndent: "0px",
textCase: "uppercase",
textDecoration: "none",
},
@@ -177,7 +183,7 @@ export const typography = {
fontSize: 32,
letterSpacing: "0.5%",
paragraphSpacing: 0,
- paragraphIndent: "{paragraphIndent.0}",
+ paragraphIndent: "0px",
textCase: "none",
textDecoration: "none",
},
@@ -188,7 +194,40 @@ export const typography = {
fontSize: 20,
letterSpacing: "0.5%",
paragraphSpacing: 0,
- paragraphIndent: "{paragraphIndent.0}",
+ paragraphIndent: "0px",
+ textCase: "none",
+ textDecoration: "none",
+ },
+ spaceSectionValueText: {
+ fontFamily: "Inter",
+ fontWeight: "Medium",
+ lineHeight: 10,
+ fontSize: 10,
+ letterSpacing: "0%",
+ paragraphSpacing: 0,
+ paragraphIndent: "0px",
+ textCase: "none",
+ textDecoration: "none",
+ },
+ spaceSectionUnitText: {
+ fontFamily: "Inter",
+ fontWeight: "Semi Bold",
+ lineHeight: 8,
+ fontSize: 8,
+ letterSpacing: "1%",
+ paragraphSpacing: 0,
+ paragraphIndent: "0px",
+ textCase: "uppercase",
+ textDecoration: "none",
+ },
+ small: {
+ fontFamily: "Inter",
+ fontWeight: "Regular",
+ lineHeight: 11,
+ fontSize: 10,
+ letterSpacing: "0%",
+ paragraphSpacing: 0,
+ paragraphIndent: "0px",
textCase: "none",
textDecoration: "none",
},
@@ -218,7 +257,7 @@ export const color = {
backgroundControls: "#ffffff",
backgroundAssetcardHover: "#e6e8eb",
backgroundBrandGradient: "linear-gradient(180deg, #e63cfe 0%, #ffae3c 100%)",
- backgroundNeutralMain: "#687076",
+ backgroundNeutralMain: "#D7DBDF",
backgroundNeutralAccent: "#11181c",
backgroundNeutralNotification: "#ffffff",
backgroundDestructiveMain: "#dc3d43",
@@ -229,8 +268,8 @@ export const color = {
backgroundAlertNotification: "#fffbd1",
backgroundInfoMain: "#006adc",
backgroundInfoNotification: "#edf6ff",
- backgroundPresetMain: "#dfe3e6",
- backgroundPresetHover: "#d7dbdf",
+ backgroundPresetMain: "#E6E8EB",
+ backgroundPresetHover: "#DFE3E6",
backgroundSetMain: "#e1f0ff",
backgroundSetHover: "#cee7fe",
backgroundInheritedMain: "#ffe8d7",
@@ -253,6 +292,17 @@ export const color = {
backgroundProjectCardTextArea: "#ffffffe6",
backgroundPublishedMain: "#39fbbb",
backgroundPublishedContrast: "#ebfffc",
+ backgroundStyleSourceToken: "#0081f1",
+ backgroundStyleSourceTag: "#d23197",
+ backgroundStyleSourceState: "#299764",
+ backgroundStyleSourceNeutral: "#687076",
+ backgroundStyleSourceDisabled: "#9da2a6",
+ backgroundStyleSourceGradientToken:
+ "linear-gradient(90deg, #0081f100 0%, #0081f1 31.87%)",
+ backgroundStyleSourceGradientTag:
+ "linear-gradient(90deg, #d2319700 0%, #d23197 31.87%)",
+ backgroundStyleSourceGradientState:
+ "linear-gradient(90deg, #29976400 0%, #299764 31.87%)",
borderMain: "#c1c8cd",
borderFocus: "#0081f1",
borderMenuInner: "#fcfcfc",
@@ -295,4 +345,8 @@ export const color = {
maintenanceSpacerViz: "#f9c6c6",
} as const;
+export const borderWidth = { borderWidth1: 1, borderWidth2: 2 } as const;
+
+export const dimension = { paragraphIndent0: "0px" } as const;
+
export const other = { tokenSetOrder0: "global" } as const;
diff --git a/packages/design-system/src/components/__DEPRECATED__/button.stories.tsx b/packages/design-system/src/components/__DEPRECATED__/button.stories.tsx
new file mode 100644
index 0000000000..346a249f17
--- /dev/null
+++ b/packages/design-system/src/components/__DEPRECATED__/button.stories.tsx
@@ -0,0 +1,10 @@
+import type { ComponentStory } from "@storybook/react";
+import { DeprecatedButton } from "./button";
+
+export default {
+ component: DeprecatedButton,
+};
+
+export const Simple: ComponentStory<typeof DeprecatedButton> = () => {
+ return <DeprecatedButton>Simple</DeprecatedButton>;
+};
diff --git a/packages/design-system/src/components/__DEPRECATED__/button.tsx b/packages/design-system/src/components/__DEPRECATED__/button.tsx
new file mode 100644
index 0000000000..194abd8877
--- /dev/null
+++ b/packages/design-system/src/components/__DEPRECATED__/button.tsx
@@ -0,0 +1,328 @@
+import { styled } from "../../stitches.config";
+
+export const DeprecatedButton = styled("button", {
+ // Reset
+ all: "unset",
+ alignItems: "center",
+ boxSizing: "border-box",
+ border: "none",
+ userSelect: "none",
+ transition: "all 150ms ease-out",
+ "&::before": {
+ boxSizing: "border-box",
+ },
+ "&::after": {
+ boxSizing: "border-box",
+ },
+
+ // Custom reset?
+ display: "inline-flex",
+ flexShrink: 0,
+ justifyContent: "center",
+ lineHeight: 1,
+ WebkitTapHighlightColor: "rgba(0,0,0,0)",
+ minWidth: 0,
+
+ // Custom
+ height: "$spacing$11",
+ px: "$spacing$5",
+ fontFamily: "$sans",
+ fontSize: "$fontSize$3",
+ fontWeight: 500,
+ fontVariantNumeric: "tabular-nums",
+
+ "&:disabled": {
+ backgroundColor: "$slate2",
+ boxShadow: "inset 0 0 0 1px $colors$slate7",
+ color: "$slate8",
+ pointerEvents: "none",
+ },
+
+ variants: {
+ size: {
+ "1": {
+ borderRadius: "$borderRadius$4",
+ height: "$spacing$11",
+ px: "$spacing$4",
+ fontSize: "$fontSize$3",
+ },
+ "2": {
+ borderRadius: "$borderRadius$6",
+ height: "$spacing$12",
+ px: "$spacing$9",
+ fontSize: "$fontSize$4",
+ },
+ "3": {
+ borderRadius: "$borderRadius$6",
+ height: "$spacing$17",
+ px: "$spacing$10",
+ fontSize: "$fontSize$4",
+ },
+ },
+ variant: {
+ gray: {
+ backgroundColor: "$loContrast",
+ boxShadow: "inset 0 0 0 1px $colors$slate7",
+ color: "$hiContrast",
+ "@hover": {
+ "&:hover": {
+ boxShadow: "inset 0 0 0 1px $colors$slate8",
+ },
+ },
+ "&:active": {
+ backgroundColor: "$slate2",
+ boxShadow: "inset 0 0 0 1px $colors$slate8",
+ },
+ "&:focus": {
+ boxShadow: "inset 0 0 0 1px $colors$slate8, 0 0 0 1px $colors$slate8",
+ },
+ '&[data-state="open"]': {
+ backgroundColor: "$slate4",
+ boxShadow: "inset 0 0 0 1px $colors$slate8",
+ },
+ },
+ blue: {
+ backgroundColor: "$blue10",
+ color: "white",
+ "@hover": {
+ "&:hover": {
+ backgroundColor: "$loContrast",
+ color: "$blue10",
+ boxShadow: "inset 0 0 0 1.5px $colors$blue10",
+ },
+ },
+ "&:active": {
+ boxShadow: "inset 0 0 0 1.5px $colors$blue8",
+ },
+ "&:focus": {
+ boxShadow:
+ "inset 0 0 0 1.5px $colors$blue8, 0 0 0 1.5px $colors$blue8",
+ },
+ '&[data-state="open"]': {
+ boxShadow: "inset 0 0 0 1.5px $colors$blue8",
+ },
+ },
+ green: {
+ backgroundColor: "$green2",
+ boxShadow: "inset 0 0 0 1px $colors$green7",
+ color: "$green11",
+ "@hover": {
+ "&:hover": {
+ boxShadow: "inset 0 0 0 1px $colors$green8",
+ },
+ },
+ "&:active": {
+ backgroundColor: "$green3",
+ boxShadow: "inset 0 0 0 1px $colors$green8",
+ },
+ "&:focus": {
+ boxShadow: "inset 0 0 0 1px $colors$green8, 0 0 0 1px $colors$green8",
+ },
+ '&[data-state="open"]': {
+ backgroundColor: "$green4",
+ boxShadow: "inset 0 0 0 1px $colors$green8",
+ },
+ },
+ red: {
+ backgroundColor: "$loContrast",
+ boxShadow: "inset 0 0 0 1px $colors$red10",
+ color: "$red10",
+ "@hover": {
+ "&:hover": {
+ background: "$red10",
+ color: "$loContrast",
+ },
+ },
+ "&:active": {
+ backgroundColor: "$red11",
+ color: "$loContrast",
+ },
+ "&:focus": {
+ boxShadow: "inset 0 0 0 1px $colors$red8, 0 0 0 1px $colors$red8",
+ },
+ '&[data-state="open"]': {
+ backgroundColor: "$red4",
+ boxShadow: "inset 0 0 0 1px $colors$red8",
+ },
+ },
+ transparentWhite: {
+ backgroundColor: "hsla(0,100%,100%,.2)",
+ color: "white",
+ "@hover": {
+ "&:hover": {
+ backgroundColor: "hsla(0,100%,100%,.25)",
+ },
+ },
+ "&:active": {
+ backgroundColor: "hsla(0,100%,100%,.3)",
+ },
+ "&:focus": {
+ boxShadow:
+ "inset 0 0 0 1px hsla(0,100%,100%,.35), 0 0 0 1px hsla(0,100%,100%,.35)",
+ },
+ },
+ raw: {
+ background: "transparent",
+ color: "inherit",
+ padding: 0,
+ borderRadius: 0,
+ height: "auto",
+ },
+ transparentBlack: {
+ backgroundColor: "hsla(0,0%,0%,.2)",
+ color: "black",
+ "@hover": {
+ "&:hover": {
+ backgroundColor: "hsla(0,0%,0%,.25)",
+ },
+ },
+ "&:active": {
+ backgroundColor: "hsla(0,0%,0%,.3)",
+ },
+ "&:focus": {
+ boxShadow:
+ "inset 0 0 0 1px hsla(0,0%,0%,.35), 0 0 0 1px hsla(0,0%,0%,.35)",
+ },
+ },
+ },
+ state: {
+ active: {
+ backgroundColor: "$slate4",
+ boxShadow: "inset 0 0 0 1px $colors$slate8",
+ color: "$slate11",
+ "@hover": {
+ "&:hover": {
+ backgroundColor: "$slate6",
+ boxShadow: "inset 0 0 0 1px $colors$slate8",
+ },
+ },
+ "&:active": {
+ backgroundColor: "$slate6",
+ },
+ "&:focus": {
+ boxShadow: "inset 0 0 0 1px $colors$slate8, 0 0 0 1px $colors$slate8",
+ },
+ },
+ waiting: {
+ backgroundColor: "$slate4",
+ boxShadow: "inset 0 0 0 1px $colors$slate8",
+ color: "$colors$slate9",
+ cursor: "wait",
+ "&:hover, &:active": {
+ color: "$colors$slate9",
+ },
+ "&:focus": {
+ boxShadow: "inset 0 0 0 1px $colors$slate8",
+ },
+ },
+ },
+ ghost: {
+ true: {
+ backgroundColor: "transparent",
+ boxShadow: "none",
+ },
+ },
+ },
+ compoundVariants: [
+ {
+ variant: "gray",
+ ghost: "true",
+ css: {
+ backgroundColor: "transparent",
+ color: "$hiContrast",
+ "@hover": {
+ "&:hover": {
+ backgroundColor: "$slateA3",
+ boxShadow: "none",
+ },
+ },
+ "&:active": {
+ backgroundColor: "$slateA4",
+ },
+ "&:focus": {
+ boxShadow:
+ "inset 0 0 0 1px $colors$slateA8, 0 0 0 1px $colors$slateA8",
+ },
+ '&[data-state="open"]': {
+ backgroundColor: "$slateA4",
+ boxShadow: "none",
+ },
+ },
+ },
+ {
+ variant: "blue",
+ ghost: "true",
+ css: {
+ backgroundColor: "transparent",
+ "@hover": {
+ "&:hover": {
+ backgroundColor: "$blueA3",
+ boxShadow: "none",
+ },
+ },
+ "&:active": {
+ backgroundColor: "$blueA4",
+ },
+ "&:focus": {
+ boxShadow:
+ "0px 0px 0px 2px $colors$blue10, 0px 0px 0px 2px $colors$blue10",
+ },
+ '&[data-state="open"]': {
+ backgroundColor: "$blueA4",
+ boxShadow: "none",
+ },
+ },
+ },
+ {
+ variant: "green",
+ ghost: "true",
+ css: {
+ backgroundColor: "transparent",
+ "@hover": {
+ "&:hover": {
+ backgroundColor: "$greenA3",
+ boxShadow: "none",
+ },
+ },
+ "&:active": {
+ backgroundColor: "$greenA4",
+ },
+ "&:focus": {
+ boxShadow:
+ "inset 0 0 0 1px $colors$greenA8, 0 0 0 1px $colors$greenA8",
+ },
+ '&[data-state="open"]': {
+ backgroundColor: "$greenA4",
+ boxShadow: "none",
+ },
+ },
+ },
+ {
+ variant: "red",
+ ghost: "true",
+ css: {
+ backgroundColor: "transparent",
+ "@hover": {
+ "&:hover": {
+ backgroundColor: "$redA3",
+ boxShadow: "none",
+ },
+ },
+ "&:active": {
+ backgroundColor: "$redA4",
+ },
+ "&:focus": {
+ boxShadow: "inset 0 0 0 1px $colors$redA8, 0 0 0 1px $colors$redA8",
+ },
+ '&[data-state="open"]': {
+ backgroundColor: "$redA4",
+ boxShadow: "none",
+ },
+ },
+ },
+ ],
+ defaultVariants: {
+ size: "1",
+ variant: "gray",
+ },
+});
diff --git a/packages/design-system/src/components/button.stories.tsx b/packages/design-system/src/components/button.stories.tsx
index 9ebf2caf27..d19273f388 100644
--- a/packages/design-system/src/components/button.stories.tsx
+++ b/packages/design-system/src/components/button.stories.tsx
@@ -1,10 +1,98 @@
-import type { ComponentStory } from "@storybook/react";
-import { Button } from "./button";
+import { type ComponentProps } from "react";
+import { MenuIcon, CrossIcon, TrashIcon } from "@webstudio-is/icons";
+import { Button as ButtonComponent } from "./button";
export default {
- component: Button,
+ title: "Library/Button",
};
-export const Simple: ComponentStory<typeof Button> = () => {
- return <Button>Simple</Button>;
+const iconsMap = {
+ undefined: undefined,
+ "<MenuIcon>": <MenuIcon />,
+ "<CrossIcon>": <CrossIcon />,
+ "<TrashIcon>": <TrashIcon />,
+} as const;
+
+const Section = ({
+ title,
+ children,
+}: {
+ title: string;
+ children: React.ReactNode;
+}) => (
+ <>
+ <h3 style={{ fontFamily: "sans-serif" }}>{title}</h3>
+ <div style={{ display: "flex", gap: 12 }}>{children}</div>
+ </>
+);
+
+export const Button = ({
+ prefix,
+ suffix,
+ ...rest
+}: Omit<ComponentProps<typeof ButtonComponent>, "prefix" | "suffix"> & {
+ prefix?: keyof typeof iconsMap;
+ suffix?: keyof typeof iconsMap;
+}) => (
+ <>
+ <Section title="Configurable">
+ <ButtonComponent
+ prefix={prefix && iconsMap[prefix]}
+ suffix={suffix && iconsMap[suffix]}
+ {...rest}
+ />
+ </Section>
+
+ <Section title="Variants">
+ {variants.map((variant) => (
+ <ButtonComponent variant={variant} key={variant}>
+ {variant}
+ </ButtonComponent>
+ ))}
+ </Section>
+
+ <Section title="With Icon">
+ <ButtonComponent prefix={<TrashIcon />}>Button</ButtonComponent>
+ <ButtonComponent suffix={<TrashIcon />}>Button</ButtonComponent>
+ <ButtonComponent prefix={<TrashIcon />} />
+ </Section>
+
+ <Section title="Disabled">
+ <ButtonComponent disabled>Button</ButtonComponent>
+ <ButtonComponent disabled prefix={<TrashIcon />}>
+ Button
+ </ButtonComponent>
+ <ButtonComponent disabled prefix={<TrashIcon />} />
+ </Section>
+
+ <Section title="Pending">
+ <ButtonComponent pending>Button</ButtonComponent>
+ <ButtonComponent pending prefix={<TrashIcon />}>
+ Button
+ </ButtonComponent>
+ <ButtonComponent pending prefix={<TrashIcon />} />
+ </Section>
+ </>
+);
+
+const variants: ReadonlyArray<
+ Extract<ComponentProps<typeof ButtonComponent>["variant"], string>
+> = ["primary", "neutral", "destructive", "positive", "ghost"];
+
+Button.argTypes = {
+ children: { defaultValue: "Button", control: "text" },
+ variant: {
+ defaultValue: "primary",
+ control: { type: "inline-radio", options: variants },
+ },
+ prefix: {
+ defaultValue: "undefined",
+ control: { type: "inline-radio", options: Object.keys(iconsMap) },
+ },
+ suffix: {
+ defaultValue: "undefined",
+ control: { type: "inline-radio", options: Object.keys(iconsMap) },
+ },
+ disabled: { defaultValue: false, control: "boolean" },
+ pending: { defaultValue: false, control: "boolean" },
};
diff --git a/packages/design-system/src/components/button.tsx b/packages/design-system/src/components/button.tsx
index 18a031d393..54aa70e5fe 100644
--- a/packages/design-system/src/components/button.tsx
+++ b/packages/design-system/src/components/button.tsx
@@ -1,328 +1,138 @@
+/**
+ * Implementation of the "Button" component from:
+ * https://www.figma.com/file/sfCE7iLS0k25qCxiifQNLE/%F0%9F%93%9A-Webstudio-Library?node-id=0%3A1
+ */
+
+import React, { forwardRef, type Ref, type ComponentProps } from "react";
+import { Text } from "./text";
import { styled } from "../stitches.config";
-export const Button = styled("button", {
- // Reset
- all: "unset",
- alignItems: "center",
- boxSizing: "border-box",
- border: "none",
- userSelect: "none",
- transition: "all 150ms ease-out",
- "&::before": {
- boxSizing: "border-box",
+// CSS supports multiple gradients as backgrounds but not multiple colors
+const backgroundColors = ({
+ overlay,
+ base,
+}: {
+ overlay: string;
+ base: string;
+}) =>
+ `linear-gradient(${overlay}, ${overlay}), linear-gradient(${base}, ${base})`;
+
+const backgroundStyle = (baseColor: string) => ({
+ background: baseColor,
+ "&:hover": {
+ background: backgroundColors({
+ base: baseColor,
+ overlay: "$colors$backgroundButtonHover",
+ }),
},
- "&::after": {
- boxSizing: "border-box",
+ "&:active": {
+ background: backgroundColors({
+ base: baseColor,
+ overlay: "$colors$backgroundButtonPressed",
+ }),
},
+});
- // Custom reset?
+const StyledButton = styled("button", {
+ all: "unset",
+ boxSizing: "border-box",
+ minWidth: 0,
display: "inline-flex",
- flexShrink: 0,
+ alignItems: "center",
justifyContent: "center",
- lineHeight: 1,
- WebkitTapHighlightColor: "rgba(0,0,0,0)",
- minWidth: 0,
-
- // Custom
- height: "$spacing$11",
- px: "$spacing$5",
- fontFamily: "$sans",
- fontSize: "$fontSize$3",
- fontWeight: 500,
- fontVariantNumeric: "tabular-nums",
+ gap: "$spacing$2",
+ color: "$colors$foregroundContrastMain",
+ padding: "0 $spacing$4",
+ height: "$spacing$12",
+ borderRadius: "$borderRadius$4",
- "&:disabled": {
- backgroundColor: "$slate2",
- boxShadow: "inset 0 0 0 1px $colors$slate7",
- color: "$slate8",
- pointerEvents: "none",
+ "&:focus-visible": {
+ outline: "2px solid $colors$borderFocus",
+ outlineOffset: "1px",
},
variants: {
- size: {
- "1": {
- borderRadius: "$borderRadius$4",
- height: "$spacing$11",
- px: "$spacing$4",
- fontSize: "$fontSize$3",
- },
- "2": {
- borderRadius: "$borderRadius$6",
- height: "$spacing$12",
- px: "$spacing$9",
- fontSize: "$fontSize$4",
- },
- "3": {
- borderRadius: "$borderRadius$6",
- height: "$spacing$17",
- px: "$spacing$10",
- fontSize: "$fontSize$4",
- },
- },
+ // "variant" is used instead of "type" as in Figma,
+ // because type is already taken for type=submit etc.
variant: {
- gray: {
- backgroundColor: "$loContrast",
- boxShadow: "inset 0 0 0 1px $colors$slate7",
- color: "$hiContrast",
- "@hover": {
- "&:hover": {
- boxShadow: "inset 0 0 0 1px $colors$slate8",
- },
- },
- "&:active": {
- backgroundColor: "$slate2",
- boxShadow: "inset 0 0 0 1px $colors$slate8",
- },
- "&:focus": {
- boxShadow: "inset 0 0 0 1px $colors$slate8, 0 0 0 1px $colors$slate8",
- },
- '&[data-state="open"]': {
- backgroundColor: "$slate4",
- boxShadow: "inset 0 0 0 1px $colors$slate8",
- },
- },
- blue: {
- backgroundColor: "$blue10",
- color: "white",
- "@hover": {
- "&:hover": {
- backgroundColor: "$loContrast",
- color: "$blue10",
- boxShadow: "inset 0 0 0 1.5px $colors$blue10",
- },
- },
- "&:active": {
- boxShadow: "inset 0 0 0 1.5px $colors$blue8",
- },
- "&:focus": {
- boxShadow:
- "inset 0 0 0 1.5px $colors$blue8, 0 0 0 1.5px $colors$blue8",
- },
- '&[data-state="open"]': {
- boxShadow: "inset 0 0 0 1.5px $colors$blue8",
- },
- },
- green: {
- backgroundColor: "$green2",
- boxShadow: "inset 0 0 0 1px $colors$green7",
- color: "$green11",
- "@hover": {
- "&:hover": {
- boxShadow: "inset 0 0 0 1px $colors$green8",
- },
- },
- "&:active": {
- backgroundColor: "$green3",
- boxShadow: "inset 0 0 0 1px $colors$green8",
- },
- "&:focus": {
- boxShadow: "inset 0 0 0 1px $colors$green8, 0 0 0 1px $colors$green8",
- },
- '&[data-state="open"]': {
- backgroundColor: "$green4",
- boxShadow: "inset 0 0 0 1px $colors$green8",
- },
- },
- red: {
- backgroundColor: "$loContrast",
- boxShadow: "inset 0 0 0 1px $colors$red10",
- color: "$red10",
- "@hover": {
- "&:hover": {
- background: "$red10",
- color: "$loContrast",
- },
- },
- "&:active": {
- backgroundColor: "$red11",
- color: "$loContrast",
- },
- "&:focus": {
- boxShadow: "inset 0 0 0 1px $colors$red8, 0 0 0 1px $colors$red8",
- },
- '&[data-state="open"]': {
- backgroundColor: "$red4",
- boxShadow: "inset 0 0 0 1px $colors$red8",
- },
- },
- transparentWhite: {
- backgroundColor: "hsla(0,100%,100%,.2)",
- color: "white",
- "@hover": {
- "&:hover": {
- backgroundColor: "hsla(0,100%,100%,.25)",
- },
- },
- "&:active": {
- backgroundColor: "hsla(0,100%,100%,.3)",
- },
- "&:focus": {
- boxShadow:
- "inset 0 0 0 1px hsla(0,100%,100%,.35), 0 0 0 1px hsla(0,100%,100%,.35)",
- },
- },
- raw: {
+ primary: { ...backgroundStyle("$colors$backgroundPrimary") },
+ neutral: {
+ ...backgroundStyle("$colors$backgroundNeutralMain"),
+ color: "$colors$foregroundMain",
+ },
+ destructive: { ...backgroundStyle("$colors$backgroundDestructiveMain") },
+ positive: { ...backgroundStyle("$colors$backgroundSuccessMain") },
+ ghost: {
+ ...backgroundStyle("$colors$backgroundHover"),
background: "transparent",
- color: "inherit",
- padding: 0,
- borderRadius: 0,
- height: "auto",
- },
- transparentBlack: {
- backgroundColor: "hsla(0,0%,0%,.2)",
- color: "black",
- "@hover": {
- "&:hover": {
- backgroundColor: "hsla(0,0%,0%,.25)",
- },
- },
- "&:active": {
- backgroundColor: "hsla(0,0%,0%,.3)",
- },
- "&:focus": {
- boxShadow:
- "inset 0 0 0 1px hsla(0,0%,0%,.35), 0 0 0 1px hsla(0,0%,0%,.35)",
- },
+ color: "$colors$foregroundMain",
},
},
- state: {
- active: {
- backgroundColor: "$slate4",
- boxShadow: "inset 0 0 0 1px $colors$slate8",
- color: "$slate11",
- "@hover": {
- "&:hover": {
- backgroundColor: "$slate6",
- boxShadow: "inset 0 0 0 1px $colors$slate8",
- },
- },
- "&:active": {
- backgroundColor: "$slate6",
- },
- "&:focus": {
- boxShadow: "inset 0 0 0 1px $colors$slate8, 0 0 0 1px $colors$slate8",
- },
- },
- waiting: {
- backgroundColor: "$slate4",
- boxShadow: "inset 0 0 0 1px $colors$slate8",
- color: "$colors$slate9",
- cursor: "wait",
- "&:hover, &:active": {
- color: "$colors$slate9",
- },
- "&:focus": {
- boxShadow: "inset 0 0 0 1px $colors$slate8",
- },
- },
- },
- ghost: {
+ pending: {
true: {
- backgroundColor: "transparent",
- boxShadow: "none",
- },
- },
- },
- compoundVariants: [
- {
- variant: "gray",
- ghost: "true",
- css: {
- backgroundColor: "transparent",
- color: "$hiContrast",
- "@hover": {
- "&:hover": {
- backgroundColor: "$slateA3",
- boxShadow: "none",
- },
- },
- "&:active": {
- backgroundColor: "$slateA4",
- },
- "&:focus": {
- boxShadow:
- "inset 0 0 0 1px $colors$slateA8, 0 0 0 1px $colors$slateA8",
- },
- '&[data-state="open"]': {
- backgroundColor: "$slateA4",
- boxShadow: "none",
- },
- },
- },
- {
- variant: "blue",
- ghost: "true",
- css: {
- backgroundColor: "transparent",
- "@hover": {
- "&:hover": {
- backgroundColor: "$blueA3",
- boxShadow: "none",
- },
- },
- "&:active": {
- backgroundColor: "$blueA4",
- },
- "&:focus": {
- boxShadow:
- "0px 0px 0px 2px $colors$blue10, 0px 0px 0px 2px $colors$blue10",
- },
- '&[data-state="open"]': {
- backgroundColor: "$blueA4",
- boxShadow: "none",
- },
- },
- },
- {
- variant: "green",
- ghost: "true",
- css: {
- backgroundColor: "transparent",
- "@hover": {
- "&:hover": {
- backgroundColor: "$greenA3",
- boxShadow: "none",
- },
- },
- "&:active": {
- backgroundColor: "$greenA4",
- },
- "&:focus": {
- boxShadow:
- "inset 0 0 0 1px $colors$greenA8, 0 0 0 1px $colors$greenA8",
- },
- '&[data-state="open"]': {
- backgroundColor: "$greenA4",
- boxShadow: "none",
- },
+ cursor: "wait",
},
- },
- {
- variant: "red",
- ghost: "true",
- css: {
- backgroundColor: "transparent",
- "@hover": {
- "&:hover": {
- backgroundColor: "$redA3",
- boxShadow: "none",
- },
- },
- "&:active": {
- backgroundColor: "$redA4",
- },
- "&:focus": {
- boxShadow: "inset 0 0 0 1px $colors$redA8, 0 0 0 1px $colors$redA8",
- },
- '&[data-state="open"]': {
- backgroundColor: "$redA4",
- boxShadow: "none",
+ false: {
+ "&[disabled]": {
+ background: "$colors$backgroundButtonDisabled",
+ color: "$colors$foregroundDisabled",
},
},
},
- ],
+ },
+
defaultVariants: {
- size: "1",
- variant: "gray",
+ variant: "primary",
},
});
+
+const TextContainer = styled(Text, {
+ padding: "0 $spacing$2",
+ // <Text> incorrectly sets lineHeight to 1 for all variants
+ // here we set lineHeight as it's defined for "label" in Figma
+ // @todo: fix <Text>
+ lineHeight: "$lineHeight$3",
+ defaultVariants: { variant: "label" },
+});
+
+type ButtonProps = {
+ pending?: boolean;
+
+ // prefix/suffix is primarily for Icons
+ // this is a replacement for icon/icon-left/icon-right in Figma
+ prefix?: React.ReactNode;
+ suffix?: React.ReactNode;
+} & Omit<ComponentProps<typeof StyledButton>, "pending" | "prefix">;
+
+export const Button = forwardRef(
+ (
+ {
+ pending = false,
+ disabled = false,
+ prefix,
+ suffix,
+ children,
+ ...restProps
+ }: ButtonProps,
+ ref: Ref<HTMLButtonElement>
+ ) => {
+ return (
+ <StyledButton
+ {...restProps}
+ pending={pending}
+ disabled={disabled || pending}
+ ref={ref}
+ >
+ {prefix}
+ {children && (
+ <TextContainer>
+ {children}
+ {pending ? "…" : ""}
+ </TextContainer>
+ )}
+ {suffix}
+ </StyledButton>
+ );
+ }
+);
+Button.displayName = "Button";
diff --git a/packages/design-system/src/index.ts b/packages/design-system/src/index.ts
index 89b061f925..e5a8d5c7e6 100644
--- a/packages/design-system/src/index.ts
+++ b/packages/design-system/src/index.ts
@@ -30,6 +30,7 @@ export {
useEnhancedTooltipProps,
} from "./components/enhanced-tooltip";
export { Button } from "./components/button";
+export { DeprecatedButton } from "./components/__DEPRECATED__/button";
export { DeprecatedIconButton } from "./components/__DEPRECATED__/icon-button";
export { IconButton } from "./components/icon-button";
export { Box } from "./components/box";