Skip to content
Open
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
2 changes: 2 additions & 0 deletions .changeset/migrate-mosaic-input-to-stylex.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
20 changes: 16 additions & 4 deletions packages/swingset/src/stories/input.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/** @jsxImportSource @emotion/react */
import type { InputProps } from '@clerk/ui/mosaic/components/input';
import { Input, inputRecipe } from '@clerk/ui/mosaic/components/input';
import { Input } from '@clerk/ui/mosaic/components/input';

import type { StoryMeta } from '@/lib/types';

Expand All @@ -11,8 +10,16 @@ export { default as __source } from './input.stories?raw';
export const meta: StoryMeta = {
group: 'Components',
title: 'Input',
source: 'packages/ui/src/mosaic/components/input.tsx',
styles: inputRecipe,
source: 'packages/ui/src/mosaic/components/input/input.tsx',
styleEngine: 'stylex',
styles: {
_variants: {
size: { sm: {}, md: {}, lg: {} },
},
_defaultVariants: {
size: 'md',
},
},
};

function knobsAsProps(props: Record<string, unknown>) {
Expand Down Expand Up @@ -41,6 +48,11 @@ export function Sizes(props: Record<string, unknown>) {
size='md'
placeholder='Medium'
/>
<Input
{...knobsAsProps(props)}
size='lg'
placeholder='Large'
/>
</div>
);
}
Expand Down
4 changes: 1 addition & 3 deletions packages/ui/src/mosaic/block/destructive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ export function Destructive({
value={confirmValue}
onChange={e => setConfirmValue(e.target.value)}
disabled={isDeleting}
sx={t => ({
marginBlockStart: t.spacing(1),
})}
style={{ marginBlockStart: 'var(--cl-spacing)' }}
/>
</Box>
<Box
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/mosaic/components/avatar/avatar.styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as stylex from '@stylexjs/stylex';

import { colorVars, fontWeightVars, radiusVars, space } from '../../tokens.stylex';
import { colorVars, fontFamilyVars, fontWeightVars, radiusVars, space } from '../../tokens.stylex';

export const styles = stylex.create({
// root — clips its parts to the shape/size; fill comes from the image or fallback
Expand All @@ -11,7 +11,7 @@ export const styles = stylex.create({
boxSizing: 'border-box',
display: 'inline-flex',
flexShrink: 0,
fontFamily: 'inherit',
fontFamily: fontFamilyVars['--cl-font-family-sans'],
fontWeight: fontWeightVars['--cl-font-medium'],
justifyContent: 'center',
lineHeight: 1,
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/mosaic/components/badge/badge.styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as stylex from '@stylexjs/stylex';

import { colorVars, fontWeightVars, radiusVars, space, typeScaleVars } from '../../tokens.stylex';
import { colorVars, fontFamilyVars, fontWeightVars, radiusVars, space, typeScaleVars } from '../../tokens.stylex';

// warning/negative/positive tint a faded fill and use the saturated token as text;
// primary/neutral fill with the solid token and use its `-foreground` for text.
Expand All @@ -12,7 +12,7 @@ export const styles = stylex.create({
alignItems: 'center',
boxSizing: 'border-box',
display: 'inline-flex',
fontFamily: 'inherit',
fontFamily: fontFamilyVars['--cl-font-family-sans'],
fontSize: typeScaleVars['--cl-text-xs-size'],
fontWeight: fontWeightVars['--cl-font-medium'],
justifyContent: 'center',
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/mosaic/components/button/button.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as stylex from '@stylexjs/stylex';
import {
colorVars,
durationVars,
fontFamilyVars,
fontWeightVars,
radiusVars,
space,
Expand Down Expand Up @@ -82,7 +83,7 @@ export const styles = stylex.create({
display: 'inline-flex',
// A button is sized by its own axis, not by whatever row it lands in.
flexShrink: 0,
fontFamily: 'inherit',
fontFamily: fontFamilyVars['--cl-font-family-sans'],
fontWeight: fontWeightVars['--cl-font-medium'],
justifyContent: 'center',
outlineOffset: '2px',
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/mosaic/components/heading/heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { MosaicComponentProps } from '../../props';
import { mergeStyleProps, themeProps } from '../../props';
import { useContextProps } from '../../utils/context';
import type { TypographyColor, TypographySize } from '../typography.styles';
import { colors, sizes } from '../typography.styles';
import { styles } from './heading.styles';
import { colors, sizes, styles as typographyStyles } from '../typography.styles';
import { styles as headingStyles } from './heading.styles';

export interface HeadingProps extends MosaicComponentProps<'h2'> {
size?: TypographySize;
Expand All @@ -33,7 +33,7 @@ export const Heading = React.forwardRef<HTMLHeadingElement, HeadingProps>(functi
const props = {
...mergeStyleProps(
themeProps('heading', { size, color }),
stylex.props(styles.base, sizes[size], colors[color]),
stylex.props(typographyStyles.base, headingStyles.base, sizes[size], colors[color]),
className,
style,
),
Expand Down
76 changes: 0 additions & 76 deletions packages/ui/src/mosaic/components/input.tsx

This file was deleted.

2 changes: 2 additions & 0 deletions packages/ui/src/mosaic/components/input/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { Input } from './input';
export type { InputProps } from './input';
101 changes: 101 additions & 0 deletions packages/ui/src/mosaic/components/input/input.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import * as stylex from '@stylexjs/stylex';

import {
colorVars,
durationVars,
fontFamilyVars,
fontWeightVars,
radiusVars,
space,
typeScaleVars,
} from '../../tokens.stylex';

const disabledBackgroundColor = `color-mix(in oklab, ${colorVars['--cl-color-primary']} 5%, transparent)`;
const interactionBorderColor = `color-mix(in oklab, ${colorVars['--cl-color-neutral']} 20%, transparent)`;

export const styles = stylex.create({
base: {
borderColor: {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 we maybe need a reset helper that just resets margin, padding, and box-sizing. we can follow up with it.

default: colorVars['--cl-color-border'],
':focus-visible': interactionBorderColor,
':focus-visible:where([aria-invalid="true"])': colorVars['--cl-color-negative'],
':where([aria-invalid="true"])': colorVars['--cl-color-negative'],
'@media (hover: hover)': {
':hover:not([aria-invalid="true"])': interactionBorderColor,
},
},
borderStyle: 'solid',
borderWidth: {
default: '1px',
':where([aria-invalid="true"])': '2px',
},
outline: {
default: 'none',
':focus-visible': `2px solid ${colorVars['--cl-color-primary']}`,
':focus-visible:where([aria-invalid="true"])': 'none',
},
backgroundColor: colorVars['--cl-color-input'],
boxSizing: 'border-box',
color: 'inherit',
display: 'block',
fontFamily: fontFamilyVars['--cl-font-family-sans'],
outlineOffset: '2px',
transitionDuration: durationVars['--cl-duration-base'],
transitionProperty: 'color, background-color, border-color',
minWidth: 0,
width: '100%',
'::file-selector-button': {
borderStyle: 'none',
borderWidth: 0,
backgroundColor: 'transparent',
color: 'inherit',
display: 'inline-flex',
fontSize: typeScaleVars['--cl-text-sm-size'],
fontWeight: fontWeightVars['--cl-font-medium'],
lineHeight: typeScaleVars['--cl-text-sm-leading'],
height: space['6'],
},
'::placeholder': {
color: colorVars['--cl-color-input-placeholder'],
},
},
disabled: {
backgroundColor: disabledBackgroundColor,
cursor: 'not-allowed',
opacity: 0.5,
pointerEvents: 'none',
},
});

export const sizes = stylex.create({
sm: {
borderRadius: radiusVars['--cl-radius-control'],
paddingInline: space['3'],
fontSize: {
default: typeScaleVars['--cl-text-xs-size'],
'@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--cl-text-xs-size']})`,
},
lineHeight: typeScaleVars['--cl-text-xs-leading'],
height: space['7'],
},
md: {
borderRadius: radiusVars['--cl-radius-control'],
paddingInline: space['3'],
fontSize: {
default: typeScaleVars['--cl-text-sm-size'],
'@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--cl-text-sm-size']})`,
},
lineHeight: typeScaleVars['--cl-text-sm-leading'],
height: space['8'],
},
lg: {
borderRadius: radiusVars['--cl-radius-element'],
paddingInline: space['3'],
fontSize: {
default: typeScaleVars['--cl-text-base-size'],
'@media (pointer: coarse)': `max(1rem, ${typeScaleVars['--cl-text-base-size']})`,
},
lineHeight: 1.375,
height: space['9'],
},
Comment thread
austincalvelage marked this conversation as resolved.
});
Loading
Loading