Skip to content

Commit 3b991ea

Browse files
committed
adding more values
1 parent 819c076 commit 3b991ea

File tree

3 files changed

+75
-3
lines changed

3 files changed

+75
-3
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,20 @@ Reference table for the properties and values supported by React Spectrum `style
1616

1717
## Colors
1818

19+
TODO: do we just want the table or preserve the same formatting as the styling guide?
20+
1921
All Spectrum 2 color tokens are available across color properties (e.g., `backgroundColor`, `color`, `borderColor`).
2022

2123
<S2Colors />
2224

25+
Below are the rest of the `style` macro supported color properties.
26+
27+
<StyleMacroProperties properties={getPropertyDefinitions(['outlineColor', 'fill', 'stroke'])} />
28+
2329
## Spacing
2430

31+
TODO: decide what to do with Spacing/Sizing since they are pretty much rolled up into Dimensions?
32+
2533
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:
2634

2735
- `edge-to-text` – default spacing between the edge of a control and its text. Relative to control height.
@@ -38,6 +46,7 @@ Size props like `width` and `height` accept arbitrary pixel values. Values are c
3846
## Text
3947

4048
// TODO: edit copy
49+
4150
Spectrum 2 typography is applied via the `font` shorthand, which sets `fontFamily`, `fontSize`, `fontWeight`, `lineHeight`, and `color`. You can override any of these individually.
4251

4352
```tsx
@@ -55,8 +64,12 @@ Type scales include: UI, Body, Heading, Title, Detail, and Code. Each scale has
5564
<S2Typography />
5665

5766

67+
<StyleMacroProperties properties={getPropertyDefinitions(['fontFamily', 'listStyleType', 'listStylePosition'])} />
68+
69+
5870
## Effects
5971

72+
<StyleMacroProperties properties={getPropertyDefinitions(['boxShadow', 'filter'])} />
6073

6174
## Layout
6275

packages/dev/s2-docs/src/styleProperties.ts

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,20 @@
1111
*/
1212

1313
interface StyleMacroPropertyDefinition {
14-
type: 'mapped' | 'percentage' | 'sizing' | 'arbitrary',
14+
// TODO: unneeded for now
15+
type: 'color' | 'mapped' | 'percentage' | 'sizing' | 'arbitrary',
16+
// Values tied to the property, usually manually defined for now
1517
values: string[],
18+
// Additional value types to append, usually used to add type links to generalize a type that
19+
// the property extends aka a css length percentage or a number that needs more explaination
1620
additionalTypes?: string[]
1721
}
1822

