Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/small-size-caption-text.md
Original file line number Diff line number Diff line change
@@ -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
20 changes: 12 additions & 8 deletions packages/reshaped/src/components/Button/Button.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down
11 changes: 7 additions & 4 deletions packages/reshaped/src/components/MenuItem/MenuItem.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ const PinFieldControlled: React.FC<T.ControlledProps> = (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"
);
Expand Down
14 changes: 9 additions & 5 deletions packages/reshaped/src/components/Select/Select.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion packages/reshaped/src/components/Tabs/Tabs.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion packages/reshaped/src/components/Tabs/TabsItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const TabsItem = React.forwardRef<ActionableRef, T.ItemProps>((props, ref) => {
{icon && <Icon svg={icon} className={s.icon} size={4} />}
{children && (
<Text
variant={size === "large" ? "body-1" : "body-2"}
variant={size === "large" ? "body-1" : size === "small" ? "caption-1" : "body-2"}
weight="medium"
className={s.buttonText}
>
Expand Down
16 changes: 11 additions & 5 deletions packages/reshaped/src/components/TextField/TextField.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down