From c753696d1a9a84be11072b58035febfd1bee215e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20Dziewo=C5=84ski?= Date: Fri, 6 Oct 2023 10:29:27 +0200 Subject: [PATCH] feat: add typography-hint-xs and typography-error-xs classes (#3006) --- .changeset/brave-foxes-confess.md | 5 +++++ .../.vuepress/components/TypographyList.vue | 2 ++ apps/preview/next/pages/examples/SfInput.tsx | 9 ++++++-- .../next/pages/examples/SfTextarea.tsx | 8 +++---- .../showcases/Checkbox/CheckboxLeading.tsx | 2 +- .../showcases/Checkbox/CheckboxTrailing.tsx | 2 +- .../Checkout/CheckoutAddressForm.tsx | 16 ++++++++------ .../showcases/Combobox/ComboboxBasic.tsx | 2 +- .../FormFields/FormFieldsRequired.tsx | 2 +- .../pages/showcases/Input/InputCharacters.tsx | 9 ++++++-- .../pages/showcases/Input/InputDisabled.tsx | 2 +- .../pages/showcases/Input/InputInvalid.tsx | 2 +- .../pages/showcases/Input/InputReadonly.tsx | 2 +- .../pages/showcases/Radio/RadioLeading.tsx | 4 ++-- .../pages/showcases/Radio/RadioTrailing.tsx | 4 ++-- .../pages/showcases/Switch/SwitchLeading.tsx | 2 +- .../pages/showcases/Switch/SwitchTrailing.tsx | 2 +- .../showcases/Textarea/TextareaAutoresize.tsx | 8 ++----- .../showcases/Textarea/TextareaCharacters.tsx | 6 +++--- .../showcases/Textarea/TextareaDisabled.tsx | 8 ++----- .../showcases/Textarea/TextareaInvalid.tsx | 8 +++---- .../showcases/Textarea/TextareaReadonly.tsx | 8 ++----- apps/preview/nuxt/pages/examples/SfInput.vue | 4 ++-- .../nuxt/pages/examples/SfTextarea.vue | 6 +++--- .../showcases/Checkbox/CheckboxLeading.vue | 2 +- .../showcases/Checkbox/CheckboxTrailing.vue | 2 +- .../Checkout/CheckoutAddressForm.vue | 16 +++++++------- .../showcases/Combobox/ComboboxBasic.vue | 2 +- .../FormFields/FormFieldsRequired.vue | 2 +- .../pages/showcases/Input/InputCharacters.vue | 4 ++-- .../pages/showcases/Input/InputDisabled.vue | 2 +- .../pages/showcases/Input/InputInvalid.vue | 2 +- .../pages/showcases/Input/InputReadonly.vue | 2 +- .../pages/showcases/Radio/RadioLeading.vue | 4 ++-- .../pages/showcases/Radio/RadioTrailing.vue | 4 ++-- .../pages/showcases/Switch/SwitchLeading.vue | 2 +- .../pages/showcases/Switch/SwitchTrailing.vue | 2 +- .../showcases/Textarea/TextareaAutoresize.vue | 9 +++----- .../showcases/Textarea/TextareaCharacters.vue | 6 +++--- .../showcases/Textarea/TextareaDisabled.vue | 9 +++----- .../showcases/Textarea/TextareaInvalid.vue | 9 ++++---- .../showcases/Textarea/TextareaReadonly.vue | 9 +++----- packages/sfui/typography/index.ts | 21 ++++++++++++------- 43 files changed, 118 insertions(+), 114 deletions(-) create mode 100644 .changeset/brave-foxes-confess.md diff --git a/.changeset/brave-foxes-confess.md b/.changeset/brave-foxes-confess.md new file mode 100644 index 0000000000..066f484115 --- /dev/null +++ b/.changeset/brave-foxes-confess.md @@ -0,0 +1,5 @@ +--- +'@storefront-ui/typography': minor +--- + +Add typography-hint-xs and typography-error-xs classes diff --git a/apps/docs/components/.vuepress/components/TypographyList.vue b/apps/docs/components/.vuepress/components/TypographyList.vue index faeed80162..75d7dd264f 100644 --- a/apps/docs/components/.vuepress/components/TypographyList.vue +++ b/apps/docs/components/.vuepress/components/TypographyList.vue @@ -44,9 +44,11 @@ const typographyClasses = [ ['error-lg', 'fontSize.lg', 'lineHeight.7'], ['error-base', 'fontSize.base', 'lineHeight.6'], ['error-sm', 'fontSize.sm', 'lineHeight.5'], + ['error-xs', 'fontSize.xs', 'lineHeight.4'], ['hint-lg', 'fontSize.lg', 'lineHeight.7'], ['hint-base', 'fontSize.base', 'lineHeight.6'], ['hint-sm', 'fontSize.sm', 'lineHeight.5'], + ['hint-xs', 'fontSize.xs', 'lineHeight.4'], ]; export default { diff --git a/apps/preview/next/pages/examples/SfInput.tsx b/apps/preview/next/pages/examples/SfInput.tsx index d644ad42ce..05bd29396c 100644 --- a/apps/preview/next/pages/examples/SfInput.tsx +++ b/apps/preview/next/pages/examples/SfInput.tsx @@ -172,7 +172,12 @@ function Example() {

{state.get.errorText}

)} {state.get.helpText && ( -

+

{state.get.helpText}

)} @@ -183,7 +188,7 @@ function Example() { {state.get.characterLimit && !state.get.readonly ? (

diff --git a/apps/preview/next/pages/examples/SfTextarea.tsx b/apps/preview/next/pages/examples/SfTextarea.tsx index e76d4cc65a..aa81fec574 100644 --- a/apps/preview/next/pages/examples/SfTextarea.tsx +++ b/apps/preview/next/pages/examples/SfTextarea.tsx @@ -109,7 +109,7 @@ function Example() { disabled={state.get.disabled} readOnly={state.get.readonly} onChange={onChange} - className={classNames('w-full', { + className={classNames('w-full block', { '!bg-disabled-100 !ring-disabled-300 !ring-1 !text-disabled-500': state.get.disabled, '!bg-disabled-100 !ring-disabled-300 !ring-1 !text-neutral-500': state.get.readonly, })} @@ -118,12 +118,12 @@ function Example() {

{state.get.invalid && !state.get.disabled && ( -

{state.get.errorText}

+

{state.get.errorText}

)} {state.get.helpText && (

@@ -139,7 +139,7 @@ function Example() { {state.get.characterLimit && !state.get.readonly ? (

diff --git a/apps/preview/next/pages/showcases/Checkbox/CheckboxLeading.tsx b/apps/preview/next/pages/showcases/Checkbox/CheckboxLeading.tsx index b5a12b2da6..fe8c0651f9 100644 --- a/apps/preview/next/pages/showcases/Checkbox/CheckboxLeading.tsx +++ b/apps/preview/next/pages/showcases/Checkbox/CheckboxLeading.tsx @@ -15,7 +15,7 @@ export default function CheckboxLeading() {

-

Help text

+

Help text

); diff --git a/apps/preview/next/pages/showcases/Checkbox/CheckboxTrailing.tsx b/apps/preview/next/pages/showcases/Checkbox/CheckboxTrailing.tsx index 319db965b6..674f4fe308 100644 --- a/apps/preview/next/pages/showcases/Checkbox/CheckboxTrailing.tsx +++ b/apps/preview/next/pages/showcases/Checkbox/CheckboxTrailing.tsx @@ -15,7 +15,7 @@ export default function CheckboxTrailing() {
-

Help text

+

Help text

); diff --git a/apps/preview/next/pages/showcases/Checkout/CheckoutAddressForm.tsx b/apps/preview/next/pages/showcases/Checkout/CheckoutAddressForm.tsx index b3df7c0ccb..55bdd35ed6 100644 --- a/apps/preview/next/pages/showcases/Checkout/CheckoutAddressForm.tsx +++ b/apps/preview/next/pages/showcases/Checkout/CheckoutAddressForm.tsx @@ -64,17 +64,19 @@ export default function AddressForm() { invalid={!streetIsValid} /> - {!streetIsValid && ( - Please provide a street name - )} - Street address or P.O. Box +
+ {!streetIsValid && ( + Please provide a street name + )} + Street address or P.O. Box +
- Optional + Optional
-

Help Text

+

Help Text

diff --git a/apps/preview/next/pages/showcases/Input/InputInvalid.tsx b/apps/preview/next/pages/showcases/Input/InputInvalid.tsx index 41c88a2863..61a9d0203e 100644 --- a/apps/preview/next/pages/showcases/Input/InputInvalid.tsx +++ b/apps/preview/next/pages/showcases/Input/InputInvalid.tsx @@ -13,7 +13,7 @@ export default function InvalidInput() {

Error

-

Help Text

+

Help Text

diff --git a/apps/preview/next/pages/showcases/Input/InputReadonly.tsx b/apps/preview/next/pages/showcases/Input/InputReadonly.tsx index 4e8d4e93af..b0e5b9cec7 100644 --- a/apps/preview/next/pages/showcases/Input/InputReadonly.tsx +++ b/apps/preview/next/pages/showcases/Input/InputReadonly.tsx @@ -12,7 +12,7 @@ export default function ReadonlyInput() {
-

Help Text

+

Help Text

diff --git a/apps/preview/next/pages/showcases/Radio/RadioLeading.tsx b/apps/preview/next/pages/showcases/Radio/RadioLeading.tsx index a80400ab7f..2e0956f5bd 100644 --- a/apps/preview/next/pages/showcases/Radio/RadioLeading.tsx +++ b/apps/preview/next/pages/showcases/Radio/RadioLeading.tsx @@ -36,8 +36,8 @@ export default function RadioAlignment() { ))} -
-

Help text

+
+

Help text

); diff --git a/apps/preview/next/pages/showcases/Radio/RadioTrailing.tsx b/apps/preview/next/pages/showcases/Radio/RadioTrailing.tsx index 5eaf13e307..2c6d17f5ce 100644 --- a/apps/preview/next/pages/showcases/Radio/RadioTrailing.tsx +++ b/apps/preview/next/pages/showcases/Radio/RadioTrailing.tsx @@ -34,8 +34,8 @@ export default function RadioWithLabelSmall() { ))}
-
-

Help text

+
+

Help text

); diff --git a/apps/preview/next/pages/showcases/Switch/SwitchLeading.tsx b/apps/preview/next/pages/showcases/Switch/SwitchLeading.tsx index fdb3f890c3..dc8009533b 100644 --- a/apps/preview/next/pages/showcases/Switch/SwitchLeading.tsx +++ b/apps/preview/next/pages/showcases/Switch/SwitchLeading.tsx @@ -18,7 +18,7 @@ export default function SwitchAlignment() { /> Label - Help text + Help text ); } diff --git a/apps/preview/next/pages/showcases/Switch/SwitchTrailing.tsx b/apps/preview/next/pages/showcases/Switch/SwitchTrailing.tsx index ecf6cfde4f..1362ab4d25 100644 --- a/apps/preview/next/pages/showcases/Switch/SwitchTrailing.tsx +++ b/apps/preview/next/pages/showcases/Switch/SwitchTrailing.tsx @@ -18,7 +18,7 @@ export default function SwitchAlignment() { }} /> - Help text + Help text ); } diff --git a/apps/preview/next/pages/showcases/Textarea/TextareaAutoresize.tsx b/apps/preview/next/pages/showcases/Textarea/TextareaAutoresize.tsx index 7f1b8705ca..18a99bdfc3 100644 --- a/apps/preview/next/pages/showcases/Textarea/TextareaAutoresize.tsx +++ b/apps/preview/next/pages/showcases/Textarea/TextareaAutoresize.tsx @@ -17,13 +17,9 @@ export default function TextareaAutoresize() { <> -
-
-

Do not include personal or financial information.

-
-
+

Do not include personal or financial information.

); } diff --git a/apps/preview/next/pages/showcases/Textarea/TextareaCharacters.tsx b/apps/preview/next/pages/showcases/Textarea/TextareaCharacters.tsx index 3942a01dc6..a644cb8f9a 100644 --- a/apps/preview/next/pages/showcases/Textarea/TextareaCharacters.tsx +++ b/apps/preview/next/pages/showcases/Textarea/TextareaCharacters.tsx @@ -33,7 +33,7 @@ export default function TextareaWithLimit() { invalid={invalid} disabled={disabled} onChange={onChange} - className="w-full mt-0.5" + className="w-full mt-0.5 block" />
@@ -42,13 +42,13 @@ export default function TextareaWithLimit() {

{errorText}

)} {helpText && ( -

+

{helpText}

)}
{characterLimit && !readonly ? ( -

+

{charsCount}

) : null} diff --git a/apps/preview/next/pages/showcases/Textarea/TextareaDisabled.tsx b/apps/preview/next/pages/showcases/Textarea/TextareaDisabled.tsx index 22ed6a9e35..a847f01fcd 100644 --- a/apps/preview/next/pages/showcases/Textarea/TextareaDisabled.tsx +++ b/apps/preview/next/pages/showcases/Textarea/TextareaDisabled.tsx @@ -11,14 +11,10 @@ export default function DisabledTextareaDemo() { -
-
-

Do not include personal or financial information.

-
-
+

Do not include personal or financial information.

); } diff --git a/apps/preview/next/pages/showcases/Textarea/TextareaInvalid.tsx b/apps/preview/next/pages/showcases/Textarea/TextareaInvalid.tsx index 7b0ce5816c..4ff374a9ea 100644 --- a/apps/preview/next/pages/showcases/Textarea/TextareaInvalid.tsx +++ b/apps/preview/next/pages/showcases/Textarea/TextareaInvalid.tsx @@ -8,13 +8,11 @@ export default function InvalidTextarea() { <>
-
-

The field cannot be empty

-

Do not include personal or financial information.

-
+

The field cannot be empty

+

Do not include personal or financial information.

); diff --git a/apps/preview/next/pages/showcases/Textarea/TextareaReadonly.tsx b/apps/preview/next/pages/showcases/Textarea/TextareaReadonly.tsx index 61e8e03651..288e8815a9 100644 --- a/apps/preview/next/pages/showcases/Textarea/TextareaReadonly.tsx +++ b/apps/preview/next/pages/showcases/Textarea/TextareaReadonly.tsx @@ -10,15 +10,11 @@ export default function ReadonlyTextarea() { Description -
-
-

Do not include personal or financial information.

-
-
+

Do not include personal or financial information.

); } diff --git a/apps/preview/nuxt/pages/examples/SfInput.vue b/apps/preview/nuxt/pages/examples/SfInput.vue index d4a33e87b9..445e94f114 100644 --- a/apps/preview/nuxt/pages/examples/SfInput.vue +++ b/apps/preview/nuxt/pages/examples/SfInput.vue @@ -22,7 +22,7 @@

{{ errorText }}

-

+

{{ helpText }}

@@ -31,7 +31,7 @@

{{ charsCount }}

diff --git a/apps/preview/nuxt/pages/examples/SfTextarea.vue b/apps/preview/nuxt/pages/examples/SfTextarea.vue index af5462eb87..7c81a13f23 100644 --- a/apps/preview/nuxt/pages/examples/SfTextarea.vue +++ b/apps/preview/nuxt/pages/examples/SfTextarea.vue @@ -15,7 +15,7 @@ v-bind="state" v-model="value" :class="[ - 'w-full', + 'w-full block', { '!bg-disabled-100 !ring-disabled-300 !ring-1 !text-disabled-500': disabled, '!bg-disabled-100 !ring-disabled-300 !ring-1 !text-neutral-500': readonly, @@ -28,7 +28,7 @@

{{ errorText }}

-

+

{{ helpText }}

{{ charsCount }}

diff --git a/apps/preview/nuxt/pages/showcases/Checkbox/CheckboxLeading.vue b/apps/preview/nuxt/pages/showcases/Checkbox/CheckboxLeading.vue index baf0fd145f..93445b0f9c 100644 --- a/apps/preview/nuxt/pages/showcases/Checkbox/CheckboxLeading.vue +++ b/apps/preview/nuxt/pages/showcases/Checkbox/CheckboxLeading.vue @@ -6,7 +6,7 @@
-

Help text

+

Help text

diff --git a/apps/preview/nuxt/pages/showcases/Textarea/TextareaInvalid.vue b/apps/preview/nuxt/pages/showcases/Textarea/TextareaInvalid.vue index 2e63e29efe..7e69d9f23a 100644 --- a/apps/preview/nuxt/pages/showcases/Textarea/TextareaInvalid.vue +++ b/apps/preview/nuxt/pages/showcases/Textarea/TextareaInvalid.vue @@ -1,15 +1,14 @@ + diff --git a/apps/preview/nuxt/pages/showcases/Textarea/TextareaReadonly.vue b/apps/preview/nuxt/pages/showcases/Textarea/TextareaReadonly.vue index 46ef5b9918..560ad47990 100644 --- a/apps/preview/nuxt/pages/showcases/Textarea/TextareaReadonly.vue +++ b/apps/preview/nuxt/pages/showcases/Textarea/TextareaReadonly.vue @@ -3,16 +3,13 @@ Description -
-
-

Do not include personal or financial information.

-
-
+

Do not include personal or financial information.

+ diff --git a/packages/sfui/typography/index.ts b/packages/sfui/typography/index.ts index d6784de3de..c6f34f7daf 100644 --- a/packages/sfui/typography/index.ts +++ b/packages/sfui/typography/index.ts @@ -70,17 +70,22 @@ export default plugin.withOptions( ['error-lg', 'fontSize.lg', 'lineHeight.7'], ['error-base', 'fontSize.base', 'lineHeight.6'], ['error-sm', 'fontSize.sm', 'lineHeight.5'], + ['error-xs', 'fontSize.xs', 'lineHeight.4'], ['hint-lg', 'fontSize.lg', 'lineHeight.7'], ['hint-base', 'fontSize.base', 'lineHeight.6'], ['hint-sm', 'fontSize.sm', 'lineHeight.5'], - ].reduce((p, [name, fontSize, lineHeight, fontFamily]) => { - p[name] = { - fontSize: theme(fontSize), - lineHeight: theme(lineHeight), - fontFamily: fontFamily ? theme(fontFamily) : undefined, - }; - return p; - }, {} as Record), + ['hint-xs', 'fontSize.xs', 'lineHeight.4'], + ].reduce( + (p, [name, fontSize, lineHeight, fontFamily]) => { + p[name] = { + fontSize: theme(fontSize), + lineHeight: theme(lineHeight), + fontFamily: fontFamily ? theme(fontFamily) : undefined, + }; + return p; + }, + {} as Record, + ), } as { [PLUGIN_CONFIG_KEY]: ResolvableTo }, }), );