@@ -11,7 +11,7 @@ interface ExtractedToken {
11
11
/** Full prefix of the token. */
12
12
prefix : string ;
13
13
/** Type of the token (color, typography etc.) */
14
- type : string ;
14
+ type : 'color' | 'typography' | 'density' | 'base' ;
15
15
/** Value of the token. */
16
16
value : string | number ;
17
17
/** Name under which the token can be referred to inside the `overrides` mixin. */
@@ -25,7 +25,7 @@ interface Token {
25
25
/** Full prefix of the token. */
26
26
prefix : string ;
27
27
/** Type of the token (color, typography etc.) */
28
- type : string ;
28
+ type : 'color' | 'typography' | 'density' | 'base' ;
29
29
/** Name under which the token can be referred to inside the `overrides` mixin. */
30
30
overridesName : string ;
31
31
/** Name of the system-level token that this token was derived from. */
@@ -172,8 +172,8 @@ function getUsageExample(themes: ThemeData[]): string | null {
172
172
`// Customize the entire app. Change :root to your selector if you want to scope the styles.` ,
173
173
`:root {` ,
174
174
` @include mat.${ mixin . overridesMixin } ((` ,
175
- ` ${ firstToken . overridesName } : orange ,` ,
176
- ...( secondToken ? [ ` ${ secondToken . overridesName } : red ,` ] : [ ] ) ,
175
+ ` ${ getTokenExample ( firstToken , 'first' ) } ,` ,
176
+ ...( secondToken ? [ ` ${ getTokenExample ( secondToken , 'second' ) } ,` ] : [ ] ) ,
177
177
` ));` ,
178
178
`}` ,
179
179
] ;
@@ -350,6 +350,30 @@ function jsonStringifyImplementation(
350
350
` ;
351
351
}
352
352
353
+ /** Generates an example string for a token. */
354
+ function getTokenExample ( token : Token , position : 'first' | 'second' ) : string {
355
+ const name = token . overridesName ;
356
+ let value : string ;
357
+
358
+ // Attempt to come up with a real-looking example based on the token's shape.
359
+ if ( name . includes ( 'shape' ) ) {
360
+ value = position === 'first' ? '12px' : '16px' ;
361
+ } else if ( name . includes ( 'opacity' ) ) {
362
+ value = position === 'first' ? '0.8' : '0.2' ;
363
+ } else if ( name . includes ( 'size' ) ) {
364
+ value = position === 'first' ? '16px' : '10px' ;
365
+ } else if ( name . includes ( 'shadow' ) ) {
366
+ value =
367
+ position === 'first'
368
+ ? '10px 10px 5px 0px rgba(0, 0, 0, 0.75)'
369
+ : '-4px -4px 5px 0px rgba(0, 0, 0, 0.5)' ;
370
+ } else {
371
+ value = position === 'first' ? 'orange' : 'red' ;
372
+ }
373
+
374
+ return `${ name } : ${ value } ` ;
375
+ }
376
+
353
377
/**
354
378
* Gets the substring between two strings.
355
379
* @param text String from which to extract the substring.
0 commit comments