Skip to content

Commit edf7154

Browse files
committed
Fix examples
1 parent 2e7db8d commit edf7154

File tree

1 file changed

+40
-18
lines changed

1 file changed

+40
-18
lines changed

docs-intro/why-tokenscript.md

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -205,36 +205,58 @@ Change `baseSpacing` once → entire scale updates automatically.
205205

206206
**Solution:** Generate programmatically:
207207

208-
<TokenScriptCodeBlock mode="script" showResult={false}>
208+
<TokenScriptCodeBlock mode="script" lines={{ end: 12 }}>
209209
{`variable brand: Color = #0066FF;
210210

211-
variable brand50: Color = lighten(brand, 45);
212-
variable brand100: Color = lighten(brand, 40);
213-
variable brand200: Color = lighten(brand, 30);
214-
// ... compute all 9 shades
215-
variable brand900: Color = darken(brand, 40);`}
211+
variable brand50: Color.Hsl = lighten(brand, 45);
212+
variable brand100: Color.Hsl = lighten(brand, 35);
213+
variable brand200: Color.Hsl = lighten(brand, 25);
214+
variable brand300: Color.Hsl = lighten(brand, 15);
215+
variable brand400: Color.Hsl = lighten(brand, 5);
216+
variable brand500: Color.Hsl = brand.to.hsl();
217+
variable brand600: Color.Hsl = darken(brand, 10);
218+
variable brand700: Color.Hsl = darken(brand, 20);
219+
variable brand800: Color.Hsl = darken(brand, 30);
220+
variable brand900: Color.Hsl = darken(brand, 40);
221+
222+
variable output: Dictionary;
223+
output.set("brand-50", brand50);
224+
output.set("brand-100", brand100);
225+
output.set("brand-200", brand200);
226+
output.set("brand-300", brand300);
227+
output.set("brand-400", brand400);
228+
output.set("brand-500", brand500);
229+
output.set("brand-600", brand600);
230+
output.set("brand-700", brand700);
231+
output.set("brand-800", brand800);
232+
output.set("brand-900", brand900);
233+
234+
return output;
235+
`}
216236
</TokenScriptCodeBlock>
217237

218238
Update brand color once → all shades regenerate.
219239

220-
### Unit Conversion for Multi-Platform
240+
<!-- ### Unit Conversion for Multi-Platform -->
221241

222-
**Problem:** iOS needs `pt`, Android needs `dp`, web needs `px`.
242+
<!-- **Problem:** iOS needs `pt`, Android needs `dp`, web needs `px`. -->
223243

224-
**Solution:** Convert automatically:
244+
<!-- **Solution:** Convert automatically: -->
225245

226-
<TokenScriptCodeBlock mode="script" showResult={false}>
227-
{`variable baseSpacing: NumberWithUnit = 16px;
246+
<!-- <TokenScriptCodeBlock mode="script"> -->
247+
<!-- {`variable baseSpacing: NumberWithUnit = 16px; -->
228248

229-
// For iOS (1pt = 1px on 1x displays)
230-
variable iosSpacing: NumberWithUnit = baseSpacing; // 16pt
249+
<!-- // For iOS (1pt = 1px on 1x displays) -->
250+
<!-- variable iosSpacing: NumberWithUnit = baseSpacing; // 16pt -->
231251

232-
// For Android (1dp ≈ 1px on mdpi)
233-
variable androidSpacing: NumberWithUnit = baseSpacing; // 16dp
252+
<!-- // For Android (1dp ≈ 1px on mdpi) -->
253+
<!-- variable androidSpacing: NumberWithUnit = baseSpacing; // 16dp -->
234254

235-
// Can also do explicit conversions
236-
variable remSpacing: NumberWithUnit = baseSpacing.convertTo("rem", 16); // 1rem`}
237-
</TokenScriptCodeBlock>
255+
<!-- // Can also do explicit conversions -->
256+
<!-- variable remSpacing: NumberWithUnit = baseSpacing; -->
257+
258+
<!-- return iosSpacing, androidSpacing, remSpacing`} -->
259+
<!-- </TokenScriptCodeBlock> -->
238260

239261
## What Can You Build With TokenScript?
240262

0 commit comments

Comments
 (0)