@onereach/styles 7.1.1 → 7.1.2-beta.4530.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -3
- package/tailwind/utils.js +40 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onereach/styles",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.2-beta.4530.0",
|
|
4
4
|
"description": "Styles for or-ui-next",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"main": "./main.css",
|
|
@@ -58,6 +58,5 @@
|
|
|
58
58
|
},
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
|
-
}
|
|
62
|
-
"gitHead": "bbe6c85a0c79f51774f344a805aeead1f1572223"
|
|
61
|
+
}
|
|
63
62
|
}
|
package/tailwind/utils.js
CHANGED
|
@@ -121,4 +121,44 @@ module.exports = {
|
|
|
121
121
|
[name]: fontWeight,
|
|
122
122
|
}), {});
|
|
123
123
|
},
|
|
124
|
+
|
|
125
|
+
parseColorTokensToVars(designTokens, colorGroups) {
|
|
126
|
+
const prefix = 'or-c';
|
|
127
|
+
const isBackground = (name) => /\b(?:container|background|surface)\b/.test(name) && !isText(name);
|
|
128
|
+
const isText = (name) => /\b(?:on)\b/.test(name);
|
|
129
|
+
const isShadow = (name) => /\b(?:shadow)\b/.test(name);
|
|
130
|
+
|
|
131
|
+
const defineColorGroup = (name) => {
|
|
132
|
+
switch (true) {
|
|
133
|
+
case isBackground(name):
|
|
134
|
+
return 'background';
|
|
135
|
+
|
|
136
|
+
case isText(name):
|
|
137
|
+
return 'text';
|
|
138
|
+
|
|
139
|
+
case isShadow(name):
|
|
140
|
+
return null;
|
|
141
|
+
|
|
142
|
+
default:
|
|
143
|
+
return 'generic';
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
return Object.values(designTokens)
|
|
148
|
+
.map((token) => {
|
|
149
|
+
const { name, theme } = token.name.match(/^(?:(?<theme>light|dark)-)?(?<name>.+)$/).groups;
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
name,
|
|
153
|
+
theme,
|
|
154
|
+
group: defineColorGroup(name),
|
|
155
|
+
color: `var(--${prefix}-${!theme || theme === 'light' ? name : `${name}-${theme}`})`,
|
|
156
|
+
};
|
|
157
|
+
})
|
|
158
|
+
.filter(({ group }) => colorGroups.includes(group))
|
|
159
|
+
.reduce((preset, { name, theme, color }) => ({
|
|
160
|
+
...preset,
|
|
161
|
+
[!theme || theme === 'light' ? name : `${name}-${theme}`]: color,
|
|
162
|
+
}), {});
|
|
163
|
+
},
|
|
124
164
|
};
|