You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/dev/s2-docs/pages/react-aria/styling.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -263,7 +263,7 @@ import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
263
263
264
264
## Animation
265
265
266
-
React Aria Components supports both [CSS transitions](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions) and [keyframe animations](https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes), and works with JavaScript animation libraries like [Framer Motion](https://www.framer.com/motion/).
266
+
React Aria Components supports both [CSS transitions](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions) and [keyframe animations](https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes), and works with JavaScript animation libraries like [Motion](https://motion.dev/).
Copy file name to clipboardExpand all lines: packages/dev/s2-docs/pages/s2/reference.mdx
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,6 +39,7 @@ Size props like `width` and `height` accept arbitrary pixel values. Values are c
39
39
## Text
40
40
41
41
Spectrum 2 typography can be applied via the `font`[shorthand](#shorthands), which sets `fontFamily`, `fontSize`, `fontWeight`, `lineHeight`, and `color`. You can override any of these individually.
42
+
Note that `font` should be applied on a per element basis rather than globally so as to properly conform with Spectrum designs.
Copy file name to clipboardExpand all lines: packages/dev/s2-docs/pages/s2/styling.mdx
+2-34Lines changed: 2 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -278,47 +278,15 @@ const childStyle = style({
278
278
});
279
279
```
280
280
281
-
## Creating custom components
282
-
283
-
In-depth examples are coming soon!
284
-
285
-
`mergeStyles` can be used to merge the style strings from multiple macros together, with the latter styles taking precedence similar to object spreading.
286
-
This behavior can be leveraged to create a component API that allows an end user to only override specific styles conditionally.
287
-
288
-
```tsx
289
-
// User can override the component's background color ONLY if it isn't "quiet"
function MyComponent({isQuiet, styles}: {isQuiet?:boolean, styles?:StyleString}) {
295
-
let result =mergeStyles(
296
-
baselineStyles(null, styles),
297
-
isQuiet?quietStyles:null
298
-
);
299
-
300
-
return <divclassName={result}>My component</div>
301
-
}
302
-
303
-
// Displays quiet styles
304
-
<MyComponentisQuietstyles={userStyles} />
305
-
306
-
// Displays user overrides
307
-
<MyComponentstyles={userStyles} />
308
-
```
309
-
310
-
The `iconStyle` macro should be used when styling Icons, see the [docs](./icons.html#iconstyle) for more information.
311
-
312
281
## CSS optimization
313
282
314
-
The `style` macro relies on CSS bundling and minification for optimal output. Follow these best practices:
283
+
The `style` macro relies on CSS bundling and minification for optimal output. Failure to perform this optimization will result in a suboptimal developer experience and obtuse styling bugs.
284
+
Follow these best practices:
315
285
316
286
- Ensure styles are extracted into a CSS bundle; do not inject at runtime with `<style>` tags.
317
287
- Use a CSS minifier like `lightningcss` to deduplicate common rules (consider in dev for easier debugging).
318
288
- Bundle all CSS for S2 components and style macros into a single CSS bundle rather than code splitting to avoid duplicate rules across chunks.
319
289
320
-
**Failure to perform this optimization will result in a suboptimal developer experience and obtuse styling bugs.**
321
-
322
290
### Parcel
323
291
324
292
Parcel supports macros out of the box and optimizes CSS with [Lightning CSS](https://lightningcss.dev). You can bundle all S2 and macro CSS into a single file using [manual shared bundles](https://parceljs.org/features/code-splitting/#manual-shared-bundles).
0 commit comments