From dbc8fd7d31315d1cc982593abf6ef2acaa0a4282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cnora?= Date: Mon, 18 Sep 2023 14:08:20 -0400 Subject: [PATCH] chore(meter, slider): fix spacing of min and max labels --- .changeset/famous-paws-marry.md | 6 ++++ .changeset/forty-carrots-reply.md | 6 ++++ .../paste-core/components/meter/src/Meter.tsx | 10 ++++++- .../meter/stories/index.stories.tsx | 10 ++++++- .../components/slider/src/Slider.tsx | 4 ++- .../slider/stories/index.stories.tsx | 28 +++++++++++++++++++ 6 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 .changeset/famous-paws-marry.md create mode 100644 .changeset/forty-carrots-reply.md diff --git a/.changeset/famous-paws-marry.md b/.changeset/famous-paws-marry.md new file mode 100644 index 0000000000..9879c18233 --- /dev/null +++ b/.changeset/famous-paws-marry.md @@ -0,0 +1,6 @@ +--- +'@twilio-paste/slider': patch +'@twilio-paste/core': patch +--- + +[Slider] Add spacing between min and max range labels, wrap overflow content onto second line, and right-align max range label. diff --git a/.changeset/forty-carrots-reply.md b/.changeset/forty-carrots-reply.md new file mode 100644 index 0000000000..3a2d88ff0b --- /dev/null +++ b/.changeset/forty-carrots-reply.md @@ -0,0 +1,6 @@ +--- +'@twilio-paste/meter': patch +'@twilio-paste/core': patch +--- + +[Meter] Add spacing between the min and max labels for readability, right-align the max label, and make overflow min/max labels wrap to second line. diff --git a/packages/paste-core/components/meter/src/Meter.tsx b/packages/paste-core/components/meter/src/Meter.tsx index 348f6b3a36..8b28d2b64e 100644 --- a/packages/paste-core/components/meter/src/Meter.tsx +++ b/packages/paste-core/components/meter/src/Meter.tsx @@ -72,8 +72,10 @@ const Meter = React.forwardRef( display="flex" flexDirection="row" justifyContent="space-between" + columnGap="space20" marginTop="space20" aria-hidden="true" + overflowWrap="anywhere" element={`${element}_MIN_MAX_WRAPPER`} > {minLabel ? ( @@ -84,7 +86,13 @@ const Meter = React.forwardRef( )} {maxLabel ? ( - + {maxLabel} ) : ( diff --git a/packages/paste-core/components/meter/stories/index.stories.tsx b/packages/paste-core/components/meter/stories/index.stories.tsx index ca1d60e9db..42dd1fab7e 100644 --- a/packages/paste-core/components/meter/stories/index.stories.tsx +++ b/packages/paste-core/components/meter/stories/index.stories.tsx @@ -135,7 +135,15 @@ export const Wrapped = (): React.ReactElement => { Storage space used on this account that belongs to you - + Helpful text ); diff --git a/packages/paste-core/components/slider/src/Slider.tsx b/packages/paste-core/components/slider/src/Slider.tsx index c2ce1342c5..726037b6ca 100644 --- a/packages/paste-core/components/slider/src/Slider.tsx +++ b/packages/paste-core/components/slider/src/Slider.tsx @@ -135,16 +135,18 @@ export const Slider = React.forwardRef((props, ref) element={`${element}_RANGE_LABELS`} display="flex" justifyContent="space-between" + columnGap="space20" fontSize="fontSize30" lineHeight="lineHeight30" fontWeight="fontWeightNormal" color="colorTextWeak" + overflowWrap="anywhere" > {i18nMinRangeLabel} {remappedProps.numberFormatter.format(minValue)} - + {i18nMaxRangeLabel} {remappedProps.numberFormatter.format(maxValue)} diff --git a/packages/paste-core/components/slider/stories/index.stories.tsx b/packages/paste-core/components/slider/stories/index.stories.tsx index 7da09caf87..3ac80ccf4b 100644 --- a/packages/paste-core/components/slider/stories/index.stories.tsx +++ b/packages/paste-core/components/slider/stories/index.stories.tsx @@ -175,6 +175,34 @@ export const HiddenRangeLabels = (): React.ReactNode => { ); }; +export const Wrapped = (): React.ReactNode => { + const [value, setValue] = React.useState(0.75); + const sliderId = useUID(); + const helpTextId = useUID(); + + return ( +
+ + + setValue(newValue)} + numberFormatter={PercentFormatter} + /> + + I saw an ad yesterday that said “Radio for sale $1, volume is stuck on full blast”. I said to myself “well, I + can’t turn that down.” + + +
+ ); +}; + export const CustomizedSlider = (): React.ReactNode => { const activeTheme = useTheme(); const [value, setValue] = React.useState(32);