diff --git a/.changeset/small-size-caption-text.md b/.changeset/small-size-caption-text.md new file mode 100644 index 00000000..ce5303f3 --- /dev/null +++ b/.changeset/small-size-caption-text.md @@ -0,0 +1,5 @@ +--- +"reshaped": patch +--- + +Button, MenuItem, Tabs, TextField, Select and PinField: Small size now renders caption-1 text, their vertical padding grows by the line height difference so the component size stays the same diff --git a/packages/reshaped/src/components/Button/Button.module.css b/packages/reshaped/src/components/Button/Button.module.css index f5b32e89..f0fca2c5 100644 --- a/packages/reshaped/src/components/Button/Button.module.css +++ b/packages/reshaped/src/components/Button/Button.module.css @@ -6,6 +6,7 @@ /* Using --rs-button-p and --rs-p to dynamically reassign --rs-p for all sizes of ghost buttons, used by Aligner */ --rs-p-v: var(--rs-button-p-v); --rs-p-h: var(--rs-button-p-h); + --rs-button-min-size: calc(var(--rs-button-line-height) + var(--rs-button-p-v) * 2); transition: var(--rs-duration-fast) var(--rs-easing-standard); transition-property: background-color, box-shadow, border-color, color, transform, opacity; @@ -29,10 +30,10 @@ line-height: var(--rs-button-line-height); letter-spacing: var(--rs-button-letter-spacing); box-sizing: border-box; - min-height: calc(var(--rs-button-line-height) + var(--rs-p-v) * 2); - min-width: calc( - var(--rs-button-line-height) - (var(--rs-unit-x1) * 2) + (var(--rs-button-p-h) * 2) - ); + + /* Keeps icon-only buttons square by using the same value for both dimensions */ + min-height: var(--rs-button-min-size); + min-width: var(--rs-button-min-size); background-color: var(--rs-button-background-color); color: var(--rs-button-color); isolation: isolate; @@ -142,13 +143,16 @@ @responsive .--size { @value small { - --rs-button-p-v: var(--rs-unit-x1); + /* Padding absorbs the caption-1 line height difference to keep the size it had with body-2 text */ + --rs-button-p-v: calc( + var(--rs-unit-x1) + (var(--rs-line-height-body-2) - var(--rs-line-height-caption-1)) / 2 + ); --rs-button-p-h: var(--rs-unit-x2); --rs-button-gap: var(--rs-unit-x1-5); --rs-button-icon-align: var(--rs-unit-x0-5); - --rs-button-line-height: var(--rs-line-height-body-2); - --rs-button-font-size: var(--rs-font-size-body-2); - --rs-button-letter-spacing: var(--rs-letter-spacing-body-2); + --rs-button-line-height: var(--rs-line-height-caption-1); + --rs-button-font-size: var(--rs-font-size-caption-1); + --rs-button-letter-spacing: var(--rs-letter-spacing-caption-1); --rs-button-radius: var(--rs-radius-small); } diff --git a/packages/reshaped/src/components/MenuItem/MenuItem.module.css b/packages/reshaped/src/components/MenuItem/MenuItem.module.css index 4179533a..2e000d2c 100644 --- a/packages/reshaped/src/components/MenuItem/MenuItem.module.css +++ b/packages/reshaped/src/components/MenuItem/MenuItem.module.css @@ -32,13 +32,16 @@ button.root { @responsive .--size { @value small { - --rs-p-v: var(--rs-unit-x1); + /* Padding absorbs the caption-1 line height difference to keep the size it had with body-2 text */ + --rs-p-v: calc( + var(--rs-unit-x1) + (var(--rs-line-height-body-2) - var(--rs-line-height-caption-1)) / 2 + ); --rs-p-h: var(--rs-unit-x1-5); --rs-menu-item-radius: var(--rs-radius-small); - font-size: var(--rs-font-size-body-2); - line-height: var(--rs-line-height-body-2); - letter-spacing: var(--rs-letter-spacing-body-2); + font-size: var(--rs-font-size-caption-1); + line-height: var(--rs-line-height-caption-1); + letter-spacing: var(--rs-letter-spacing-caption-1); } @value medium { diff --git a/packages/reshaped/src/components/PinField/PinFieldControlled.tsx b/packages/reshaped/src/components/PinField/PinFieldControlled.tsx index b8e315bf..a5861b20 100644 --- a/packages/reshaped/src/components/PinField/PinFieldControlled.tsx +++ b/packages/reshaped/src/components/PinField/PinFieldControlled.tsx @@ -45,9 +45,11 @@ const PinFieldControlled: React.FC = (props) => { } = props; const patternRegexp = patternMap[pattern]; const responsiveInputSize = responsivePropDependency(size, (value) => sizeMap[value]); - const responsiveTextVariant = responsivePropDependency(size, (value) => - value === "medium" ? "body-2" : "body-1" - ); + const responsiveTextVariant = responsivePropDependency(size, (value) => { + if (value === "small") return "caption-1"; + if (value === "medium") return "body-2"; + return "body-1"; + }); const responsiveRadius = responsivePropDependency(size, (value) => value === "small" ? "small" : "medium" ); diff --git a/packages/reshaped/src/components/Select/Select.module.css b/packages/reshaped/src/components/Select/Select.module.css index e5c0e799..0750f7c9 100644 --- a/packages/reshaped/src/components/Select/Select.module.css +++ b/packages/reshaped/src/components/Select/Select.module.css @@ -107,13 +107,17 @@ --rs-select-gap: var(--rs-unit-x1-5); --rs-select-chevron-size: var(--rs-unit-x4); --rs-select-radius: var(--rs-radius-small); - --rs-select-p-v: var(--rs-unit-x1); + + /* Padding absorbs the caption-1 line height difference to keep the size it had with body-2 text */ + --rs-select-p-v: calc( + var(--rs-unit-x1) + (var(--rs-line-height-body-2) - var(--rs-line-height-caption-1)) / 2 + ); --rs-select-p-h: var(--rs-unit-x2); - --rs-select-font-size: var(--rs-font-size-body-2); - --rs-select-line-height: var(--rs-line-height-body-2); - --rs-select-letter-spacing: var(--rs-letter-spacing-body-2); + --rs-select-font-size: var(--rs-font-size-caption-1); + --rs-select-line-height: var(--rs-line-height-caption-1); + --rs-select-letter-spacing: var(--rs-letter-spacing-caption-1); --rs-select-icon-align: var(--rs-unit-x0-5); - --rs-select-min-height: calc(var(--rs-select-line-height) + var(--rs-unit-x1) * 2); + --rs-select-min-height: calc(var(--rs-select-line-height) + var(--rs-select-p-v) * 2); } @value medium { diff --git a/packages/reshaped/src/components/Tabs/Tabs.module.css b/packages/reshaped/src/components/Tabs/Tabs.module.css index dd34dd31..41eacb7c 100644 --- a/packages/reshaped/src/components/Tabs/Tabs.module.css +++ b/packages/reshaped/src/components/Tabs/Tabs.module.css @@ -355,7 +355,10 @@ } .--size-small { - --rs-tabs-item-p-v: var(--rs-unit-x1); + /* Padding absorbs the caption-1 line height difference to keep the size it had with body-2 text */ + --rs-tabs-item-p-v: calc( + var(--rs-unit-x1) + (var(--rs-line-height-body-2) - var(--rs-line-height-caption-1)) / 2 + ); --rs-tabs-item-p-h: var(--rs-unit-x2); --rs-tabs-icon-gap: var(--rs-unit-x1-5); --rs-tabs-radius: var(--rs-radius-small); diff --git a/packages/reshaped/src/components/Tabs/TabsItem.tsx b/packages/reshaped/src/components/Tabs/TabsItem.tsx index 72f61986..cbf2680d 100644 --- a/packages/reshaped/src/components/Tabs/TabsItem.tsx +++ b/packages/reshaped/src/components/Tabs/TabsItem.tsx @@ -87,7 +87,7 @@ const TabsItem = React.forwardRef((props, ref) => { {icon && } {children && ( diff --git a/packages/reshaped/src/components/TextField/TextField.module.css b/packages/reshaped/src/components/TextField/TextField.module.css index 9eaf210b..181675b9 100644 --- a/packages/reshaped/src/components/TextField/TextField.module.css +++ b/packages/reshaped/src/components/TextField/TextField.module.css @@ -194,14 +194,20 @@ @value small { --rs-text-field-gap: var(--rs-unit-x1-5); --rs-text-field-radius: var(--rs-radius-small); - --rs-text-field-p-v: var(--rs-unit-x1); + + /* Padding absorbs the caption-1 line height difference to keep the size it had with body-2 text */ + --rs-text-field-p-v: calc( + var(--rs-unit-x1) + (var(--rs-line-height-body-2) - var(--rs-line-height-caption-1)) / 2 + ); --rs-text-field-p-h: var(--rs-unit-x2); --rs-text-field-icon-align: var(--rs-unit-x0-5); - --rs-text-field-font-size: var(--rs-font-size-body-2); - --rs-text-field-line-height: var(--rs-line-height-body-2); - --rs-text-field-letter-spacing: var(--rs-letter-spacing-body-2); + --rs-text-field-font-size: var(--rs-font-size-caption-1); + --rs-text-field-line-height: var(--rs-line-height-caption-1); + --rs-text-field-letter-spacing: var(--rs-letter-spacing-caption-1); --rs-text-field-action-inset: var(--rs-unit-x1); - --rs-text-field-min-height: calc(var(--rs-text-field-line-height) + var(--rs-unit-x1) * 2); + --rs-text-field-min-height: calc( + var(--rs-text-field-line-height) + var(--rs-text-field-p-v) * 2 + ); } @value medium {