MCPcopy Create free account
hub / github.com/shoutem/theme / StyleNormalizer

Class StyleNormalizer

src/StyleNormalizer/StyleNormalizer.js:11–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9 * specific to properties.
10 */
11export default class StyleNormalizer {
12 constructor() {
13 this.normalizers = {};
14 this.createNormalizers('margin', [HORIZONTAL, VERTICAL, SIDES]);
15 this.createNormalizers('padding', [HORIZONTAL, VERTICAL, SIDES]);
16 }
17
18 createNormalizers(prop, shorthands, suffix = '') {
19 shorthands.forEach(shorthand => {
20 const propName = prop + shorthand.type + suffix;
21
22 if (this.normalizerExists(propName)) {
23 throw Error(`Normalizer for '${propName}' shorthand already exists`);
24 }
25
26 this.normalizers[propName] = ShorthandsNormalizerFactory.createNormalizer(
27 prop,
28 shorthand,
29 suffix,
30 );
31 });
32 }
33
34 normalizerExists(normalizerName) {
35 return !!this.normalizers[normalizerName];
36 }
37
38 canNormalize(prop) {
39 return this.normalizerExists(prop);
40 }
41
42 normalize(prop, val) {
43 return this.normalizers[prop](val);
44 }
45}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected