@charcoal-ui/tailwind-config 2.5.0 → 2.6.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.
Files changed (55) hide show
  1. package/dist/_lib/TailwindBuild.d.ts +17 -17
  2. package/dist/_lib/compat.d.ts +13 -13
  3. package/dist/_lib/compat.d.ts.map +1 -1
  4. package/dist/colors/plugin.d.ts +7 -7
  5. package/dist/colors/plugin.test.d.ts +1 -1
  6. package/dist/colors/toTailwindConfig.d.ts +5 -5
  7. package/dist/colors/toTailwindConfig.test.d.ts +1 -1
  8. package/dist/colors/utils.d.ts +6 -6
  9. package/dist/colors/utils.d.ts.map +1 -1
  10. package/dist/docs/borderRadius/BorderRadius.d.ts +2 -2
  11. package/dist/docs/borderRadius/index.d.ts +2 -2
  12. package/dist/docs/colors/Colors.d.ts +2 -2
  13. package/dist/docs/colors/Colors.d.ts.map +1 -1
  14. package/dist/docs/colors/TextBgColor.story.d.ts +26 -26
  15. package/dist/docs/colors/TextBgColor.story.d.ts.map +1 -1
  16. package/dist/docs/colors/TextColors.d.ts +2 -2
  17. package/dist/docs/colors/index.d.ts +3 -3
  18. package/dist/docs/gradient/Gradients.d.ts +2 -2
  19. package/dist/docs/gradient/index.d.ts +9 -9
  20. package/dist/docs/gradient/index.d.ts.map +1 -1
  21. package/dist/docs/gradient/utils.d.ts +1 -1
  22. package/dist/docs/index.d.ts +8 -8
  23. package/dist/docs/index.d.ts.map +1 -1
  24. package/dist/docs/screens/Screens.d.ts +2 -2
  25. package/dist/docs/screens/index.d.ts +2 -2
  26. package/dist/docs/spacing/Spacing.d.ts +2 -2
  27. package/dist/docs/spacing/index.d.ts +2 -2
  28. package/dist/docs/typography/HalfLeading.d.ts +2 -2
  29. package/dist/docs/typography/Sizes.d.ts +2 -2
  30. package/dist/docs/typography/index.d.ts +8 -8
  31. package/dist/docs/typography/index.d.ts.map +1 -1
  32. package/dist/foundation.d.ts +5 -5
  33. package/dist/foundation.d.ts.map +1 -1
  34. package/dist/gradient/plugin.d.ts +18 -18
  35. package/dist/gradient/plugin.d.ts.map +1 -1
  36. package/dist/gradient/plugin.test.d.ts +1 -1
  37. package/dist/index.cjs.js +377 -0
  38. package/dist/index.cjs.js.map +1 -0
  39. package/dist/index.d.ts +9 -9
  40. package/dist/index.esm.js +359 -0
  41. package/dist/index.esm.js.map +1 -0
  42. package/dist/index.test.d.ts +1 -1
  43. package/dist/types.d.ts +29 -29
  44. package/dist/types.d.ts.map +1 -1
  45. package/dist/typography/plugin.d.ts +2 -2
  46. package/dist/util.d.ts +11 -11
  47. package/package.json +16 -16
  48. package/src/docs/colors/Colors.tsx +1 -0
  49. package/src/docs/gradient/index.ts +1 -1
  50. package/dist/index.cjs +0 -488
  51. package/dist/index.cjs.map +0 -1
  52. package/dist/index.modern.js +0 -444
  53. package/dist/index.modern.js.map +0 -1
  54. package/dist/index.module.js +0 -483
  55. package/dist/index.module.js.map +0 -1
