Skip to content

Commit 61ba9db

Browse files
committed
review comments
1 parent 2e13868 commit 61ba9db

File tree

3 files changed

+4
-35
lines changed

3 files changed

+4
-35
lines changed

packages/dev/s2-docs/pages/react-aria/styling.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
263263

264264
## Animation
265265

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/).
267267

268268
### CSS transitions
269269

packages/dev/s2-docs/pages/s2/reference.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Size props like `width` and `height` accept arbitrary pixel values. Values are c
3939
## Text
4040

4141
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.
4243

4344
```tsx
4445
<main>

packages/dev/s2-docs/pages/s2/styling.mdx

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -278,47 +278,15 @@ const childStyle = style({
278278
});
279279
```
280280

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"
290-
const baselineStyles = style({backgroundColor: 'gray-100'}, ['backgroundColor']);
291-
const quietStyles = style({backgroundColor: 'transparent'});
292-
const userStyles = style({backgroundColor: 'celery-600'});
293-
294-
function MyComponent({isQuiet, styles}: {isQuiet?: boolean, styles?: StyleString}) {
295-
let result = mergeStyles(
296-
baselineStyles(null, styles),
297-
isQuiet ? quietStyles : null
298-
);
299-
300-
return <div className={result}>My component</div>
301-
}
302-
303-
// Displays quiet styles
304-
<MyComponent isQuiet styles={userStyles} />
305-
306-
// Displays user overrides
307-
<MyComponent styles={userStyles} />
308-
```
309-
310-
The `iconStyle` macro should be used when styling Icons, see the [docs](./icons.html#iconstyle) for more information.
311-
312281
## CSS optimization
313282

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:
315285

316286
- Ensure styles are extracted into a CSS bundle; do not inject at runtime with `<style>` tags.
317287
- Use a CSS minifier like `lightningcss` to deduplicate common rules (consider in dev for easier debugging).
318288
- Bundle all CSS for S2 components and style macros into a single CSS bundle rather than code splitting to avoid duplicate rules across chunks.
319289

320-
**Failure to perform this optimization will result in a suboptimal developer experience and obtuse styling bugs.**
321-
322290
### Parcel
323291

324292
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

Comments
 (0)