Skip to content

Commit 852be67

Browse files
committed
Merge branch 'main' of github.com:styleframe-dev/styleframe
2 parents 435962f + c3913ee commit 852be67

File tree

144 files changed

+7124
-2361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+7124
-2361
lines changed

.changeset/add-figma-plugin.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

.changeset/config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
"@styleframe/testing-integration",
2121
"@styleframe/docs",
2222
"@styleframe/app",
23-
"@styleframe/storybook",
24-
"@styleframe/figma"
23+
"@styleframe/storybook"
2524
],
2625
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
2726
"onlyUpdatePeerDependentsWhenOutOfRange": true

.claude/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ import { useFluidViewport, useFluidFontSize, useFluidClamp } from '@styleframe/p
157157
5. **NEVER use arbitrary CSS values without `css` template literal for complex expressions**
158158
6. **NEVER forget to export the Styleframe instance as default**
159159
7. **NEVER use appearance-based names** - Use semantic names (e.g., `color.primary` not `color.blue`)
160+
8. **NEVER use named exports in index files** - Use `export *` for all re-exports in index files
160161

161162
---
162163

.claude/styleframe-api.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,34 @@ createPadding({ sm: ref(spacingSm) }, [hover, focus]);
139139

140140
**IMPORTANT:** Always invoke the creator function. Defining the utility without calling it produces no CSS.
141141

142+
### Spacing Utility Composables
143+
144+
Spacing utilities (`useMarginUtility`, `usePaddingUtility`, `useGapUtility`, `useSpaceUtility`) support **multiplier values** that generate `calc()` expressions:
145+
146+
```ts
147+
import { useMarginUtility, usePaddingUtility, useGapUtility } from '@styleframe/theme';
148+
149+
// Create utility with named values
150+
const createMargin = useMarginUtility(s, {
151+
sm: ref(spacingSm),
152+
md: ref(spacingMd),
153+
});
154+
155+
// Add multiplier values using array syntax (with @ prefix)
156+
createMargin(["@1.5", "@2", "@0.5", "@-1"]);
157+
158+
// Generates:
159+
// ._margin:1.5 { margin: calc(var(--spacing) * 1.5); }
160+
// ._margin:2 { margin: calc(var(--spacing) * 2); }
161+
// ._margin:0.5 { margin: calc(var(--spacing) * 0.5); }
162+
// ._margin:-1 { margin: calc(var(--spacing) * -1); }
163+
```
164+
165+
**Supported multiplier formats (with @ prefix):**
166+
- Integers: `@1`, `@2`, `@3`
167+
- Decimals: `@0.5`, `@1.5`, `@2.25`
168+
- Negative: `@-1`, `@-0.5` (for negative margins)
169+
142170
### modifier(name, factory)
143171

144172
Creates reusable utility modifiers.

.claude/styleframe-patterns.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,41 @@ export function useSpacingUtilities(s: Styleframe) {
9494
}
9595
```
9696

97+
### Spacing Utilities with Multipliers
98+
99+
Use theme composables for spacing utilities with multiplier support:
100+
101+
```ts
102+
import type { Styleframe } from 'styleframe';
103+
import { useSpacing } from '@styleframe/theme';
104+
import { useMarginUtility, usePaddingUtility, useGapUtility } from '@styleframe/theme';
105+
106+
export function useSpacingUtilities(s: Styleframe) {
107+
const { ref } = s;
108+
const { spacing, spacingSm, spacingMd, spacingLg } = useSpacing(s, {
109+
default: '1rem',
110+
sm: '0.5rem',
111+
md: '1rem',
112+
lg: '1.5rem',
113+
} as const);
114+
115+
// Create utilities with named values
116+
const createMargin = useMarginUtility(s, {
117+
sm: ref(spacingSm),
118+
md: ref(spacingMd),
119+
lg: ref(spacingLg),
120+
});
121+
122+
// Add multiplier values for flexible spacing (with @ prefix)
123+
createMargin(["@1.5", "@2", "@0.5", "@-1"]);
124+
125+
// Generates: _margin:sm, _margin:md, _margin:lg (named)
126+
// _margin:1.5, _margin:2, etc. (multipliers with calc())
127+
128+
return { createMargin };
129+
}
130+
```
131+
97132
---
98133

99134
## Complete Design System Setup

.claude/styleframe-recipes.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,36 @@ button({ disabled: true })
147147
|--------------|----------------|-----------------|
148148
| `ref(variable)` | Token path | `_property:token.path` |
149149
| `"@token.path"` | Token path | `_property:token.path` |
150+
| `"@1.5"` (auto-generated) | Multiplier value | `_property:1.5` |
150151
| `"literal"` | Wrapped value | `_property:[literal]` |
151152

153+
### Auto-generated Values in Recipes
154+
155+
Spacing properties (`padding`, `margin`, `gap`) support numeric multiplier values with the `@` prefix:
156+
157+
```ts
158+
recipe({
159+
name: 'card',
160+
base: {
161+
padding: '@1.5', // → _padding:1.5 → calc(var(--spacing) * 1.5)
162+
margin: '@2', // → _margin:2 → calc(var(--spacing) * 2)
163+
gap: '@0.5', // → _gap:0.5 → calc(var(--spacing) * 0.5)
164+
},
165+
variants: {
166+
spacing: {
167+
compact: { padding: '@0.5' },
168+
normal: { padding: '@1' },
169+
relaxed: { padding: '@2' },
170+
},
171+
},
172+
});
173+
```
174+
175+
**Supported formats:**
176+
- Integers: `@1`, `@2`, `@3`
177+
- Decimals: `@0.5`, `@1.5`, `@2.25`
178+
- Negative: `@-1`, `@-0.5` (useful for negative margins)
179+
152180
---
153181

154182
## Variants

.claude/styleframe-tokens.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,28 @@ const { spacingXs, spacingSm, spacingMd, spacingLg, spacingXl } =
9393
});
9494
```
9595

