Skip to content

Commit fab5a77

Browse files
authored
chore: update documentation (#729)
1 parent fa1397f commit fab5a77

File tree

2 files changed

+69
-5
lines changed

2 files changed

+69
-5
lines changed

src/stories/BaseProperties.docs.mdx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,9 @@ Base properties are common properties available to all components in the Cube UI
1616
| `element` | `string` | Inner element name for styling purposes. Format: capitalized string (e.g., "Label", "Icon") |
1717
| `styles` | `Styles` | The style map for customizing component appearance using the `tasty` style system |
1818
| `breakpoints` | `number[]` | The list of responsive breakpoints in pixels for this component |
19-
| `block` | `boolean` | Whether the element has block layout outside (display: block) |
20-
| `inline` | `boolean` | Whether the element has inline layout outside (display: inline) |
2119
| `mods` | `{ [key: string]: boolean \| undefined \| null }` | The list of element modifiers for state-based styling |
2220
| `isHidden` | `boolean` | Whether the element is hidden (`hidden` attribute is set) |
2321
| `isDisabled` | `boolean` | Whether the element is disabled (`disabled` attribute is set) |
24-
| `css` | `string` | Plain CSS string for the element |
25-
| `styleName` | `string` | The element name for use in style overriding |
2622
| `style` | `CSSProperties` | The CSS style map (native React style object) |
2723

2824
## Standard HTML Properties

src/stories/Tasty.docs.mdx

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ const Card = tasty({
2424
border: true,
2525
radius: true,
2626
},
27+
styleProps: ['padding', 'fill'], // Expose styles as props
2728
});
2829

2930
// Usage
3031
<Card>Hello World</Card>
32+
<Card padding="6x" fill="#gray.05">Custom Card</Card>
3133
```
3234

3335
### Extending Existing Components
@@ -108,6 +110,64 @@ const GlobalHeading = tasty('.heading', {
108110
});
109111
```
110112

113+
### Style Props - Direct Style Access
114+
115+
Use `styleProps` to expose style properties as direct component props:
116+
117+
```jsx
118+
const FlexibleBox = tasty({
119+
as: 'div',
120+
styles: {
121+
display: 'flex',
122+
padding: '2x',
123+
},
124+
styleProps: ['gap', 'align', 'placeContent', 'fill'],
125+
});
126+
127+
// Usage - style properties become direct props
128+
<FlexibleBox
129+
gap="2x"
130+
align="center"
131+
placeContent="space-between"
132+
fill="#surface"
133+
>
134+
Content
135+
</FlexibleBox>
136+
137+
// Equivalent to using styles prop:
138+
<FlexibleBox styles={{
139+
gap: '2x',
140+
align: 'center',
141+
placeContent: 'space-between',
142+
fill: '#surface'
143+
}}>
144+
Content
145+
</FlexibleBox>
146+
```
147+
148+
**Benefits of `styleProps`:**
149+
- **Cleaner API** - No need for `styles` prop wrapper
150+
- **Better TypeScript support** - Props are properly typed
151+
- **Component-specific styling** - Expose only relevant properties
152+
- **Responsive support** - Works with arrays: `gap={['2x', '1x']}`
153+
- **State-based styling** - Works with objects: `fill={{ '': '#white', hovered: '#gray' }}`
154+
155+
**Style Prop Priority:**
156+
```jsx
157+
// Direct props override styles prop
158+
<FlexibleBox
159+
styles={{ gap: '1x' }}
160+
gap="3x" // This takes priority
161+
/>
162+
163+
// Both direct props and styles can be used together
164+
<FlexibleBox
165+
styles={{ padding: '2x', border: true }}
166+
gap="2x"
167+
align="center"
168+
/>
169+
```
170+
111171
### Style System Overview
112172

113173
Tasty enhances CSS with:
@@ -560,7 +620,8 @@ const Component = tasty({
560620
```jsx
561621
// ✅ Use styled wrappers instead of styles prop
562622
const StyledButton = tasty(Button, {
563-
styles: { fill: '#purple' }
623+
styles: { fill: '#purple' },
624+
styleProps: ['fill', 'color'], // Expose common styles as props
564625
});
565626

566627
// ✅ Use design tokens and custom units
@@ -590,6 +651,13 @@ styles: {
590651
hovered: '#gray.05',
591652
},
592653
}
654+
655+
// ✅ Use styleProps for component APIs
656+
const Container = tasty({
657+
styles: { display: 'flex' },
658+
styleProps: ['gap', 'padding', 'align', 'justify'],
659+
});
660+
// Enables: <Container gap="2x" align="center" />
593661
```
594662

595663
### Don'ts ❌

0 commit comments

Comments
 (0)