@@ -100,13 +100,17 @@ export class StyleJsonSheet {
100100 * @param {StyleJson } styles The style list to convert
101101 * @returns {string[] } An array of rule strings for the style list
102102 */
103- public getStyleRules ( styles : StyleJson = this . styles ) : string [ ] {
103+ public getStyleRules (
104+ styles : StyleJson = this . styles ,
105+ spaces : string = ''
106+ ) : string [ ] {
104107 const selectors = Object . keys ( styles ) ;
105108 const defs : string [ ] = new Array ( selectors . length ) ;
106109 let i = 0 ;
107110 for ( const selector of selectors ) {
108111 const data = styles [ selector ] ;
109- defs [ i ++ ] = `${ selector } {\n${ this . getStyleDefString ( data ) } \n}` ;
112+ defs [ i ++ ] =
113+ `${ spaces } ${ selector } {\n${ this . getStyleDefString ( data , spaces ) } \n${ spaces } }` ;
110114 }
111115 return defs ;
112116 }
@@ -115,19 +119,25 @@ export class StyleJsonSheet {
115119 * @param {StyleJsonData | StyleJson } styles The style data to be stringified
116120 * @returns {string } The CSS string for the given data
117121 */
118- public getStyleDefString ( styles : StyleJsonData | StyleJson ) : string {
122+ public getStyleDefString (
123+ styles : StyleJsonData | StyleJson ,
124+ spaces : string
125+ ) : string {
119126 const properties = Object . keys ( styles ) ;
120127 const values : string [ ] = new Array ( properties . length ) ;
121128 let i = 0 ;
122129 for ( const property of properties ) {
123130 values [ i ++ ] =
124131 styles [ property ] instanceof Object
125- ? ' ' +
126- this . getStyleRules ( {
127- [ property ] : styles [ property ] ,
128- } as StyleJson ) . join ( '\n ' )
129- : ' ' + property + ': ' + styles [ property ] + ';' ;
132+ ? spaces +
133+ this . getStyleRules (
134+ {
135+ [ property ] : styles [ property ] ,
136+ } as StyleJson ,
137+ spaces + ' '
138+ ) . join ( '\n' + spaces )
139+ : ' ' + spaces + property + ': ' + styles [ property ] + ';' ;
130140 }
131- return values . join ( '\n' ) ;
141+ return values . join ( '\n' + spaces ) ;
132142 }
133143}
0 commit comments