96+
### Spacing Utilities with Multiplier Support
97+
98+
Spacing utilities support multiplier values that generate `calc()` expressions:
99+
100+
```ts
101+
import { useMarginUtility, usePaddingUtility, useGapUtility } from '@styleframe/theme';
102+
103+
// Create utility with named values
104+
const createMargin = useMarginUtility(s, {
105+
sm: ref(spacingSm),
106+
md: ref(spacingMd),
107+
});
108+
109+
// Add multiplier values using array syntax (with @ prefix)
110+
createMargin(["@1.5", "@2", "@0.5", "@-1"]);
111+
112+
// Generates: _margin:1.5, _margin:2, _margin:0.5, _margin:-1
113+
// CSS: calc(var(--spacing) * multiplier)
114+
```
115+
116+
**Note:** Multiplier values require the base `spacing` variable to be defined.
117+
96118
---
97119

98120
### Typography

apps/docs/content/docs/02.api/10.recipes/00.index.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,4 +476,26 @@ recipe({
476476
```
477477
:::
478478

479+
:::accordion-item{label="Can I use auto-generated spacing values in recipes?" icon="i-lucide-circle-help"}
480+
Yes! Spacing properties (`padding`, `margin`, `gap`) support auto-generated values using the `@` prefix with a number. These generate `calc()` expressions based on your `spacing` variable:
481+
482+
```ts [styleframe.config.ts]
483+
recipe({
484+
name: "card",
485+
base: {
486+
padding: "@1.5", // → calc(var(--spacing) * 1.5)
487+
},
488+
variants: {
489+
spacing: {
490+
compact: { padding: "@0.5" },
491+
normal: { padding: "@1" },
492+
relaxed: { padding: "@2" },
493+
},
494+
},
495+
});
496+
```
497+
498+
This allows flexible spacing without pre-defining every value, while keeping proportions consistent with your design system.
499+
:::
500+
479501
::

apps/docs/content/docs/02.api/10.recipes/02.output-format.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Recipe field names (in camelCase) map directly to your defined utilities:
8383

8484
### Value Types and Class Suffixes
8585

86-
There are three ways to specify values in recipes, each producing different class suffixes:
86+
There are four ways to specify values in recipes, each producing different class suffixes:
8787

8888
#### 1. Token References using `ref()`
8989

@@ -122,7 +122,38 @@ recipe({
122122
});
123123
```
124124

125-
#### 3. Arbitrary Values
125+
#### 3. Auto-generated Values
126+
127+
For spacing properties (padding, margin, gap), you can use numeric multiplier values with the `@` prefix. These generate `calc()` expressions based on your `spacing` variable.
128+
129+
```ts [styleframe.config.ts]
130+
recipe({
131+
name: "card",
132+
base: {
133+
padding: "@1.5", // _padding:1.5 → calc(var(--spacing) * 1.5)
134+
margin: "@2", // _margin:2 → calc(var(--spacing) * 2)
135+
gap: "@0.5", // _gap:0.5 → calc(var(--spacing) * 0.5)
136+
},
137+
variants: {
138+
spacing: {
139+
compact: { padding: "@0.5" }, // _padding:0.5
140+
normal: { padding: "@1" }, // _padding:1
141+
relaxed: { padding: "@1.5" }, // _padding:1.5
142+
},
143+
},
144+
});
145+
```
146+
147+
Auto-generated values support:
148+
- **Integers**: `@1`, `@2`, `@3`
149+
- **Decimals**: `@0.5`, `@1.5`, `@2.25`
150+
- **Negative values**: `@-1`, `@-0.5` (useful for negative margins)
151+
152+
::tip
153+
Auto-generated values provide flexibility without pre-defining every spacing value. They're especially useful for one-off adjustments while keeping your spacing proportional to the base `spacing` variable.
154+
::
155+
156+
#### 4. Arbitrary Values
126157

127158
Any value that isn't a token reference is treated as an arbitrary value and wrapped in brackets.
128159

@@ -303,4 +334,24 @@ Examples:
303334

304335
Class generation format can be customized via the instance's utilities selector option. See [Instance - Configuration Options](/docs/api/instance#utilitiesselector) for details.
305336
:::
337+
338+
:::accordion-item{label="How do auto-generated values work in recipes?" icon="i-lucide-circle-help"}
339+
Auto-generated values use the `@` prefix with a numeric value (e.g., `@1.5`, `@2`, `@-1`) for spacing properties like `padding`, `margin`, and `gap`. These generate utility classes that use `calc()` expressions:
340+
341+
```ts
342+
recipe({
343+
name: "card",
344+
base: {
345+
padding: "@1.5", // → _padding:1.5
346+
},
347+
});
348+
```
349+
350+
The generated CSS uses your `--spacing` variable:
351+
```css
352+
._padding\:1\.5 { padding: calc(var(--spacing) * 1.5); }
353+
```
354+
355+
This allows flexible spacing that scales with your design system's base spacing value.
356+
:::
306357
::

apps/docs/content/docs/05.utilities/07.flexbox-grid.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ export default s;
279279

280280
### `useGapUtility`
281281

282-
Set the gap between flex or grid items.
282+
Set the gap between flex or grid items. Gap utilities support both named values and multiplier values.
283283

284284
::tabs
285285
:::tabs-item{icon="i-lucide-code" label="Code"}
@@ -292,19 +292,23 @@ import { useGapUtility, useGapXUtility, useGapYUtility } from "@styleframe/theme
292292
const s = styleframe();
293293
const { ref } = s;
294294

295-
const { spacingSm, spacingMd, spacingLg } = useSpacing(s, {
295+
const { spacing, spacingSm, spacingMd, spacingLg } = useSpacing(s, {
296+
default: '1rem',
296297
sm: '0.5rem',
297298
md: '1rem',
298299
lg: '1.5rem',
299300
} as const);
300301

301-
useGapUtility(s, {
302+
const createGap = useGapUtility(s, {
302303
'0': '0',
303304
sm: ref(spacingSm),
304305
md: ref(spacingMd),
305306
lg: ref(spacingLg),
306307
});
307308

309+
// Add multiplier values for flexible gap sizing (with @ prefix)
310+
createGap(["@1.5", "@2", "@0.5"]);
311+
308312
useGapXUtility(s, {
309313
sm: ref(spacingSm),
310314
md: ref(spacingMd),
@@ -323,6 +327,7 @@ export default s;
323327

324328
```css [styleframe/index.css]
325329
:root {
330+
--spacing: 1rem;
326331
--spacing--sm: 0.5rem;
327332
--spacing--md: 1rem;
328333
--spacing--lg: 1.5rem;
@@ -333,6 +338,11 @@ export default s;
333338
._gap\:md { gap: var(--spacing--md); }
334339
._gap\:lg { gap: var(--spacing--lg); }
335340

341+
/* Multiplier values (with fallback) */
342+
._gap\:1\.5 { gap: calc(var(--spacing, 1rem) * 1.5); }
343+
._gap\:2 { gap: calc(var(--spacing, 1rem) * 2); }
344+
._gap\:0\.5 { gap: calc(var(--spacing, 1rem) * 0.5); }
345+
336346
._gap-x\:sm { column-gap: var(--spacing--sm); }
337347
._gap-x\:md { column-gap: var(--spacing--md); }
338348

@@ -346,6 +356,7 @@ export default s;
346356
```html
347357
<div class="_display:flex _gap:md">Equal gap all around</div>
348358
<div class="_display:grid _gap-x:lg _gap-y:sm">Different horizontal/vertical gaps</div>
359+
<div class="_display:flex _gap:1.5">1.5x base spacing gap</div>
349360
```
350361

351362
:::

0 commit comments

Comments
 (0)