Skip to content

Commit 59b0762

Browse files
authored
Add font shorthand and use Adobe Clean variable font (#6818)
1 parent dcfa1b0 commit 59b0762

32 files changed

+253
-240
lines changed

.storybook-s2/docs/Icons.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import {highlight} from './highlight' with {type: 'macro'};
66

77
export function Icons() {
88
return (
9-
<div className={style({maxWidth: 'lg', marginX: 'auto', fontFamily: 'sans'})}>
9+
<div className={style({maxWidth: 'lg', marginX: 'auto'})}>
1010
<div className={style({marginX: 48})}>
11-
<h1 className={style({fontSize: 'heading-2xl', color: 'heading', marginBottom: 48})}>
11+
<h1 className={style({font: 'heading-2xl', marginBottom: 48})}>
1212
Workflow icons
1313
</h1>
1414
<P>Spectrum 2 offers a subset of the icons currently available in React Spectrum v3. These icons can be imported from <Code>@react-spectrum/s2/icons</Code>.</P>

.storybook-s2/docs/Intro.jsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import CommunityIcon from '@react-spectrum/s2/s2wf-icons/S2_Icon_Community_20_N.
99
import DeviceTabletIcon from '@react-spectrum/s2/s2wf-icons/S2_Icon_DeviceTablet_20_N.svg';
1010
import DeviceDesktopIcon from '@react-spectrum/s2/s2wf-icons/S2_Icon_DeviceDesktop_20_N.svg';
1111
import {highlight} from './highlight' with {type: 'macro'};
12-
import {H2, H3, H4, P, Pre, Code} from './typography';
12+
import {H2, H3, H4, P, Pre, Code, Strong} from './typography';
1313

1414
export function Docs() {
1515
return (
16-
<div className={style({maxWidth: 'lg', marginX: 'auto', marginY: 48, fontFamily: 'sans'})}>
16+
<div className={style({maxWidth: 'lg', marginX: 'auto', marginY: 48})}>
1717
<header
1818
style={{
1919
backgroundImage: `url(${new URL('wallpaper_collaborative_S2_desktop.webp', import.meta.url).toString()})`,
@@ -25,12 +25,12 @@ export function Docs() {
2525
marginBottom: 48,
2626
borderRadius: 'xl'
2727
})}>
28-
<h1 className={style({fontSize: 'heading-2xl', color: 'white'})}>
28+
<h1 className={style({font: 'heading-2xl', color: 'white'})}>
2929
Spectrum 2 in React Spectrum
3030
</h1>
3131
</header>
3232
<main className={style({marginX: 48})}>
33-
<P><strong>Introducing <Link href="https://s2.spectrum.adobe.com" target="_blank">Spectrum 2</Link></strong> – a new update to Adobe's design system, now in pre-release! Designed to support our growing suite of products, Spectrum 2 aims to work seamlessly across experiences by balancing personality and function.</P>
33+
<P><Strong>Introducing <Link href="https://s2.spectrum.adobe.com" target="_blank">Spectrum 2</Link></Strong> – a new update to Adobe's design system, now in pre-release! Designed to support our growing suite of products, Spectrum 2 aims to work seamlessly across experiences by balancing personality and function.</P>
3434
<P>The React Spectrum team has been hard at work to bring the Spectrum 2 design to our components. Spectrum 2 in React Spectrum is built on <Link href="https://react-spectrum.adobe.com/react-aria/" target="_blank">React Aria Components</Link> and a new styling foundation powered by <Link href="https://github.com/adobe/spectrum-tokens" target="_blank">Spectrum Tokens</Link>. This gives you access to Spectrum design fundamentals such as colors, spacing, sizing, and typography in your own applications and custom components. Spectrum 2 also brings new features such as t-shirt sizing, improved form layout, dynamic new press interactions, and more.</P>
3535
<P>Check out the new Button design, with fresh new colors and icons, a fun new press scaling interaction, and support for t-shirt sizes.</P>
3636
<Example>
@@ -156,7 +156,7 @@ function App() {
156156
<Example>
157157
<Button variant="accent" onPress={() => alert('Hey there!')}>Hello Spectrum 2!</Button>
158158
</Example>
159-
<P><strong>Note</strong>: If you’re embedding Spectrum 2 as a section of a larger page rather than taking over the whole window, follow the <Link href="#embedded-sections" target="_self">directions below</Link> instead of using <Code>page.css</Code>.</P>
159+
<P><Strong>Note</Strong>: If you’re embedding Spectrum 2 as a section of a larger page rather than taking over the whole window, follow the <Link href="#embedded-sections" target="_self">directions below</Link> instead of using <Code>page.css</Code>.</P>
160160
<H3>Overriding the color scheme</H3>
161161
<P>By default, the page follows the user’s operating system color scheme setting, supporting both light and dark mode. The page background is set to the <Code>base</Code> Spectrum background layer by default. This can be configured by setting the <Code>data-color-scheme</Code> and <Code>data-background</Code> attributes on the <Code>{'<html>'}</Code> element. For example, to force the application to only render in light mode, set <Code>data-color-scheme="light"</Code>.</P>
162162
<Pre>{highlight(`<html data-color-scheme="light">

.storybook-s2/docs/StyleMacro.jsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { style } from '../../packages/@react-spectrum/s2/style/spectrum-theme' with {type: 'macro'};
2-
import {Link, LinkButton} from '@react-spectrum/s2';
2+
import {Link} from '@react-spectrum/s2';
33
import {highlight} from './highlight' with {type: 'macro'};
4-
import {H2, H3, H3, P, Pre, Code} from './typography';
4+
import {H2, H3, H3, P, Pre, Code, Strong} from './typography';
55

66
export function StyleMacro() {
77
return (
8-
<div className={style({maxWidth: 'lg', marginX: 'auto', fontFamily: 'sans', fontSize: 'body-lg'})}>
8+
<div className={style({maxWidth: 'lg', marginX: 'auto'})}>
99
<header
1010
className={style({
1111
paddingX: 48,
1212
marginBottom: 48
1313
})}>
14-
<h1 className={style({fontSize: 'heading-2xl', color: 'heading'})}>
14+
<h1 className={style({font: 'heading-2xl'})}>
1515
Style Macro
1616
</h1>
1717
</header>
@@ -22,14 +22,14 @@ export function StyleMacro() {
2222
<div className={style({backgroundColor: 'red-400', color: 'white'})}>
2323
{/* ... */}
2424
</div>`)}</Pre>
25-
<P><strong>Atomic CSS</strong> scales as your application grows because it outputs a separate rule for each CSS property you write, ensuring there is no duplication across your whole app. The above example generates two CSS rules:</P>
25+
<P><Strong>Atomic CSS</Strong> scales as your application grows because it outputs a separate rule for each CSS property you write, ensuring there is no duplication across your whole app. The above example generates two CSS rules:</P>
2626
<Pre>{highlight(`.bJ { background-color: #ffbcb4 }
2727
.ac { color: #fff }`, 'CSS')}</Pre>
2828
<P>These rules are reused across your app wherever the same values are used, which keeps your bundle size small even as you add features. In addition, you only pay for the values you use – there’s no unnecessary CSS custom properties for colors and other tokens that aren’t used.</P>
29-
<P>The <Code>style</Code> macro <strong>colocates</strong> your styles with your component code, rather than in separate CSS files. Colocation enables you to:</P>
29+
<P>The <Code>style</Code> macro <Strong>colocates</Strong> your styles with your component code, rather than in separate CSS files. Colocation enables you to:</P>
3030
<ul className="sb-unstyled">
31-
<li className={style({lineHeight: 'body', color: 'body', marginTop: 0, marginBottom: 8})}><strong>Develop more efficiently</strong> – No need to switch between multiple files when working on a component, or spend time writing CSS selectors.</li>
32-
<li className={style({lineHeight: 'body', color: 'body', marginY: 0})}><strong>Refactor with confidence</strong> – Changing the styles in a component is guaranteed to never unintentionally affect any other parts of your application. When you delete a component, the corresponding styles are also removed, reducing technical debt.</li>
31+
<li className={style({font: 'body-lg', marginTop: 0, marginBottom: 8})}><Strong>Develop more efficiently</Strong> – No need to switch between multiple files when working on a component, or spend time writing CSS selectors.</li>
32+
<li className={style({font: 'body-lg', marginY: 0})}><Strong>Refactor with confidence</Strong> – Changing the styles in a component is guaranteed to never unintentionally affect any other parts of your application. When you delete a component, the corresponding styles are also removed, reducing technical debt.</li>
3333
</ul>
3434
<H2>Values</H2>
3535
<P>The <Code>style</Code> macro supports a constrained set of values for each CSS property, which conform to the Spectrum design system. For example, the <Code>backgroundColor</Code> property supports Spectrum colors, and does not allow arbitrary hex or rgb values by default. This helps make it easier to build consistent UIs that are maintainable over time.</P>
@@ -60,6 +60,7 @@ export function StyleMacro() {
6060
}
6161
}
6262
});
63+
6364
function MyComponent({variant}) {
6465
return <div className={styles({variant})} />
6566
}`)}</Pre>
@@ -70,9 +71,11 @@ function MyComponent({variant}) {
7071
isSelected: 'gray-900'
7172
}
7273
});
74+
7375
<div className={styles({isSelected: true})} />`)}</Pre>
7476
<P>Runtime conditions also work well with the <Link href="https://react-spectrum.adobe.com/react-aria/styling.html#render-props" target="_blank">render props</Link> in React Aria Components. If you define your styles inline, you’ll even get autocomplete for all of the available conditions.</P>
7577
<Pre>{highlight(`import {Checkbox} from 'react-aria-components';
78+
7679
<Checkbox
7780
className={style({
7881
backgroundColor: {
@@ -97,6 +100,7 @@ function MyComponent({variant}) {
97100
}
98101
}
99102
});
103+
100104
<div className={styles({isSelected, isEmphasized, isDisabled})} />`)}</Pre>
101105
<P>The above example has three runtime conditions (<Code>isSelected</Code>, <Code>isEmphasized</Code>, and <Code>isDisabled</Code>), and uses the <Code>forcedColors</Code> condition to apply styles for <Link href="https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors" target="_blank">Windows High Contrast Mode</Link> (WHCM). The order of precedence follows the order the conditions are defined in the object, with the <Code>isSelected</Code> + <Code>isDisabled</Code> + <Code>forcedColors</Code> state having the highest priority.</P>
102106
<H2>Reusing styles</H2>
@@ -106,6 +110,7 @@ function MyComponent({variant}) {
106110
alignItems: 'center',
107111
columnGap: 8
108112
};
113+
109114
const styles = style({
110115
...horizontalStack,
111116
columnGap: 4
@@ -122,6 +127,7 @@ export function horizontalStack(gap: number) {
122127
<P>Then, import your macro and use it in a component.</P>
123128
<Pre>{highlight(`// component.tsx
124129
import {horizontalStack} from './style-utils' with {type: 'macro'};
130+
125131
const styles = style({
126132
...horizontalStack(4),
127133
backgroundColor: 'base'

.storybook-s2/docs/typography.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,34 @@ import {Link} from '@react-spectrum/s2';
33

44
export function H2({children}) {
55
let id = anchorId(children);
6-
return <h2 className={style({fontSize: 'heading-xl', lineHeight: 'heading', color: 'heading', marginTop: 48, marginBottom: 24})} id={id}>{children}</h2>
6+
return <h2 className={style({font: 'heading-xl', marginTop: 48, marginBottom: 24})} id={id}>{children}</h2>
77
}
88

99
export function H3({children}) {
1010
let id = anchorId(children);
11-
return <h3 className={style({fontSize: 'heading', lineHeight: 'heading', color: 'heading', marginTop: 32, marginBottom: 16})} id={anchorId(children)}>{children}</h3>
11+
return <h3 className={style({font: 'heading', marginTop: 32, marginBottom: 16})} id={anchorId(children)}>{children}</h3>
1212
}
1313

1414
export function H4({children}) {
1515
let id = anchorId(children);
16-
return <h4 className={style({fontSize: 'heading-sm', lineHeight: 'heading', color: 'heading', marginTop: 32, marginBottom: 8})} id={anchorId(children)}>{children}</h4>
16+
return <h4 className={style({font: 'heading-sm', marginTop: 32, marginBottom: 8})} id={anchorId(children)}>{children}</h4>
1717
}
1818

1919
export function P({children}) {
20-
return <p className={style({fontSize: 'body-lg', lineHeight: 'body', color: 'body', marginTop: 0, marginBottom: 24})}>{children}</p>
20+
return <p className={style({font: 'body-lg', marginTop: 0, marginBottom: 24})}>{children}</p>
2121
}
2222

2323
export function Code({children}) {
24-
return <code className={style({fontFamily: 'code', fontSize: 'code-sm', backgroundColor: 'layer-1', paddingX: 4, borderWidth: 1, borderColor: 'gray-100', borderStyle: 'solid', borderRadius: 'sm'})}>{children}</code>;
24+
return <code className={style({font: 'code-sm', backgroundColor: 'layer-1', paddingX: 4, borderWidth: 1, borderColor: 'gray-100', borderStyle: 'solid', borderRadius: 'sm'})}>{children}</code>;
25+
}
26+
27+
export function Strong({children}) {
28+
return <strong className={style({fontWeight: 'bold'})}>{children}</strong>;
2529
}
2630

2731
export function Pre({children}) {
2832
return (
29-
<pre className={'sb-unstyled ' + style({padding: 32, marginY: 32, backgroundColor: 'layer-1', borderRadius: 'xl', fontFamily: 'code', fontSize: 'code-sm', lineHeight: 'code'})}>
33+
<pre className={'sb-unstyled ' + style({padding: 32, marginY: 32, backgroundColor: 'layer-1', borderRadius: 'xl', font: 'code-sm'})}>
3034
<code dangerouslySetInnerHTML={{__html: children}} />
3135
</pre>
3236
);

.storybook-s2/preview-head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<script>
77
(function(d) {
88
var config = {
9-
kitId: 'uei1lip',
9+
kitId: 'fqj0dxc',
1010
scriptTimeout: 3000,
1111
async: true
1212
},

packages/@react-spectrum/s2/src/ActionButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ export const btnStyles = style<ButtonRenderProps & ActionButtonStyleProps & Togg
5353
alignItems: 'center',
5454
justifyContent: 'center',
5555
columnGap: 'text-to-visual',
56-
fontFamily: 'sans',
56+
font: 'control',
5757
fontWeight: 'medium',
58-
fontSize: 'control',
5958
userSelect: 'none',
6059
height: 'control',
6160
minWidth: 'control',

packages/@react-spectrum/s2/src/Badge.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ export interface BadgeProps extends DOMProps, AriaLabelingProps, StyleProps, Bad
4545

4646
const badge = style<BadgeStyleProps>({
4747
display: 'flex',
48-
fontFamily: 'sans',
49-
fontSize: 'control',
48+
font: 'control',
5049
justifyContent: 'center',
5150
alignItems: 'center',
5251
borderRadius: 'control',

packages/@react-spectrum/s2/src/Breadcrumbs.tsx

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ const linkStyles = style({
146146
}
147147
},
148148
transition: 'default',
149-
fontFamily: 'sans',
150-
fontSize: 'control',
149+
font: 'control',
151150
fontWeight: {
152151
default: 'normal',
153152
isCurrent: 'bold'
@@ -166,53 +165,23 @@ const linkStyles = style({
166165
default: 'focus-ring',
167166
forcedColors: 'Highlight'
168167
},
169-
disableTapHighlight: true,
170-
marginTop: {
171-
size: {
172-
M: size(6), // component-top-to-text-100
173-
L: size(9) // component-top-to-text-200
174-
}
175-
},
176-
marginBottom: {
177-
size: {
178-
M: size(8), // component-bottom-to-text-100
179-
L: size(11) // component-bottom-to-text-200
180-
}
181-
}
168+
disableTapHighlight: true
182169
});
183170

184-
const currentStyles = style({
171+
const currentStyles = style<{size: string}>({
185172
color: {
186173
default: 'neutral',
187174
forcedColors: 'ButtonText'
188175
},
189176
transition: 'default',
190-
fontFamily: 'sans',
191-
fontSize: 'control',
192-
fontWeight: 'bold',
193-
marginTop: {
194-
default: {
195-
size: {
196-
M: size(6), // component-top-to-text-100
197-
L: size(9) // component-top-to-text-200
198-
}
199-
}
200-
},
201-
marginBottom: {
202-
default: {
203-
size: {
204-
M: size(9), // component-bottom-to-text-100
205-
L: size(11) // component-bottom-to-text-200
206-
}
207-
}
208-
}
177+
font: 'control',
178+
fontWeight: 'bold'
209179
});
210180

211181
// TODO: support user heading size customization, for now just set it to large
212182
const heading = style({
213183
margin: 0,
214-
fontFamily: 'sans',
215-
fontSize: 'heading-lg',
184+
font: 'heading-lg',
216185
fontWeight: 'extra-bold'
217186
});
218187

@@ -234,7 +203,7 @@ export function Breadcrumb({children, ...props}: BreadcrumbProps) {
234203
className={breadcrumbStyles({size, isCurrent})} >
235204
{isCurrent ?
236205
<span
237-
className={currentStyles({size, isCurrent})}>
206+
className={currentStyles({size})}>
238207
<Provider
239208
values={[
240209
[HeadingContext, {className: heading}]

packages/@react-spectrum/s2/src/Button.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ const button = style<ButtonRenderProps & ButtonStyleProps>({
7272
justifyContent: 'center',
7373
textAlign: 'start',
7474
columnGap: 'text-to-visual',
75-
fontFamily: 'sans',
75+
font: 'control',
7676
fontWeight: 'bold',
77-
fontSize: 'control',
7877
userSelect: 'none',
7978
minHeight: 'control',
8079
minWidth: {

packages/@react-spectrum/s2/src/Checkbox.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ const wrapper = style({
4949
columnGap: 'text-to-control',
5050
alignItems: 'baseline',
5151
width: 'fit',
52-
fontFamily: 'sans',
53-
fontSize: 'control',
52+
font: 'control',
5453
transition: 'colors',
5554
color: {
5655
default: 'neutral',

0 commit comments

Comments
 (0)