@@ -0,0 +1,359 @@
1
+ // src/foundation.ts
2
+ var GRID_COUNT = 12;
3
+ function mergeEffect({
4
+ elementEffect,
5
+ effect
6
+ }) {
7
+ return {
8
+ ...elementEffect,
9
+ ...effect,
10
+ outline: {
11
+ type: "opacity",
12
+ opacity: 0.32
13
+ }
14
+ };
15
+ }
16
+
17
+ // src/util.ts
18
+ function getDefaultKeyName(version) {
19
+ switch (version) {
20
+ case "v3":
21
+ case "v2": {
22
+ return "DEFAULT";
23
+ }
24
+ case "v1": {
25
+ return "default";
26
+ }
27
+ }
28
+ }
29
+ function getVariantOption(version) {
30
+ switch (version) {
31
+ case "v3": {
32
+ return {};
33
+ }
34
+ case "v2":
35
+ case "v1": {
36
+ return { variants: {} };
37
+ }
38
+ }
39
+ }
40
+ function setEquals(a, b) {
41
+ return a.size === b.size && Array.from(a).every((value) => b.has(value));
42
+ }
43
+ function assertAllThemeHaveSameKeys(themeMap) {
44
+ const defaultTheme = themeMap[":root"];
45
+ const expectedColorKeys = new Set(Object.keys(defaultTheme.color));
46
+ const expectedEffectKeys = new Set(Object.keys(defaultTheme.effect));
47
+ for (const [name, theme] of Object.entries(themeMap)) {
48
+ const colorKeys = new Set(Object.keys(theme.color));
49
+ const effectKeys = new Set(Object.keys(theme.effect));
50
+ if (!setEquals(colorKeys, expectedColorKeys)) {
51
+ throw new Error(`:root and ${name} does not have same colors.
52
+
53
+ Expected( :root ): ${JSON.stringify(Array.from(expectedColorKeys))}
54
+ Got: ${JSON.stringify(Array.from(colorKeys))}`);
55
+ }
56
+ if (!setEquals(effectKeys, expectedEffectKeys)) {
57
+ throw new Error(`:root and ${name} does not have same effects.
58
+
59
+ Expected( :root ): ${JSON.stringify(Array.from(expectedEffectKeys))}
60
+ Got: ${JSON.stringify(Array.from(effectKeys))}`);
61
+ }
62
+ }
63
+ }
64
+ function camelToKebab(value) {
65
+ return value.replace(/(?<small>[\da-z]|(?=[A-Z]))(?<capital>[A-Z])/gu, "$1-$2").toLowerCase();
66
+ }
67
+
68
+ // src/index.ts
69
+ import {
70
+ COLUMN_UNIT,
71
+ GUTTER_UNIT,
72
+ SPACING,
73
+ BORDER_RADIUS
74
+ } from "@charcoal-ui/foundation";
75
+ import { light } from "@charcoal-ui/theme";
76
+ import { mapObject as mapObject5, px as px2 } from "@charcoal-ui/utils";
77
+
78
+ // src/colors/toTailwindConfig.ts
79
+ import { applyEffect, filterObject, mapObject } from "@charcoal-ui/utils";
80
+
81
+ // src/colors/utils.ts
82
+ var COLOR_PREFIX = "--tailwind-color-";
83
+ function isSingleColor(color) {
84
+ return typeof color === "string";
85
+ }
86
+
87
+ // src/colors/toTailwindConfig.ts
88
+ function colorsToTailwindConfig(version, colors, effects) {
89
+ const targetColors = filterObject(colors, isSingleColor);
90
+ const DEFAULT = getDefaultKeyName(version);
91
+ function colorsForAllEffects(name, color) {
92
+ const varName = `${COLOR_PREFIX}${name}`;
93
+ return {
94
+ [DEFAULT]: `var(${varName}, ${color})`,
95
+ ...mapObject(effects, (effectName, effect) => [
96
+ effectName,
97
+ `var(${varName}--${effectName}, ${applyEffect(color, effect)})`
98
+ ])
99
+ };
100
+ }
101
+ return mapObject(targetColors, (name, color) => [
102
+ name,
103
+ colorsForAllEffects(name, color)
104
+ ]);
105
+ }
106
+
107
+ // src/colors/plugin.ts
108
+ import {
109
+ applyEffect as applyEffect2,
110
+ filterObject as filterObject2,
111
+ flatMapObject,
112
+ mapObject as mapObject2
113
+ } from "@charcoal-ui/utils";
114
+ import plugin from "tailwindcss/plugin";
115
+ function cssVariableColorPlugin({
116
+ ":root": _defaultTheme,
117
+ ...themes
118
+ }) {
119
+ const definitions = defineCssVariables(themes);
120
+ return plugin(({ addBase }) => {
121
+ addBase(definitions);
122
+ });
123
+ }
124
+ function defineCssVariables(themes) {
125
+ return mapObject2(themes, (selectorOrMediaQuery, theme) => {
126
+ const css = toCssVariables(theme);
127
+ if (selectorOrMediaQuery.startsWith("@media")) {
128
+ return [
129
+ selectorOrMediaQuery,
130
+ {
131
+ ":root": css
132
+ }
133
+ ];
134
+ } else {
135
+ return [selectorOrMediaQuery, css];
136
+ }
137
+ });
138
+ }
139
+ function toCssVariables(theme) {
140
+ const colors = filterObject2(theme.color, isSingleColor);
141
+ const effects = Object.entries(mergeEffect(theme));
142
+ return flatMapObject(colors, (name, color) => {
143
+ const varName = `${COLOR_PREFIX}${name}`;
144
+ return [
145
+ [varName, color],
146
+ ...effects.map(([type, effect]) => [
147
+ `${varName}--${type}`,
148
+ applyEffect2(color, effect)
149
+ ])
150
+ ];
151
+ });
152
+ }
153
+
154
+ // src/gradient/plugin.ts
155
+ import plugin2 from "tailwindcss/plugin";
156
+ import {
157
+ applyEffectToGradient,
158
+ flatMapObject as flatMapObject2,
159
+ gradient,
160
+ mapKeys,
161
+ mapObject as mapObject3
162
+ } from "@charcoal-ui/utils";
163
+ var VAR_PREFIX = "--tailwind-gradient-";
164
+ function cssVariableColorPlugin2(gradients, effects, selectorOrMediaQuery) {
165
+ const utilities = getUtilities(gradients, effects);
166
+ const classRules = mapObject3(utilities, (name) => [
167
+ `.bg-${name}`,
168
+ { backgroundImage: `var(${VAR_PREFIX}${name})` }
169
+ ]);
170
+ return plugin2(({ addBase, addUtilities }) => {
171
+ const css = mapKeys(utilities, (name) => `${VAR_PREFIX}${name}`);
172
+ if (selectorOrMediaQuery.startsWith("@media")) {
173
+ addBase({
174
+ [selectorOrMediaQuery]: {
175
+ ":root": css
176
+ }
177
+ });
178
+ } else {
179
+ addBase({
180
+ [selectorOrMediaQuery]: css
181
+ });
182
+ }
183
+ addUtilities(classRules, {
184
+ variants: ["responsive"]
185
+ });
186
+ });
187
+ }
188
+ var DIRECTIONS = {
189
+ "to top": "top",
190
+ "to bottom": "bottom",
191
+ "to left": "left",
192
+ "to right": "right"
193
+ };
194
+ function getUtilities(gradients, effect) {
195
+ const effects = Object.entries(effect);
196
+ const directions = Object.entries(DIRECTIONS);
197
+ return flatMapObject2(
198
+ gradients,
199
+ (name, colors) => directions.flatMap(([direction, className]) => {
200
+ const toLinearGradient = (colors2) => {
201
+ const style = gradient(direction)(colors2);
202
+ if (!("backgroundImage" in style)) {
203
+ throw new Error(
204
+ `Could not generate linear-gradient() from ${name} ${direction} ${className}`
205
+ );
206
+ }
207
+ return style.backgroundImage;
208
+ };
209
+ return [
210
+ [createUtilityName(name, className), toLinearGradient(colors)],
211
+ ...effects.map(([effectName, effect2]) => [
212
+ createUtilityName(name, className, effectName),
213
+ toLinearGradient(applyEffectToGradient(effect2)(colors))
214
+ ])
215
+ ];
216
+ })
217
+ );
218
+ }
219
+ function createUtilityName(gradientName, direction, suffix = "") {
220
+ return [camelToKebab(gradientName), direction, suffix].filter(Boolean).join("-");
221
+ }
222
+
223
+ // src/typography/plugin.ts
224
+ import plugin3 from "tailwindcss/plugin";
225
+ import { TYPOGRAPHY_SIZE } from "@charcoal-ui/foundation";
226
+ import { halfLeading, mapObject as mapObject4 } from "@charcoal-ui/utils";
227
+ import { px } from "@charcoal-ui/utils";
228
+ var leadingCancel = {
229
+ display: "block",
230
+ width: 0,
231
+ height: 0,
232
+ content: '""'
233
+ };
234
+ var typographyStyle = (style) => {
235
+ const margin = -halfLeading(style);
236
+ return {
237
+ "font-size": px(style.fontSize),
238
+ "line-height": px(style.lineHeight),
239
+ "&::before": {
240
+ ...leadingCancel,
241
+ marginTop: px(margin)
242
+ },
243
+ "&::after": {
244
+ ...leadingCancel,
245
+ marginBottom: px(margin)
246
+ }
247
+ };
248
+ };
249
+ var typographyPlugin = plugin3(({ addUtilities }) => {
250
+ const typographyClasses = mapObject4(TYPOGRAPHY_SIZE, (fontSize, style) => [
251
+ `.typography-${fontSize}`,
252
+ typographyStyle(style)
253
+ ]);
254
+ addUtilities(
255
+ {
256
+ ...typographyClasses,
257
+ ".preserve-half-leading": {
258
+ "&::before": {
259
+ content: "none"
260
+ },
261
+ "&::after": {
262
+ content: "none"
263
+ }
264
+ }
265
+ },
266
+ {
267
+ variants: ["responsive"]
268
+ }
269
+ );
270
+ });
271
+ var plugin_default = typographyPlugin;
272
+
273
+ // src/index.ts
274
+ function createTailwindConfig({
275
+ theme = { ":root": light },
276
+ version = "v3"
277
+ }) {
278
+ assertAllThemeHaveSameKeys(theme);
279
+ const defaultTheme = theme[":root"];
280
+ const effects = mergeEffect(defaultTheme);
281
+ const DEFAULT = getDefaultKeyName(version);
282
+ return {
283
+ theme: {
284
+ screens: {
285
+ screen1: px2(0),
286
+ screen2: px2(defaultTheme.breakpoint.screen1),
287
+ screen3: px2(defaultTheme.breakpoint.screen2),
288
+ screen4: px2(defaultTheme.breakpoint.screen3),
289
+ screen5: px2(defaultTheme.breakpoint.screen4)
290
+ },
291
+ colors: {
292
+ black: "#000",
293
+ white: "#fff",
294
+ transparent: "transparent",
295
+ current: "currentColor",
296
+ ...colorsToTailwindConfig(version, defaultTheme.color, effects)
297
+ },
298
+ borderColor: {
299
+ ...colorsToTailwindConfig(
300
+ version,
301
+ mapObject5(defaultTheme.border, (k, v) => [k, v.color]),
302
+ effects
303
+ )
304
+ },
305
+ spacing: mapObject5(SPACING, (name, pixel) => [name, px2(pixel)]),
306
+ width: {
307
+ full: "100%",
308
+ screen: "100vw",
309
+ auto: "auto",
310
+ fit: "fit-content",
311
+ ...Array.from({ length: GRID_COUNT }, (_, i) => i + 1).reduce(
312
+ (styles, i) => ({
313
+ ...styles,
314
+ [`col-span-${i}`]: px2(COLUMN_UNIT * i + GUTTER_UNIT * (i - 1))
315
+ }),
316
+ {}
317
+ ),
318
+ ...Array.from({ length: GRID_COUNT - 1 }, (_, i) => i + 1).reduce(
319
+ (styles, i) => ({
320
+ ...styles,
321
+ [`${i}/${GRID_COUNT}`]: `${i / GRID_COUNT * 100}%`
322
+ }),
323
+ {}
324
+ )
325
+ },
326
+ gap: {
327
+ fixed: px2(GUTTER_UNIT)
328
+ },
329
+ borderRadius: mapObject5(BORDER_RADIUS, (name, value) => [
330
+ name,
331
+ px2(value)
332
+ ]),
333
+ transitionDuration: {
334
+ [DEFAULT]: "0.2s"
335
+ }
336
+ },
337
+ ...getVariantOption(version),
338
+ corePlugins: {
339
+ lineHeight: false
340
+ },
341
+ plugins: [
342
+ plugin_default,
343
+ cssVariableColorPlugin(theme),
344
+ ...Object.entries(theme).map(
345
+ ([selectorOrMediaQuery, theme2]) => cssVariableColorPlugin2(
346
+ theme2.gradientColor,
347
+ mergeEffect(theme2),
348
+ selectorOrMediaQuery
349
+ )
350
+ )
351
+ ]
352
+ };
353
+ }
354
+ var config = createTailwindConfig({});
355
+ export {
356
+ config,
357
+ createTailwindConfig
358
+ };
359
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/foundation.ts","../src/util.ts","../src/index.ts","../src/colors/toTailwindConfig.ts","../src/colors/utils.ts","../src/colors/plugin.ts","../src/gradient/plugin.ts","../src/typography/plugin.ts"],"sourcesContent":["import { Effect } from '@charcoal-ui/foundation'\nimport { CharcoalTheme as Theme } from '@charcoal-ui/theme'\n\nexport const GRID_COUNT = 12\n\nexport function mergeEffect({\n elementEffect,\n effect,\n}: Pick<Theme, 'elementEffect' | 'effect'>): MergedEffect {\n return {\n ...elementEffect,\n ...effect,\n outline: {\n type: 'opacity',\n opacity: 0.32,\n } as Effect,\n }\n}\n\nexport type MergedEffect = Record<string, Effect>\n","import { TailwindConfig } from 'tailwindcss/tailwind-config'\nimport { TailwindVersion, ThemeMap } from './types'\n\n/**\n * the key \"default\" or \"DEFAULT\" has special meaning and dropped from class name\n *\n * @see https://tailwindcss.com/docs/upgrading-to-v2#update-default-theme-keys-to-default\n */\nexport function getDefaultKeyName(version: TailwindVersion) {\n switch (version) {\n case 'v3':\n case 'v2': {\n return 'DEFAULT'\n }\n\n case 'v1': {\n return 'default'\n }\n }\n}\n\nexport function getVariantOption(\n version: TailwindVersion\n): Partial<TailwindConfig> {\n switch (version) {\n case 'v3': {\n // v3 以上では variants は variantOrders に改名された\n // そしてこれは上書きをしたいモチベがない\n // https://v2.tailwindcss.com/docs/configuration#variant-order\n return {}\n }\n\n case 'v2':\n case 'v1': {\n return { variants: {} }\n }\n }\n}\n\nfunction setEquals<T>(a: Set<T>, b: Set<T>) {\n return a.size === b.size && Array.from(a).every((value) => b.has(value))\n}\n\nexport function assertAllThemeHaveSameKeys(themeMap: ThemeMap): void {\n const defaultTheme = themeMap[':root']\n const expectedColorKeys = new Set(Object.keys(defaultTheme.color))\n const expectedEffectKeys = new Set(Object.keys(defaultTheme.effect))\n\n for (const [name, theme] of Object.entries(themeMap)) {\n const colorKeys = new Set(Object.keys(theme.color))\n const effectKeys = new Set(Object.keys(theme.effect))\n\n if (!setEquals(colorKeys, expectedColorKeys)) {\n throw new Error(`:root and ${name} does not have same colors.\n\nExpected( :root ): ${JSON.stringify(Array.from(expectedColorKeys))}\nGot: ${JSON.stringify(Array.from(colorKeys))}`)\n }\n\n if (!setEquals(effectKeys, expectedEffectKeys)) {\n throw new Error(`:root and ${name} does not have same effects.\n\nExpected( :root ): ${JSON.stringify(Array.from(expectedEffectKeys))}\nGot: ${JSON.stringify(Array.from(effectKeys))}`)\n }\n }\n}\n\nexport function camelToKebab(value: string) {\n return value\n .replace(/(?<small>[\\da-z]|(?=[A-Z]))(?<capital>[A-Z])/gu, '$1-$2')\n .toLowerCase()\n}\n","import { GRID_COUNT, mergeEffect } from './foundation'\n\nimport { TailwindConfig } from 'tailwindcss/tailwind-config'\nimport { TailwindVersion, ThemeMap } from './types'\n\nimport {\n assertAllThemeHaveSameKeys,\n getDefaultKeyName,\n getVariantOption,\n} from './util'\nimport {\n COLUMN_UNIT,\n GUTTER_UNIT,\n SPACING,\n BORDER_RADIUS,\n} from '@charcoal-ui/foundation'\nimport { light } from '@charcoal-ui/theme'\nimport { mapObject, px } from '@charcoal-ui/utils'\nimport { colorsToTailwindConfig } from './colors/toTailwindConfig'\n\nimport cssVariableColorPlugin from './colors/plugin'\nimport cssVariableGradientPlugin from './gradient/plugin'\nimport typographyPlugin from './typography/plugin'\n\ninterface Options {\n version?: TailwindVersion\n theme?: ThemeMap\n}\n\nexport function createTailwindConfig({\n theme = { ':root': light },\n version = 'v3',\n}: Options): TailwindConfig {\n assertAllThemeHaveSameKeys(theme)\n\n const defaultTheme = theme[':root']\n const effects = mergeEffect(defaultTheme)\n const DEFAULT = getDefaultKeyName(version)\n\n return {\n theme: {\n screens: {\n screen1: px(0),\n screen2: px(defaultTheme.breakpoint.screen1),\n screen3: px(defaultTheme.breakpoint.screen2),\n screen4: px(defaultTheme.breakpoint.screen3),\n screen5: px(defaultTheme.breakpoint.screen4),\n },\n colors: {\n // @deprecated\n black: '#000',\n\n // @deprecated\n white: '#fff',\n\n transparent: 'transparent',\n current: 'currentColor',\n ...colorsToTailwindConfig(version, defaultTheme.color, effects),\n },\n borderColor: {\n ...colorsToTailwindConfig(\n version,\n mapObject(defaultTheme.border, (k, v) => [k, v.color]),\n effects\n ),\n },\n spacing: mapObject(SPACING, (name, pixel) => [name, px(pixel)]),\n width: {\n full: '100%',\n screen: '100vw',\n auto: 'auto',\n fit: 'fit-content',\n\n /**\n * generates classes like \"w-col-span-1\"\n */\n ...Array.from({ length: GRID_COUNT }, (_, i) => i + 1).reduce(\n (styles, i) => ({\n ...styles,\n [`col-span-${i}`]: px(COLUMN_UNIT * i + GUTTER_UNIT * (i - 1)),\n }),\n {}\n ),\n\n /**\n * generates classes like \"w-1/12\" (except for 12/12, which just equals to w-full)\n */\n ...Array.from({ length: GRID_COUNT - 1 }, (_, i) => i + 1).reduce(\n (styles, i) => ({\n ...styles,\n [`${i}/${GRID_COUNT}`]: `${(i / GRID_COUNT) * 100}%`,\n }),\n {}\n ),\n },\n gap: {\n fixed: px(GUTTER_UNIT),\n },\n borderRadius: mapObject(BORDER_RADIUS, (name, value) => [\n name,\n px(value),\n ]),\n transitionDuration: {\n [DEFAULT]: '0.2s',\n },\n },\n\n ...getVariantOption(version),\n\n corePlugins: {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-expect-error 配列にしろと言ってくるが、たぶん @types が間違っている\n lineHeight: false,\n },\n plugins: [\n typographyPlugin,\n cssVariableColorPlugin(theme),\n\n ...Object.entries(theme).map(([selectorOrMediaQuery, theme]) =>\n cssVariableGradientPlugin(\n theme.gradientColor,\n mergeEffect(theme),\n selectorOrMediaQuery\n )\n ),\n ],\n }\n}\n\nexport const config: TailwindConfig = createTailwindConfig({})\n","import { Material } from '@charcoal-ui/foundation'\nimport { applyEffect, filterObject, mapObject } from '@charcoal-ui/utils'\nimport { TailwindConfig } from 'tailwindcss/tailwind-config'\nimport { MergedEffect } from '../foundation'\n\nimport { TailwindVersion } from '../types'\nimport { getDefaultKeyName } from '../util'\n\nimport { AnyColorTheme, COLOR_PREFIX, isSingleColor } from './utils'\n\nexport function colorsToTailwindConfig(\n version: TailwindVersion,\n colors: AnyColorTheme,\n effects: MergedEffect\n): TailwindConfig['theme']['colors'] {\n const targetColors = filterObject(colors, isSingleColor)\n const DEFAULT = getDefaultKeyName(version)\n\n /**\n * こういう感じのを吐き出す\n *\n * ```js\n * {\n * DEFAULT: 'var(--tailwind-color-hoge1, #fff)',\n * hover: 'var(--tailwind-color-hoge1--hover, #eee)',\n * press: 'var(--tailwind-color-hoge1--press, #ddd)',\n * disabled: 'var(--tailwind-color-hoge1--disabled, #eee)',\n * }\n * ```\n */\n function colorsForAllEffects(name: string, color: Material) {\n const varName = `${COLOR_PREFIX}${name}`\n\n return {\n [DEFAULT]: `var(${varName}, ${color})`,\n\n ...mapObject(effects, (effectName, effect) => [\n effectName,\n `var(${varName}--${effectName}, ${applyEffect(color, effect)})`,\n ]),\n }\n }\n\n return mapObject(targetColors, (name, color) => [\n name,\n colorsForAllEffects(name, color),\n ])\n}\n","import { GradientMaterial, Material } from '@charcoal-ui/foundation'\n\nexport const COLOR_PREFIX = '--tailwind-color-'\n\nexport function isSingleColor(color: AnyColor): color is Material {\n return typeof color === 'string'\n}\n\ntype AnyColor = Material | GradientMaterial\n\nexport type AnyColorTheme = Record<string, AnyColor>\n","import { Material } from '@charcoal-ui/foundation'\nimport { CharcoalTheme as Theme } from '@charcoal-ui/theme'\nimport {\n applyEffect,\n filterObject,\n flatMapObject,\n mapObject,\n} from '@charcoal-ui/utils'\nimport plugin, { TailwindPlugin } from 'tailwindcss/plugin'\nimport { mergeEffect } from '../foundation'\nimport { CSSVariableName, CSSVariables, Definition, ThemeMap } from '../types'\nimport { COLOR_PREFIX, isSingleColor } from './utils'\n\n/**\n * `:root` 以外のケースで各 CSS Variable がどういう値を取るかを定義する\n */\nexport default function cssVariableColorPlugin({\n ':root': _defaultTheme,\n ...themes\n}: ThemeMap): TailwindPlugin {\n const definitions = defineCssVariables(themes)\n\n return plugin(({ addBase }) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n addBase(definitions)\n })\n}\n\nexport function defineCssVariables(themes: Omit<ThemeMap, ':root'>) {\n return mapObject(themes, (selectorOrMediaQuery, theme) => {\n const css = toCssVariables(theme)\n\n if (selectorOrMediaQuery.startsWith('@media')) {\n return [\n selectorOrMediaQuery,\n {\n ':root': css,\n },\n ]\n } else {\n return [selectorOrMediaQuery, css]\n }\n }) as Definition\n}\n\nfunction toCssVariables(theme: Theme): CSSVariables {\n const colors = filterObject(theme.color, isSingleColor)\n const effects = Object.entries(mergeEffect(theme))\n\n return flatMapObject(colors, (name, color) => {\n const varName: keyof CSSVariables = `${COLOR_PREFIX}${name}`\n\n return [\n [varName, color],\n\n ...effects.map<[CSSVariableName, Material]>(([type, effect]) => [\n `${varName}--${type}`,\n applyEffect(color, effect),\n ]),\n ]\n })\n}\n","import plugin from 'tailwindcss/plugin'\nimport { camelToKebab } from '../util'\nimport { GradientMaterial } from '@charcoal-ui/foundation'\nimport { ThemeColorGradient } from '@charcoal-ui/theme'\nimport {\n applyEffectToGradient,\n flatMapObject,\n gradient,\n GradientDirection,\n mapKeys,\n mapObject,\n} from '@charcoal-ui/utils'\nimport { Values } from '../types'\nimport { MergedEffect } from '../foundation'\n\nconst VAR_PREFIX = '--tailwind-gradient-'\n\nexport default function cssVariableColorPlugin(\n gradients: ThemeColorGradient,\n effects: MergedEffect,\n selectorOrMediaQuery: string\n) {\n const utilities = getUtilities(gradients, effects)\n\n const classRules = mapObject(utilities, (name) => [\n `.bg-${name}`,\n { backgroundImage: `var(${VAR_PREFIX}${name})` },\n ])\n\n return plugin(({ addBase, addUtilities }) => {\n const css = mapKeys(utilities, (name) => `${VAR_PREFIX}${name}`)\n if (selectorOrMediaQuery.startsWith('@media')) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n addBase({\n [selectorOrMediaQuery]: {\n ':root': css,\n },\n })\n } else {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n addBase({\n [selectorOrMediaQuery]: css,\n })\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n addUtilities(classRules, {\n variants: ['responsive'],\n })\n })\n}\n\nconst DIRECTIONS = {\n 'to top': 'top',\n 'to bottom': 'bottom',\n 'to left': 'left',\n 'to right': 'right',\n} as const\n\n/**\n * こういう感じのやつ。この時点では `--tailwind-gradient-` のような CSS 変数名になってない\n *\n * ```js\n * {\n * 'hoge1': 'linear-gradient(to top, ...)',\n * ...\n * }\n * ```\n */\ntype Utilities = Record<string, LinearGradient>\n\ntype LinearGradient = `linear-gradient(${string})`\n\nexport function getUtilities(\n gradients: Record<string, GradientMaterial>,\n effect: MergedEffect\n): Utilities {\n const effects = Object.entries(effect)\n const directions = Object.entries(DIRECTIONS) as [\n GradientDirection,\n Values<typeof DIRECTIONS>\n ][]\n\n return flatMapObject(gradients, (name, colors) =>\n directions.flatMap(([direction, className]) => {\n const toLinearGradient = (colors: GradientMaterial) => {\n const style = gradient(direction)(colors)\n\n if (!('backgroundImage' in style)) {\n throw new Error(\n `Could not generate linear-gradient() from ${name} ${direction} ${className}`\n )\n }\n\n // 本当は backgroundColor も同時に生成されるんだけど、使うにはそれ用の CSS 変数も一緒に作らないといけない\n // とりあえず background-image だけで動くのでこっちだけを利用する\n return style.backgroundImage as LinearGradient\n }\n\n return [\n // こういう感じのやつ\n // { 'hoge1': 'linear-gradienr(to top, ...)' }\n [createUtilityName(name, className), toLinearGradient(colors)],\n\n // こういう感じのやつ\n // { 'hoge1--hover': 'linear-gradienr(to top, ...)' }\n ...effects.map<[string, LinearGradient]>(([effectName, effect]) => [\n createUtilityName(name, className, effectName),\n toLinearGradient(applyEffectToGradient(effect)(colors)),\n ]),\n ]\n })\n )\n}\n\nfunction createUtilityName(\n gradientName: string,\n direction: Values<typeof DIRECTIONS>,\n suffix = ''\n) {\n return [camelToKebab(gradientName), direction, suffix]\n .filter(Boolean)\n .join('-')\n}\n","import plugin from 'tailwindcss/plugin'\nimport { TypographyDescriptor, TYPOGRAPHY_SIZE } from '@charcoal-ui/foundation'\nimport { halfLeading, mapObject } from '@charcoal-ui/utils'\nimport { px } from '@charcoal-ui/utils'\n\nconst leadingCancel = {\n display: 'block',\n width: 0,\n height: 0,\n content: '\"\"',\n}\n\nconst typographyStyle = (style: TypographyDescriptor) => {\n const margin = -halfLeading(style)\n\n return {\n 'font-size': px(style.fontSize),\n 'line-height': px(style.lineHeight),\n\n /**\n * cancel leading\n *\n * @see https://yuyakinoshita.com/blog/2020/01/20/line-height-crop/\n */\n '&::before': {\n ...leadingCancel,\n marginTop: px(margin),\n },\n '&::after': {\n ...leadingCancel,\n marginBottom: px(margin),\n },\n }\n}\n\nconst typographyPlugin = plugin(({ addUtilities }) => {\n const typographyClasses = mapObject(TYPOGRAPHY_SIZE, (fontSize, style) => [\n `.typography-${fontSize}`,\n typographyStyle(style),\n ])\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n addUtilities(\n {\n ...typographyClasses,\n '.preserve-half-leading': {\n '&::before': {\n content: 'none',\n },\n '&::after': {\n content: 'none',\n },\n },\n },\n {\n variants: ['responsive'],\n }\n )\n})\n\nexport default typographyPlugin\n"],"mappings":";AAGO,IAAM,aAAa;AAEnB,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AACF,GAA0D;AACxD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,GAAG;AAAA,IACH,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AACF;;;ACTO,SAAS,kBAAkB,SAA0B;AAC1D,UAAQ,SAAS;AAAA,IACf,KAAK;AAAA,IACL,KAAK,MAAM;AACT,aAAO;AAAA,IACT;AAAA,IAEA,KAAK,MAAM;AACT,aAAO;AAAA,IACT;AAAA,EACF;AACF;AAEO,SAAS,iBACd,SACyB;AACzB,UAAQ,SAAS;AAAA,IACf,KAAK,MAAM;AAIT,aAAO,CAAC;AAAA,IACV;AAAA,IAEA,KAAK;AAAA,IACL,KAAK,MAAM;AACT,aAAO,EAAE,UAAU,CAAC,EAAE;AAAA,IACxB;AAAA,EACF;AACF;AAEA,SAAS,UAAa,GAAW,GAAW;AAC1C,SAAO,EAAE,SAAS,EAAE,QAAQ,MAAM,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,KAAK,CAAC;AACzE;AAEO,SAAS,2BAA2B,UA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C,GAAG,MAAM,IAAI,CAAC,EAAE;AAAA,UACrD,CAAC,QAAQ,OAAO;AAAA,YACd,GAAG;AAAA,YACH,CAAC,YAAY,MAAMA,IAAG,cAAc,IAAI,eAAe,IAAI,EAAE;AAAA,UAC/D;AAAA,UACA,CAAC;AAAA,QACH;AAAA,QAKA,GAAG,MAAM,KAAK,EAAE,QAAQ,aAAa,EAAE,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,EAAE;AAAA,UACzD,CAAC,QAAQ,OAAO;AAAA,YACd,GAAG;AAAA,YACH,CAAC,GAAG,KAAK,eAAe,GAAI,IAAI,aAAc;AAAA,UAChD;AAAA,UACA,CAAC;AAAA,QACH;AAAA,MACF;AAAA,MACA,KAAK;AAAA,QACH,OAAOA,IAAG,WAAW;AAAA,MACvB;AAAA,MACA,cAAcC,WAAU,eAAe,CAAC,MAAM,UAAU;AAAA,QACtD;AAAA,QACAD,IAAG,KAAK;AAAA,MACV,CAAC;AAAA,MACD,oBAAoB;AAAA,QAClB,CAAC,UAAU;AAAA,MACb;AAAA,IACF;AAAA,IAEA,GAAG,iBAAiB,OAAO;AAAA,IAE3B,aAAa;AAAA,MAGX,YAAY;AAAA,IACd;AAAA,IACA,SAAS;AAAA,MACP;AAAA,MACA,uBAAuB,KAAK;AAAA,MAE5B,GAAG,OAAO,QAAQ,KAAK,EAAE;AAAA,QAAI,CAAC,CAAC,sBAAsBE,MAAK,MACxDC;AAAA,UACED,OAAM;AAAA,UACN,YAAYA,MAAK;AAAA,UACjB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,SAAyB,qBAAqB,CAAC,CAAC;","names":["mapObject","px","applyEffect","filterObject","mapObject","mapObject","filterObject","applyEffect","plugin","flatMapObject","mapObject","cssVariableColorPlugin","plugin","colors","effect","plugin","mapObject","px","mapObject","theme","cssVariableColorPlugin"]}
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=index.test.d.ts.map
package/dist/types.d.ts CHANGED
@@ -1,30 +1,30 @@
1
- import { Material } from '@charcoal-ui/foundation';
2
- import { CharcoalTheme as Theme } from '@charcoal-ui/theme';
3
- export declare type TailwindVersion = 'v1' | 'v2' | 'v3';
4
- export interface ThemeMap {
5
- ':root': Theme;
6
- [mediaQuery: `@media (${string})`]: Theme;
7
- [selector: string]: Theme;
8
- }
9
- export declare type Values<T extends object> = T[keyof T];
10
- export declare type Definition = {
11
- [mediaQuery: `@media${string}`]: {
12
- ':root': CSSVariables;
13
- };
14
- [selector: string]: CSSVariables;
15
- };
16
- export declare type CSSVariableName = `--tailwind-${string}`;
17
- /**
18
- * こういう感じのやつ
19
- *
20
- * ```js
21
- * {
22
- * '--tailwind-color-hoge1': '#ffffff',
23
- * '--tailwind-color-hoge1--hover': '#eeeeee',
24
- * '--tailwind-color-hoge1--press': '#dddddd',
25
- * ...
26
- * }
27
- * ```
28
- */
29
- export declare type CSSVariables = Record<CSSVariableName, Material>;
1
+ import { Material } from '@charcoal-ui/foundation';
2
+ import { CharcoalTheme as Theme } from '@charcoal-ui/theme';
3
+ export type TailwindVersion = 'v1' | 'v2' | 'v3';
4
+ export interface ThemeMap {
5
+ ':root': Theme;
6
+ [mediaQuery: `@media (${string})`]: Theme;
7
+ [selector: string]: Theme;
8
+ }
9
+ export type Values<T extends object> = T[keyof T];
10
+ export type Definition = {
11
+ [mediaQuery: `@media${string}`]: {
12
+ ':root': CSSVariables;
13
+ };
14
+ [selector: string]: CSSVariables;
15
+ };
16
+ export type CSSVariableName = `--tailwind-${string}`;
17
+ /**
18
+ * こういう感じのやつ
19
+ *
20
+ * ```js
21
+ * {
22
+ * '--tailwind-color-hoge1': '#ffffff',
23
+ * '--tailwind-color-hoge1--hover': '#eeeeee',
24
+ * '--tailwind-color-hoge1--press': '#dddddd',
25
+ * ...
26
+ * }
27
+ * ```
28
+ */
29
+ export type CSSVariables = Record<CSSVariableName, Material>;
30
30
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE3D,oBAAY,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAEhD,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,KAAK,CAAA;IACd,CAAC,UAAU,EAAE,WAAW,MAAM,GAAG,GAAG,KAAK,CAAA;IACzC,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAA;CAC1B;AAED,oBAAY,MAAM,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAEjD,oBAAY,UAAU,GAAG;IACvB,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG;QAAE,OAAO,EAAE,YAAY,CAAA;KAAE,CAAA;IAC1D,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAAA;CACjC,CAAA;AAED,oBAAY,eAAe,GAAG,cAAc,MAAM,EAAE,CAAA;AAEpD;;;;;;;;;;;GAWG;AACH,oBAAY,YAAY,GAAG,MAAM,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAClD,OAAO,EAAE,aAAa,IAAI,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAE3D,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;AAEhD,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,KAAK,CAAA;IACd,CAAC,UAAU,EAAE,WAAW,MAAM,GAAG,GAAG,KAAK,CAAA;IACzC,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAA;CAC1B;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAEjD,MAAM,MAAM,UAAU,GAAG;IACvB,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,GAAG;QAAE,OAAO,EAAE,YAAY,CAAA;KAAE,CAAA;IAC1D,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAAA;CACjC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,cAAc,MAAM,EAAE,CAAA;AAEpD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAA"}
@@ -1,3 +1,3 @@
1
- declare const typographyPlugin: import("tailwindcss/plugin").TailwindPlugin;
2
- export default typographyPlugin;
1
+ declare const typographyPlugin: import("tailwindcss/plugin").TailwindPlugin;
2
+ export default typographyPlugin;
3
3
  //# sourceMappingURL=plugin.d.ts.map
package/dist/util.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { TailwindConfig } from 'tailwindcss/tailwind-config';
2
- import { TailwindVersion, ThemeMap } from './types';
3
- /**
4
- * the key "default" or "DEFAULT" has special meaning and dropped from class name
5
- *
6
- * @see https://tailwindcss.com/docs/upgrading-to-v2#update-default-theme-keys-to-default
7
- */
8
- export declare function getDefaultKeyName(version: TailwindVersion): "DEFAULT" | "default";
9
- export declare function getVariantOption(version: TailwindVersion): Partial<TailwindConfig>;
10
- export declare function assertAllThemeHaveSameKeys(themeMap: ThemeMap): void;
11
- export declare function camelToKebab(value: string): string;
1
+ import { TailwindConfig } from 'tailwindcss/tailwind-config';
2
+ import { TailwindVersion, ThemeMap } from './types';
3
+ /**
4
+ * the key "default" or "DEFAULT" has special meaning and dropped from class name
5
+ *
6
+ * @see https://tailwindcss.com/docs/upgrading-to-v2#update-default-theme-keys-to-default
7
+ */
8
+ export declare function getDefaultKeyName(version: TailwindVersion): "DEFAULT" | "default";
9
+ export declare function getVariantOption(version: TailwindVersion): Partial<TailwindConfig>;
10
+ export declare function assertAllThemeHaveSameKeys(themeMap: ThemeMap): void;
11
+ export declare function camelToKebab(value: string): string;
12
12
  //# sourceMappingURL=util.d.ts.map
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
2
  "name": "@charcoal-ui/tailwind-config",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "license": "Apache-2.0",
5
- "type": "module",
6
- "source": "./src/index.ts",
7
- "main": "./dist/index.cjs",
8
- "module": "./dist/index.module.js",
5
+ "main": "./dist/index.cjs.js",
6
+ "module": "./dist/index.esm.js",
9
7
  "exports": {
10
- "require": "./dist/index.cjs",
11
- "default": "./dist/index.modern.js"
8
+ "require": "./dist/index.cjs.js",
9
+ "default": "./dist/index.esm.js"
12
10
  },
13
11
  "types": "./dist/index.d.ts",
14
12
  "sideEffects": false,
15
13
  "scripts": {
16
- "build": "microbundle --compress=false -f modern,esm,cjs --tsconfig tsconfig.build.json",
17
- "typecheck": "tsc --noEmit --project tsconfig.build.json",
18
- "clean": "rimraf dist"
14
+ "build": "run-p --print-label 'build:*'",
15
+ "build:bundle": "FORCE_COLOR=1 tsup",
16
+ "build:dts": "tsc --project tsconfig.build.json --pretty --emitDeclarationOnly",
17
+ "typecheck": "tsc --project tsconfig.build.json --pretty --noEmit",
18
+ "clean": "rimraf dist .tsbuildinfo"
19
19
  },
20
20
  "devDependencies": {
21
- "microbundle": "^0.14.2",
22
21
  "postcss": "^8.4.5",
23
22
  "postcss-selector-parser": "^6.0.9",
24
23
  "react": "^18.0.0",
25
24
  "rimraf": "^3.0.2",
26
25
  "tailwindcss": "^3.0.5",
27
- "typescript": "^4.5.5"
26
+ "tsup": "^6.5.0",
27
+ "typescript": "^4.9.5"
28
28
  },
29
29
  "dependencies": {
30
- "@charcoal-ui/foundation": "^2.5.0",
31
- "@charcoal-ui/theme": "^2.5.0",
32
- "@charcoal-ui/utils": "^2.5.0"
30
+ "@charcoal-ui/foundation": "^2.6.0",
31
+ "@charcoal-ui/theme": "^2.6.0",
32
+ "@charcoal-ui/utils": "^2.6.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "csstype": ">=3.0.0",
@@ -48,5 +48,5 @@
48
48
  "url": "https://github.com/pixiv/charcoal.git",
49
49
  "directory": "packages/tailwind-config"
50
50
  },
51
- "gitHead": "f2d6f530bbc4467e9205a4e70ce65a57372860a8"
51
+ "gitHead": "8579b406b316285a35858512030d2143524ae154"
52
52
  }
@@ -65,6 +65,7 @@ export const Colors: React.FC = () => {
65
65
  {Object.keys(effectTypes).map((modifier) =>
66
66
  modifier in values ? (
67
67
  <ColorBox
68
+ key={modifier}
68
69
  bgColorClass={`bg-${colorName}-${modifier}`}
69
70
  label={`-${modifier}`}
70
71
  />
@@ -16,7 +16,7 @@ const gradientPlugin: TailwindPlugin = config.plugins
16
16
  export const utilityClasses = getUtilities(gradientPlugin)
17
17
 
18
18
  export const directions = ['top', 'bottom', 'right', 'left'] as const
19
- export type Direction = typeof directions[number]
19
+ export type Direction = (typeof directions)[number]
20
20
 
21
21
  export type { EffectType }
22
22
  export const effectTypes: { [type in EffectType]: null } = {