Skip to content

Commit 48c9651

Browse files
authored
Merge pull request #24 from maxholman/fixes20240726-canary
Fixes20240726 canary
2 parents e1eddfe + 041ea6a commit 48c9651

21 files changed

Lines changed: 851 additions & 1103 deletions

lib/badges.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,13 @@ export const Badge = forwardRef(
2222
component="span"
2323
padding="2"
2424
paddingInline="3"
25+
fontSize="0"
26+
fontWeight="medium"
2527
className={[className, variant && badgePurposeClassNames[variant]]}
2628
{...props}
2729
>
2830
{isStringLike(children) ? (
29-
<Box
30-
component="span"
31-
fontSize="0"
32-
fontWeight="medium"
33-
textOverflow="ellipsis"
34-
textAlign="center"
35-
>
31+
<Box component="span" textOverflow="ellipsis" textAlign="center">
3632
{children}
3733
</Box>
3834
) : (

lib/box.css.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,20 @@ export const textOverflowVariants = styleVariants(
259259
(value) => [textOverflowBase, value],
260260
);
261261

262+
export type TextWrap = 'pretty' | 'balance' | 'nowrap';
263+
264+
export const textWrapVariants = styleVariants({
265+
balance: {
266+
textWrap: 'balance',
267+
},
268+
pretty: {
269+
textWrap: 'pretty',
270+
},
271+
nowrap: {
272+
textWrap: 'nowrap',
273+
},
274+
} satisfies Record<TextWrap, StyleRule>);
275+
262276
export type FlexDirection = 'row' | 'column';
263277

264278
export const flexDirectionVariants = styleVariants(

lib/box.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import {
3939
flexShrinkClass,
4040
flexWrapVariants,
4141
type Wrap,
42+
textWrapVariants,
43+
type TextWrap,
4244
} from './box.css.js';
4345
import { isNotFalsy, matchViewportVariants } from './component-utils.js';
4446
import { TooltipLazy } from './tooltip-lazy.js';
@@ -57,7 +59,6 @@ import {
5759
type FontSize,
5860
type FontWeight,
5961
type LineHeight,
60-
type TextWrap,
6162
} from './typography.css.js';
6263

6364
export type BoxProps<T extends keyof ReactHTMLElementsHacked = 'div'> = Merge<
@@ -85,12 +86,12 @@ export type BoxProps<T extends keyof ReactHTMLElementsHacked = 'div'> = Merge<
8586

8687
textAlign?: TextAlign | Falsy;
8788
textOverflow?: TextOverflow | Falsy;
89+
textWrap?: TextWrap | Falsy;
8890

8991
fontSize?: FontSize | Falsy;
9092
capSize?: FontSize | Falsy;
9193
fontWeight?: FontWeight | Falsy;
9294
lineHeight?: LineHeight | Falsy;
93-
textWrap?: TextWrap | Falsy;
9495

9596
overflow?: Overflow | Falsy;
9697

@@ -256,6 +257,7 @@ export const Box = forwardRef(
256257
),
257258

258259
textAlign && textAlignVariants[textAlign],
260+
textWrap && textWrapVariants[textWrap],
259261

260262
isNotFalsy(rounded) && roundedVariants[rounded],
261263

lib/button.css.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ export const buttonClassName = style([
7979
userSelect: 'none',
8080
borderRadius: baseVars.border.radius,
8181
borderWidth: baseVars.border.width,
82+
transitionProperty: 'background-color, color, border-color',
83+
transitionDuration: '0.08s',
84+
transitionTimingFunction: 'ease-in-out',
8285
selectors: {
8386
'&[disabled]': {
8487
pointerEvents: 'none',
@@ -118,14 +121,18 @@ export const iconClassName = style({
118121
width: '0.7em', // hack, this should be variable based on the font-size
119122
});
120123

121-
export const visiblyHiddenClass = style({
122-
visibility: 'hidden',
123-
});
124-
125124
export const busyButtonClass = style({
126125
pointerEvents: 'none',
127126
});
128127

128+
export const busySpinnerClass = style({
129+
position: 'absolute',
130+
});
131+
129132
export const inlineBleedClass = style({
130133
marginBlock: calc(propsVars.space[0]).negate().toString(),
131134
});
135+
136+
export const visiblyHiddenClass = style({
137+
visibility: 'hidden',
138+
});

lib/button.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('Button', () => {
1616
// ASSERT
1717
expect(screen.getByRole('button')).toMatchInlineSnapshot(`
1818
<button
19-
class="button_buttonVariantClassNames_default__1sytq441 button_buttonClassName__1sytq44p layout_alignItemsVariants_center__17vpgba1 layout_justifyContentVariants_center__17vpgbad box_viewportStyleVariants_2__fg8qdbmn box_flexWrapVariants_nowrap__fg8qdbm0 box_viewportStyleVariants_5__fg8qdben box_viewportStyleVariants_6__fg8qdbc1 box_flexDirectionVariants_row__fg8qdblt"
19+
class="button_buttonVariantClassNames_default__1sytq441 button_buttonClassName__1sytq44p layout_alignItemsVariants_center__17vpgba1 layout_justifyContentVariants_center__17vpgbad box_viewportStyleVariants_2__fg8qdbmq box_flexWrapVariants_nowrap__fg8qdbm3 box_viewportStyleVariants_5__fg8qdben box_viewportStyleVariants_6__fg8qdbc1 box_flexDirectionVariants_row__fg8qdblw"
2020
type="button"
2121
>
2222
<span

lib/button.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
iconClassName,
1616
inlineBleedClass,
1717
visiblyHiddenClass,
18+
busySpinnerClass,
1819
} from './button.css.js';
1920
import { differentOriginLinkProps } from './component-utils.js';
2021
import { useStringLikeDetector } from './hooks/use-string-like.js';
@@ -68,17 +69,13 @@ export type ButtonIconProps<
6869
}
6970
>;
7071

71-
/** @private */
72-
const IconBox: FC<{
73-
icon: ReactElement | FC;
74-
busy?: boolean | Falsy;
75-
capSize?: FontSize;
76-
}> = ({ icon, busy, ...props }) => (
77-
<Box
78-
{...props}
79-
component="span"
80-
className={[iconClassName, busy && visiblyHiddenClass]}
81-
>
72+
const IconBox: FC<
73+
BoxProps<'span'> & {
74+
icon: ReactElement | FC;
75+
capSize?: FontSize;
76+
}
77+
> = ({ icon, className, ...props }) => (
78+
<Box {...props} component="span" className={[className, iconClassName]}>
8279
{isValidElement<ReactElementDefaultPropsType>(icon)
8380
? icon
8481
: icon({} /* { className: iconClassName } */)}
@@ -199,10 +196,10 @@ export const Button = forwardRef(
199196
]}
200197
>
201198
{iconStart && (
202-
<IconBox capSize={fontSize} busy={busy} icon={iconStart} />
199+
<IconBox capSize={fontSize} icon={iconStart} {...busyAttributes} />
203200
)}
204201

205-
{!busy && hasStringChildren && (
202+
{hasStringChildren && (
206203
<ExactText
207204
component="span"
208205
textAlign={textAlign}
@@ -213,15 +210,17 @@ export const Button = forwardRef(
213210
</ExactText>
214211
)}
215212

216-
{!busy && children && !hasStringChildren && (
213+
{!hasStringChildren && children && (
217214
<Box flexGrow component="span" {...busyAttributes}>
218215
{children}
219216
</Box>
220217
)}
221218

222-
{busy && <Spinner capSize={fontSize} />}
219+
{busy && <Spinner className={busySpinnerClass} capSize={fontSize} />}
223220

224-
{iconEnd && <IconBox capSize={fontSize} busy={busy} icon={iconEnd} />}
221+
{iconEnd && (
222+
<IconBox capSize={fontSize} icon={iconEnd} {...busyAttributes} />
223+
)}
225224
</UnstyledButton>
226225
);
227226
},

lib/callout.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ import {
1414
PositiveIcon,
1515
} from './icons.js';
1616
import type { PurposeVariant } from './purpose.css.js';
17-
import type { Merge, ReactHTMLElementsHacked } from './types.js';
17+
import type { Falsy, Merge, ReactHTMLElementsHacked } from './types.js';
1818
import { ExactText } from './typography.js';
1919
import { isValidElementOfType } from './utils.js';
2020

2121
export type { PurposeVariant as CalloutVariant };
2222

23-
function variantIcon(variant: PurposeVariant): ReactNode {
23+
function variantIcon(variant: PurposeVariant | Falsy): ReactNode {
2424
const props = { className: iconClassName };
2525

2626
switch (variant) {
@@ -41,7 +41,7 @@ export type CalloutCommonProps = {
4141
align?: never;
4242
children: ReactNode;
4343
icon?: ReactNode;
44-
variant?: PurposeVariant;
44+
variant?: PurposeVariant | Falsy;
4545
};
4646

4747
export type CalloutProps<T extends keyof ReactHTMLElementsHacked = 'div'> =
@@ -70,7 +70,7 @@ export const Callout = ({
7070
return (
7171
<Box
7272
space={space}
73-
className={[className, calloutStyleVariants[variant]]}
73+
className={[className, variant && calloutStyleVariants[variant]]}
7474
role="alert"
7575
aria-live="polite"
7676
{...props}

lib/forms.css.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ export const formInputOuterClassName = style({
7474
export const formInputInnerClassName = style([
7575
{
7676
selectors: {
77-
'&::placeholder': {},
77+
'&::placeholder': {
78+
color: baseVars.color.muted.fgColor,
79+
},
7880
},
7981
},
8082
]);

lib/forms.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ export const FormInput = forwardRef<HTMLInputElement, FormInputProps>(
133133
message,
134134
autoFocus,
135135
customValidity,
136+
flexGrow,
137+
hidden,
136138
...props
137139
},
138140
forwardedRef,
@@ -146,7 +148,12 @@ export const FormInput = forwardRef<HTMLInputElement, FormInputProps>(
146148
const ref = useCombinedRefs(forwardedRef, ourRef);
147149

148150
return (
149-
<Block className={className} space={defaultFormInputSpace}>
151+
<Block
152+
flexGrow={flexGrow}
153+
className={className}
154+
space={defaultFormInputSpace}
155+
hidden={hidden}
156+
>
150157
{label && (
151158
<FormInputLabel
152159
htmlFor={!inputTypeProps.readOnly ? id : undefined}
@@ -169,6 +176,7 @@ export const FormInput = forwardRef<HTMLInputElement, FormInputProps>(
169176
{...inputTypeProps}
170177
autoFocus={definitelyAutoFocus}
171178
id={id}
179+
flexGrow={flexGrow}
172180
/>
173181
{message && <FormInputMessage message={message} />}
174182
</Block>

lib/loaders.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export type SpinnerProps = Merge<
2222
>;
2323

2424
export const Spinner: FC<SpinnerProps> = ({
25-
size = '1',
25+
size,
2626
className,
2727
inline = true,
2828
delay = false,
@@ -39,7 +39,7 @@ export const Spinner: FC<SpinnerProps> = ({
3939
? spinnerAnimationVariantClassNames.delay
4040
: spinnerAnimationVariantClassNames.normal,
4141
inline && inlineSpinnerClass,
42-
!inline && spinnerSizeVariantClassNames[size],
42+
size && spinnerSizeVariantClassNames[size],
4343
]}
4444
{...props}
4545
>

0 commit comments

Comments
 (0)