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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
apply figma design to text-field, remove size variant
Oleg Isonene777b735f3cd
diff --git a/packages/design-system/src/components/text-field.stories.tsx b/packages/design-system/src/components/text-field.stories.tsxindex 28b2bef61e..f49a1c0adb 100644--- a/packages/design-system/src/components/text-field.stories.tsx+++ b/packages/design-system/src/components/text-field.stories.tsx@@ -2,7 +2,7 @@ import { expect } from "@storybook/jest";import { userEvent, waitFor, within } from "@storybook/testing-library";import React from "react";import { ComponentStory } from "@storybook/react";-import { BrushIcon, ChevronDownIcon } from "@webstudio-is/icons";+import { RowGapIcon, ChevronDownIcon } from "@webstudio-is/icons";import { Button } from "./button";import { Flex } from "./flex";import { IconButton } from "./icon-button";@@ -36,15 +36,6 @@ export const NativeProps: ComponentStory<typeof TextField> = () => {);};-export const Sizes: ComponentStory<typeof TextField> = () => {- return (- <Flex direction="column" gap={3}>- <TextField size={1} />- <TextField size={2} />- </Flex>- );-};-export const Variants: ComponentStory<typeof TextField> = () => {return (<Flex direction="column" gap={3}>@@ -68,7 +59,7 @@ export const PrefixSuffix: ComponentStory<typeof TextField> = () => {return (<Flex direction="column" gap={3}><TextField- prefix={<BrushIcon />}+ prefix={<RowGapIcon />}suffix={<IconButton><ChevronDownIcon />@@ -77,25 +68,16 @@ export const PrefixSuffix: ComponentStory<typeof TextField> = () => {/><TextFieldstate="invalid"- prefix={<BrushIcon />}+ prefix={<RowGapIcon />}suffix={<IconButton><ChevronDownIcon /></IconButton>}/>- <TextField- size={2}- prefix={<BrushIcon />}- suffix={- <IconButton size={2}>- <ChevronDownIcon />- </IconButton>- }- /><TextFielddisabled- prefix={<BrushIcon />}+ prefix={<RowGapIcon />}suffix={<IconButton><ChevronDownIcon />@@ -112,7 +94,7 @@ export const Layout: ComponentStory<typeof TextField> = () => {<Flex direction="row" gap={2} css={{ justifyContent: "space-between" }}><TextFieldvalue="Long content comes here and it doesn't wrap"- prefix={<BrushIcon />}+ prefix={<RowGapIcon />}suffix={<IconButton><ChevronDownIcon />@@ -147,7 +129,7 @@ export const Layout: ComponentStory<typeof TextField> = () => {<TextFieldid="field"value="Long content comes here and it doesn't wrap"- prefix={<BrushIcon />}+ prefix={<RowGapIcon />}/></Box><Box css={{ background: "$muted" }}>@@ -222,7 +204,7 @@ export const ClickCapture: ComponentStory<typeof TextField> = (args) => {placeholder="Click on the icon to focus input"prefix={<Flex title="icon">- <BrushIcon />+ <RowGapIcon /></Flex>}suffix={diff --git a/packages/design-system/src/components/text-field.tsx b/packages/design-system/src/components/text-field.tsxindex aadbcba47f..d84988cee5 100644--- a/packages/design-system/src/components/text-field.tsx+++ b/packages/design-system/src/components/text-field.tsx@@ -12,6 +12,7 @@ const InputBase = styled("input", {boxSizing: "border-box",fontFamily: "inherit",fontSize: "inherit",+ color: "inherit",margin: "0",padding: "0",flexGrow: 1,@@ -69,9 +70,23 @@ const TextFieldBase = styled("div", {color: "$hiContrast",fontVariantNumeric: "tabular-nums",+ px: "$2",+ borderRadius: "$1",+ fontFamily: "$sans",+ fontSize: "$1",+ height: 28, // @todo waiting for the sizing scale+ lineHeight: 1,+ "&[data-has-prefix]": {+ paddingLeft: 2,+ },++ "&[data-has-suffix]": {+ paddingRight: 2,+ },+"&:focus-within": {boxShadow:- "inset 0px 0px 0px 1px $colors$blue8, 0px 0px 0px 1px $colors$blue8",+ "inset 0px 0px 0px 1px $colors$blue10, 0px 0px 0px 1px $colors$blue10",},"&[aria-disabled=true]": {@@ -86,22 +101,6 @@ const TextFieldBase = styled("div", {},variants: {- size: {- "1": {- px: "$1",- borderRadius: "$1",- fontSize: "$1",- height: "$5",- lineHeight: "$sizes$5",- },- "2": {- px: "$2",- borderRadius: "$2",- fontSize: "$3",- height: "$6",- lineHeight: "$sizes$6",- },- },variant: {ghost: {boxShadow: "none",@@ -114,7 +113,7 @@ const TextFieldBase = styled("div", {"&:focus": {backgroundColor: "$loContrast",boxShadow:- "inset 0px 0px 0px 1px $colors$blue8, 0px 0px 0px 1px $colors$blue8",+ "inset 0px 0px 0px 1px $colors$blue8, 0px 0px 0px 1px $colors$blue10",},"&:disabled": {backgroundColor: "transparent",@@ -141,14 +140,11 @@ const TextFieldBase = styled("div", {},},},- defaultVariants: {- size: "1",- },});type TextFieldProps = Pick<React.ComponentProps<typeof TextFieldBase>,- "size" | "variant" | "state" | "css"+ "variant" | "state" | "css"> &Omit<React.ComponentProps<"input">, "prefix" | "children"> & {inputRef?: React.Ref<HTMLInputElement>;@@ -164,7 +160,6 @@ export const TextField = React.forwardRef<HTMLDivElement, TextFieldProps>(css,disabled,inputRef,- size,state,variant,onFocus,@@ -194,11 +189,12 @@ export const TextField = React.forwardRef<HTMLDivElement, TextFieldProps>(<TextFieldBasearia-disabled={disabled}ref={forwardedRef}- size={size}state={state}variant={variant}css={css}{...focusWithinProps}+ {...(prefix && { "data-has-prefix": true })}+ {...(suffix && { "data-has-suffix": true })}onClickCapture={focusInnerInput}>{/* We want input to be the first element in DOM so it receives the focus first */}