Skip to content

Commit e86e9b5

Browse files
emilisbethanshar
authored andcommitted
Optimize typography and spacing modifier key patterns (#472)
* Optimize typography and spacing modifier key patterns * Change spacings pattern
1 parent 476b7d4 commit e86e9b5

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/style/spacings.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,19 @@ class Spacings {
1313
s9 = Constants.isIOS ? 27 : 36;
1414
s10 = Constants.isIOS ? 30 : 40;
1515

16+
keysPattern = this.generateKeysPattern();
17+
1618
loadSpacings(spacings) {
1719
_.forEach(spacings, (value, key) => {
1820
this[key] = value;
1921
});
2022
}
2123

2224
getKeysPattern() {
25+
return this.keysPattern;
26+
}
27+
28+
generateKeysPattern() {
2329
return new RegExp(
2430
_.chain(this)
2531
.keys()

src/style/typography.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class Typography {
7575
fontFamily: Constants.isAndroid ? 'sans-serif-light' : undefined,
7676
};
7777

78+
keysPattern = this.generateKeysPattern();
79+
7880
/**
7981
* Load custom set of typographies
8082
* arguments:
@@ -85,9 +87,14 @@ class Typography {
8587
_.forEach(typographies, (value, key) => {
8688
this[key] = value;
8789
});
90+
this.keysPattern = this.generateKeysPattern();
8891
}
8992

9093
getKeysPattern() {
94+
return this.keysPattern;
95+
}
96+
97+
generateKeysPattern() {
9198
return new RegExp(_.chain(this)
9299
.keys()
93100
.map(key => [`${key}`])

0 commit comments

Comments
 (0)