1010 * governing permissions and limitations under the License.
1111 */
1212
13- interface StyleMacroPropertyDefinition {
14- // TODO: unneeded for now
15- type : 'color' | 'mapped' | 'percentage' | 'sizing' | 'arbitrary' ,
16- // Values tied to the property, usually manually defined for now
17- 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
20- additionalTypes ?: string [ ]
21- }
22-
2313// properties that extend from baseColors
2414const baseColorProperties = new Set ( [
2515 'color' , 'backgroundColor' , 'borderColor' , 'outlineColor' , 'fill' , 'stroke'
@@ -40,23 +30,21 @@ const sizingProperties = new Set([
4030 'flexBasis' , 'containIntrinsicWidth' , 'containIntrinsicHeight'
4131] ) ;
4232
43- // manually defined
44- // TODO: maybe spit these up into groups, and have getPropertyDefinitions grab via category name instead
45- const propertyValues : { [ key : string ] : string [ ] } = {
46- // Color
33+
34+ const colorPropertyValues : { [ key : string ] : string [ ] } = {
4735 // This should append baseColors in getPropertyDefinition
4836 outlineColor : [ 'focus-ring' ] ,
4937 // This should append what seems to be a combination of semantic colors and background/global colors
5038 fill : [ 'none' , 'currentColor' ] ,
5139 stroke : [ 'none' , 'currentColor' ] ,
40+ } ;
5241
53-
54- display : [ 'block' , 'inline-block' , 'inline' , 'flex' , 'inline-flex' , 'grid' , 'inline-grid' , 'contents' , 'list-item' , 'none' ] ,
42+ const dimensionsPropertyValues : { [ key : string ] : string [ ] } = {
5543 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' ] ,
5644 height : [ 'auto' , 'full' , 'min' , 'max' , 'fit' , 'screen' ] ,
45+ } ;
5746
58-
59- // text
47+ const textPropertyValues : { [ key : string ] : string [ ] } = {
6048 fontFamily : [ 'sans' , 'serif' , 'code' ] ,
6149 // todo: skipped font-size, font-weight, line height though these will also just be manually defined here
6250 listStyleType : [ 'none' , 'disc' , 'decimal' ] ,
@@ -65,7 +53,6 @@ const propertyValues: {[key: string]: string[]} = {
6553 textAlign : [ 'start' , 'center' , 'end' , 'justify' ] ,
6654 verticalAlign : [ 'baseline' , 'top' , 'middle' , 'bottom' , 'text-top' , 'text-bottom' , 'sub' , 'super' ] ,
6755 textDecoration : [ 'none' , 'underline' , 'overline' , 'line-through' ] ,
68-
6956 textOverflow : [ 'ellipsis' , 'clip' ] ,
7057 lineClamp : [ 'number' ] ,
7158 hyphens : [ 'none' , 'manual' , 'auto' ] ,
@@ -74,52 +61,72 @@ const propertyValues: {[key: string]: string[]} = {
7461 wordBreak : [ 'normal' , 'break-all' , 'keep-all' , 'break-word' ] ,
7562 overflowWrap : [ 'normal' , 'anywhere' , 'break-word' ] ,
7663 boxDecorationBreak : [ 'slice' , 'clone' ] ,
64+ } ;
7765
78- // effects
66+ const effectsPropertyValues : { [ key : string ] : string [ ] } = {
7967 // TODO: should the below have a typelink explaining more details
8068 boxShadow : [ 'emphasized' , 'elevated' , 'dragged' , 'none' ] ,
8169 filter : [ 'emphasized' , 'elevated' , 'dragged' , 'none' ] ,
70+ } ;
71+
72+ const layoutPropertyValues : { [ key : string ] : string [ ] } = {
8273
74+ display : [ 'block' , 'inline-block' , 'inline' , 'flex' , 'inline-flex' , 'grid' , 'inline-grid' , 'contents' , 'list-item' , 'none' ] ,
8375} ;
8476
85- // TODO: will we need something specific for short hand?
86- export function getPropertyDefinition ( propertyName : string ) : StyleMacroPropertyDefinition {
87- const values = propertyValues [ propertyName ] || [ ] ;
77+ const miscPropertyValues : { [ key : string ] : string [ ] } = {
78+
79+ } ;
80+
81+ const shorthandMapping : { [ key : string ] : string [ ] } = {
8882
83+ } ;
84+
85+ const conditionMapping : { [ key : string ] : string [ ] } = {
86+
87+ } ;
88+
89+ const properties : { [ key : string ] : { [ key : string ] : string [ ] } } = {
90+ color : colorPropertyValues ,
91+ dimensions : dimensionsPropertyValues ,
92+ text : textPropertyValues ,
93+ effects : effectsPropertyValues ,
94+ layout : layoutPropertyValues ,
95+ misc : miscPropertyValues
96+ } ;
97+
98+ // TODO: will we need something specific for short hand?
99+ // TODO: see if there are any others that we will need to add additional shared types for
100+ export function getAdditionalTypes ( propertyName : string ) : string [ ] {
89101 if ( baseColorProperties . has ( propertyName ) ) {
90- return {
91- type : 'color' ,
92- values,
93- additionalTypes : [ 'baseColors' ]
94- }
102+ return [ 'baseColors' ]
95103 }
96104
97105 if ( sizingProperties . has ( propertyName ) ) {
98- return {
99- type : 'sizing' ,
100- values,
101- additionalTypes : [ 'number' , 'LengthPercentage' ]
102- } ;
106+ return [ 'number' , 'LengthPercentage' ]
103107 }
104108
105109 if ( percentageProperties . has ( propertyName ) ) {
106- return {
107- type : 'percentage' ,
108- values,
109- additionalTypes : [ 'LengthPercentage' ]
110- } ;
110+ return [ 'LengthPercentage' ]
111111 }
112112
113- return {
114- type : 'mapped' ,
115- values
116- } ;
113+ return [ ] ;
114+ }
115+
116+ interface StyleMacroPropertyDefinition {
117+ values : string [ ] ,
118+ additionalTypes ?: string [ ]
117119}
118120
119- export function getPropertyDefinitions ( propertyNames : string [ ] ) : { [ key : string ] : StyleMacroPropertyDefinition } {
120- const result : { [ key : string ] : StyleMacroPropertyDefinition } = { } ;
121- for ( const name of propertyNames ) {
122- result [ name ] = getPropertyDefinition ( name ) ;
121+ export function getPropertyDefinitions ( propertyCategory : string ) : { [ key : string ] : StyleMacroPropertyDefinition } {
122+ let result : { [ key : string ] : StyleMacroPropertyDefinition } = { } ;
123+ let propertiesMapping = properties [ propertyCategory ] || { } ;
124+
125+ for ( let [ name , values ] of Object . entries ( propertiesMapping ) ) {
126+ result [ name ] = {
127+ values,
128+ additionalTypes : getAdditionalTypes ( name )
129+ }
123130 }
124131 return result ;
125132}
0 commit comments