-
Notifications
You must be signed in to change notification settings - Fork 1.3k
docs: Style macro docs #9090
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LFDanLu
wants to merge
30
commits into
main
Choose a base branch
from
style_macro_docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,062
β86
Open
docs: Style macro docs #9090
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
edeaa2f
add FAQ and other sections
LFDanLu 8a1f97e
add section for creating custom components
LFDanLu 28eb788
initial stab at extracting types from style macro
LFDanLu 457c59a
testing sizing properties
LFDanLu a15c24f
Merge branch 'main' of github.com:adobe/react-spectrum into referenceβ¦
LFDanLu 819c076
revert export of theme object since it was breaking inference
LFDanLu 3b991ea
adding more values
LFDanLu 42b0406
reorg
LFDanLu 36f1a6f
add the rest of the properties and double check them
LFDanLu e2b29c9
add more type links
LFDanLu 4c94cd0
add mdn links for common types and specific css properties
LFDanLu 83262ef
add relative links so basecolors and various dimension strings link bβ¦
LFDanLu 5d2b172
add descriptions to table and get rid of unessasary isRelative
LFDanLu 980d3d6
add short hand and condition tables
LFDanLu 59e9400
add subpage for reference and advanced style macro section
LFDanLu a414886
support subpage list under the ToC
LFDanLu 0b2751d
forgot to move last bit of content
LFDanLu 4ef4996
update FAQ, add mobile related pages, link from RAC styling
LFDanLu b04b7af
Merge branch 'main' of github.com:adobe/react-spectrum into style_macβ¦
LFDanLu 807beb0
fix mobile styling
LFDanLu 0c6ac3f
review comments
LFDanLu a3d57a9
fix build links?
LFDanLu 30bab22
rename mdx file to fix all links
LFDanLu 44b0d8d
Merge branch 'main' of github.com:adobe/react-spectrum into style_macβ¦
LFDanLu 5084b6b
small fixes
LFDanLu 34ad8cc
move reference out of subpage and merge styling page
LFDanLu 6bf1724
make icons page lowercase and fix shorthands link
LFDanLu 6e508f2
whoops forgot to make git track the capitalization rename
LFDanLu 4b38f98
addressing feedback from quarry team
LFDanLu 2e13868
Merge branch 'main' of github.com:adobe/react-spectrum into style_macβ¦
LFDanLu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| import {Layout} from '../../src/Layout'; | ||
| import {InlineAlert, Heading, Content, Link} from '@react-spectrum/s2'; | ||
| import {S2Colors} from '../../src/S2Colors'; | ||
| import {S2Typography} from '../../src/S2Typography'; | ||
| import {StyleMacroProperties} from '../../src/types'; | ||
| import {getPropertyDefinitions, getShorthandDefinitions} from '../../src/styleProperties'; | ||
| export default Layout; | ||
|
|
||
| export const section = 'Components'; | ||
| export const tags = ['style', 'macro', 'spectrum', 'custom', 'values', 'reference']; | ||
| export const description = 'Reference table for the style macro'; | ||
|
|
||
| # Style Macro | ||
|
|
||
| The `style` macro supports a constrained set of values per property that conform to Spectrum 2. | ||
|
|
||
| ## Colors | ||
snowystinger marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| All Spectrum 2 color tokens are available across color properties (e.g., `backgroundColor`, `color`, `borderColor`). | ||
| `baseColors` consists of the semantic and global colors listed below. | ||
|
|
||
| <S2Colors /> | ||
|
|
||
| <StyleMacroProperties properties={getPropertyDefinitions('color')} /> | ||
|
Comment on lines
+22
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| ## Dimensions | ||
|
|
||
| Spacing props like `margin` and `padding` accept values on a **4px grid**. These are specified in `px` and get converted to `rem`. In addition to numbers, these named options are available: | ||
|
|
||
| - `edge-to-text` β default spacing between the edge of a control and its text. Relative to control height. | ||
| - `pill` β default spacing between the edge of a pill-shaped control and its text. Relative to control height. | ||
| - `text-to-control` β default spacing between text and a control (e.g., label and input). Scales with font size. | ||
| - `text-to-visual` β default spacing between text and a visual element (e.g., icon). Scales with font size. | ||
|
|
||
| Size props like `width` and `height` accept arbitrary pixel values. Values are converted to `rem` and multiplied by 1.25x on touch devices to increase hit targets. | ||
|
|
||
| <StyleMacroProperties properties={getPropertyDefinitions('dimensions')} /> | ||
|
|
||
| ## Text | ||
|
|
||
| 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. | ||
|
|
||
| ```tsx | ||
| <main> | ||
| <h1 className={style({font: 'heading-xl'})}>Heading</h1> | ||
| <p className={style({font: 'body'})}>Body</p> | ||
| <ul className={style({font: 'body-sm', fontWeight: 'bold'})}> | ||
| <li>List item</li> | ||
| </ul> | ||
| </main> | ||
| ``` | ||
|
|
||
| Type scales include: UI, Body, Heading, Title, Detail, and Code. Each scale has a default and additional t-shirt sizes (e.g., `ui-sm`, `heading-2xl`, `code-xl`). | ||
|
|
||
| <S2Typography /> | ||
|
|
||
|
|
||
| <StyleMacroProperties properties={getPropertyDefinitions('text')} /> | ||
|
|
||
|
|
||
| ## Effects | ||
|
|
||
| <StyleMacroProperties properties={getPropertyDefinitions('effects')} /> | ||
|
|
||
| ## Layout | ||
|
|
||
| <StyleMacroProperties properties={getPropertyDefinitions('layout')} /> | ||
|
|
||
| ## Misc | ||
|
|
||
| <StyleMacroProperties properties={getPropertyDefinitions('misc')} /> | ||
|
|
||
| ## Shorthands | ||
|
|
||
| Shorthands apply their provided value to commonly grouped properties. | ||
|
|
||
| <StyleMacroProperties properties={getShorthandDefinitions('shorthand')} /> | ||
|
|
||
| ## Conditions | ||
|
|
||
| <StyleMacroProperties properties={getPropertyDefinitions('conditions')} /> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would this be the only one with a lowercase? seems like the file should be renamed if that's what it relies on, that way it's more predictable.
really i'd like to get rid of all the uppercases in the urls... but that's a different issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the convention that seems to exist currently is that component pages are capitalized (e.g. DropZone/Menu/etc) and that non component pages aren't (e.g. dnd.mdx/migrating.mdx/etc) and icons fits into the latter. The file should be renamed to be lower case as well with my last commit, forgot to force git to recognize that change since it didn't automatically