23+
// properties that extend from baseColors
24+
const baseColorProperties = new Set([
25+
'color', 'backgroundColor', 'borderColor', 'outlineColor', 'fill', 'stroke'
26+
])
27+
1928
// Properties that use PercentageProperty (accept LengthPercentage in addition to mapped values)
2029
const percentageProperties = new Set([
2130
'top', 'left', 'bottom', 'right',
@@ -32,15 +41,59 @@ const sizingProperties = new Set([
3241
]);
3342

3443
// manually defined
44+
// TODO: maybe spit these up into groups, and have getPropertyDefinitions grab via category name instead
3545
const propertyValues: {[key: string]: string[]} = {
46+
// Color
47+
// This should append baseColors in getPropertyDefinition
48+
outlineColor: ['focus-ring'],
49+
// This should append what seems to be a combination of semantic colors and background/global colors
50+
fill: ['none', 'currentColor'],
51+
stroke: ['none', 'currentColor'],
52+
53+
3654
display: ['block', 'inline-block', 'inline', 'flex', 'inline-flex', 'grid', 'inline-grid', 'contents', 'list-item', 'none'],
3755
top: ['0', '2', '4', '8', '12', '16', '20', '24', '28', '32', '36', '40', '44', '48', '56', '64', '80', '96', '-2', '-4', '-8', '-12', '-16', '-20', '-24', '-28', '-32', '-36', '-40', '-44', '-48', '-56', '-64', '-80', '-96', 'auto', 'full'],
38-
height: ['auto', 'full', 'min', 'max', 'fit', 'screen']
56+
height: ['auto', 'full', 'min', 'max', 'fit', 'screen'],
57+
58+
59+
// text
60+
fontFamily: ['sans', 'serif', 'code'],
61+
// todo: skipped font-size, font-weight, line height though these will also just be manually defined here
62+
listStyleType: ['none', 'disc', 'decimal'],
63+
listStylePosition: ['inside', 'outside'],
64+
textTransform: ['uppercase', 'lowercase', 'capitalize', 'none'],
65+
textAlign: ['start', 'center', 'end', 'justify'],
66+
verticalAlign: ['baseline', 'top', 'middle', 'bottom', 'text-top', 'text-bottom', 'sub', 'super'],
67+
textDecoration: ['none' , 'underline' , 'overline' , 'line-through'],
68+
69+
textOverflow: ['ellipsis', 'clip'],
70+
lineClamp: ['number'],
71+
hyphens: ['none', 'manual', 'auto'],
72+
whiteSpace: ['normal', 'nowrap', 'pre', 'pre-line', 'pre-wrap', 'break-spaces'],
73+
textWrap: ['wrap', 'nowrap', 'balance', 'pretty'],
74+
wordBreak: ['normal', 'break-all', 'keep-all', 'break-word'],
75+
overflowWrap: ['normal', 'anywhere', 'break-word'],
76+
boxDecorationBreak: ['slice', 'clone'],
77+
78+
// effects
79+
// TODO: should the below have a typelink explaining more details
80+
boxShadow: ['emphasized', 'elevated', 'dragged', 'none'],
81+
filter: ['emphasized', 'elevated', 'dragged', 'none'],
82+
3983
};
4084

85+
// TODO: will we need something specific for short hand?
4186
export function getPropertyDefinition(propertyName: string): StyleMacroPropertyDefinition {
4287
const values = propertyValues[propertyName] || [];
4388

89+
if (baseColorProperties.has(propertyName)) {
90+
return {
91+
type: 'color',
92+
values,
93+
additionalTypes: ['baseColors']
94+
}
95+
}
96+
4497
if (sizingProperties.has(propertyName)) {
4598
return {
4699
type: 'sizing',

packages/dev/s2-docs/src/types.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ function TemplateLiteral({elements}: TTemplate) {
696696
}
697697

698698
interface StyleMacroPropertyDefinition {
699-
type: 'mapped' | 'percentage' | 'sizing' | 'arbitrary',
699+
type: 'color' | 'mapped' | 'percentage' | 'sizing' | 'arbitrary',
700700
values: string[],
701701
additionalTypes?: string[]
702702
}
@@ -705,6 +705,7 @@ interface StyleMacroPropertiesProps {
705705
properties: {[propertyName: string]: StyleMacroPropertyDefinition}
706706
}
707707

708+
// TODO: fix the width of the columns so that they are consistent
708709
export function StyleMacroProperties({properties}: StyleMacroPropertiesProps) {
709710
let propertyNames = Object.keys(properties);
710711

@@ -740,6 +741,11 @@ export function StyleMacroProperties({properties}: StyleMacroPropertiesProps) {
740741
<React.Fragment key={`type-${i}`}>
741742
<Punctuation>{' | '}</Punctuation>
742743
<TypePopover name={typeName}>
744+
{typeName === 'baseColors' && (
745+
<p className={style({font: 'body'})}>
746+
A base set of colors defined by Spectrum. See the global and semantic colors in the color reference above.
747+
</p>
748+
)}
743749
{typeName === 'LengthPercentage' && (
744750
<p className={style({font: 'body'})}>
745751
A CSS length value with percentage or viewport units. Examples: <code className={codeStyle}>'50%'</code>, <code className={codeStyle}>'100vw'</code>, <code className={codeStyle}>'50vh'</code>

0 commit comments

Comments
 (0)