@charcoal-ui/tailwind-config 4.0.1 → 4.2.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/README.md +20 -3
- package/dist/_lib/TailwindBuild.d.ts +2 -2
- package/dist/_lib/TailwindBuild.d.ts.map +1 -1
- package/dist/colors/plugin.d.ts +2 -2
- package/dist/colors/plugin.d.ts.map +1 -1
- package/dist/colors/toTailwindConfig.d.ts +2 -2
- package/dist/colors/toTailwindConfig.d.ts.map +1 -1
- package/dist/docs/borderRadius/index.d.ts +1 -1
- package/dist/docs/borderRadius/index.d.ts.map +1 -1
- package/dist/docs/colors/Colors.d.ts.map +1 -1
- package/dist/docs/colors/index.d.ts +1 -1
- package/dist/docs/colors/index.d.ts.map +1 -1
- package/dist/docs/screens/index.d.ts +1 -1
- package/dist/docs/screens/index.d.ts.map +1 -1
- package/dist/docs/spacing/index.d.ts +1 -1
- package/dist/docs/spacing/index.d.ts.map +1 -1
- package/dist/gradient/plugin.d.ts +4 -1
- package/dist/gradient/plugin.d.ts.map +1 -1
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/tokenV2.d.ts +1 -2
- package/dist/tokenV2.d.ts.map +1 -1
- package/dist/typography/plugin.d.ts +4 -1
- package/dist/typography/plugin.d.ts.map +1 -1
- package/dist/util.d.ts +2 -2
- package/dist/util.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/Custom.mdx +1 -1
- package/src/README.mdx +18 -1
- package/src/__snapshots__/index.test.ts.snap +3212 -1960
- package/src/__snapshots__/tokenV2.test.ts.snap +4814 -3784
- package/src/_lib/TailwindBuild.ts +2 -3
- package/src/colors/plugin.ts +3 -4
- package/src/colors/toTailwindConfig.ts +2 -2
- package/src/docs/borderRadius/index.ts +2 -1
- package/src/docs/colors/Colors.tsx +1 -0
- package/src/gradient/plugin.ts +1 -3
- package/src/index.test.ts +1 -0
- package/src/index.ts +6 -5
- package/src/tokenV2.test.ts +1 -0
- package/src/tokenV2.ts +3 -8
- package/src/typography/plugin.ts +1 -1
- package/src/util.ts +2 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import postcss, { Result } from 'postcss'
|
|
2
2
|
import postcssSelectorParser from 'postcss-selector-parser'
|
|
3
3
|
import tailwindcss from 'tailwindcss'
|
|
4
|
-
import type {
|
|
4
|
+
import type { Config } from 'tailwindcss'
|
|
5
5
|
|
|
6
6
|
const selectorParser = postcssSelectorParser()
|
|
7
7
|
|
|
@@ -45,11 +45,10 @@ export class TailwindBuild {
|
|
|
45
45
|
this.parsedCss = parsedCss
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
static async run(config:
|
|
48
|
+
static async run(config: Config, css: string) {
|
|
49
49
|
const plugin = tailwindcss({
|
|
50
50
|
...config,
|
|
51
51
|
|
|
52
|
-
// @ts-expect-error safelist が @types/tailwindcss に生えてない
|
|
53
52
|
safelist: [
|
|
54
53
|
{
|
|
55
54
|
// 一切 purge しない
|
package/src/colors/plugin.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
flatMapObject,
|
|
7
7
|
mapObject,
|
|
8
8
|
} from '@charcoal-ui/utils'
|
|
9
|
-
import plugin
|
|
9
|
+
import plugin from 'tailwindcss/plugin'
|
|
10
10
|
import { mergeEffect } from '../foundation'
|
|
11
11
|
import { CSSVariableName, CSSVariables, Definition, ThemeMap } from '../types'
|
|
12
12
|
import { COLOR_PREFIX, isSingleColor } from './utils'
|
|
@@ -19,19 +19,18 @@ import { defineCssVariablesV1 } from './pluginTokenV1'
|
|
|
19
19
|
export default function cssVariableColorPlugin(
|
|
20
20
|
themeMap: ThemeMap,
|
|
21
21
|
cssVariablesV1: boolean
|
|
22
|
-
):
|
|
22
|
+
): ReturnType<typeof plugin> {
|
|
23
23
|
// `:root` 以外のケースで各 CSS Variable がどういう値を取るかを定義する
|
|
24
24
|
const { ':root': _defaultTheme, ...otherThemes } = themeMap
|
|
25
25
|
const definitions = defineCssVariables(otherThemes)
|
|
26
26
|
|
|
27
27
|
return plugin(({ addBase }) => {
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
29
28
|
addBase(definitions)
|
|
30
29
|
|
|
31
30
|
// styledのTokenInjector移植(background処理除く)
|
|
32
31
|
if (cssVariablesV1) {
|
|
33
32
|
const cssVariablesV1 = defineCssVariablesV1(themeMap)
|
|
34
|
-
//
|
|
33
|
+
// @ts-expect-error FIXME
|
|
35
34
|
addBase(cssVariablesV1)
|
|
36
35
|
}
|
|
37
36
|
})
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Material } from '@charcoal-ui/foundation'
|
|
2
2
|
import { applyEffect, filterObject, mapObject } from '@charcoal-ui/utils'
|
|
3
|
-
import type {
|
|
3
|
+
import type { Config } from 'tailwindcss'
|
|
4
4
|
import { MergedEffect } from '../foundation'
|
|
5
5
|
|
|
6
6
|
import { TailwindVersion } from '../types'
|
|
@@ -12,7 +12,7 @@ export function colorsToTailwindConfig(
|
|
|
12
12
|
version: TailwindVersion,
|
|
13
13
|
colors: AnyColorTheme,
|
|
14
14
|
effects: MergedEffect
|
|
15
|
-
):
|
|
15
|
+
): NonNullable<Config['theme']>['colors'] {
|
|
16
16
|
const targetColors = filterObject(colors, isSingleColor)
|
|
17
17
|
const DEFAULT = getDefaultKeyName(version)
|
|
18
18
|
|
|
@@ -55,6 +55,7 @@ export const Colors: React.FC = () => {
|
|
|
55
55
|
<div className="space-y-24">
|
|
56
56
|
{Object.entries(colors).map(([colorName, values]) => (
|
|
57
57
|
<div className="flex" key={colorName}>
|
|
58
|
+
{/* @ts-expect-error FIXME */}
|
|
58
59
|
{typeof values === 'object' && 'DEFAULT' in values ? (
|
|
59
60
|
<>
|
|
60
61
|
<ColorBox
|
package/src/gradient/plugin.ts
CHANGED
|
@@ -30,21 +30,19 @@ export default function cssVariableColorPlugin(
|
|
|
30
30
|
return plugin(({ addBase, addUtilities }) => {
|
|
31
31
|
const css = mapKeys(utilities, (name) => `${VAR_PREFIX}${name}`)
|
|
32
32
|
if (selectorOrMediaQuery.startsWith('@media')) {
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
34
33
|
addBase({
|
|
35
34
|
[selectorOrMediaQuery]: {
|
|
36
35
|
':root': css,
|
|
37
36
|
},
|
|
38
37
|
})
|
|
39
38
|
} else {
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
41
39
|
addBase({
|
|
42
40
|
[selectorOrMediaQuery]: css,
|
|
43
41
|
})
|
|
44
42
|
}
|
|
45
43
|
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
47
44
|
addUtilities(classRules, {
|
|
45
|
+
// @ts-expect-error FIXME
|
|
48
46
|
variants: ['responsive'],
|
|
49
47
|
})
|
|
50
48
|
})
|
package/src/index.test.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GRID_COUNT, mergeEffect } from './foundation'
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { Config } from 'tailwindcss'
|
|
4
4
|
import { TailwindVersion, ThemeMap } from './types'
|
|
5
5
|
|
|
6
6
|
import {
|
|
@@ -36,7 +36,7 @@ export function createTailwindConfig({
|
|
|
36
36
|
version = 'v3',
|
|
37
37
|
cssVariablesV1 = true,
|
|
38
38
|
unstableTokenV2 = false,
|
|
39
|
-
}: Options):
|
|
39
|
+
}: Options): Omit<Config, 'content'> {
|
|
40
40
|
assertAllThemeHaveSameKeys(theme)
|
|
41
41
|
|
|
42
42
|
const defaultTheme = theme[':root']
|
|
@@ -53,7 +53,7 @@ export function createTailwindConfig({
|
|
|
53
53
|
spacing: spacingV2,
|
|
54
54
|
gap: gapV2,
|
|
55
55
|
width: widthV2,
|
|
56
|
-
}: Partial<
|
|
56
|
+
}: Partial<NonNullable<Config['theme']>> = unstableTokenV2
|
|
57
57
|
? unstable_createTailwindConfigTokenV2().theme
|
|
58
58
|
: {}
|
|
59
59
|
|
|
@@ -148,7 +148,6 @@ export function createTailwindConfig({
|
|
|
148
148
|
...getVariantOption(version),
|
|
149
149
|
|
|
150
150
|
corePlugins: {
|
|
151
|
-
// @ts-expect-error 配列にしろと言ってくるが、たぶん @types が間違っている
|
|
152
151
|
lineHeight: false,
|
|
153
152
|
},
|
|
154
153
|
plugins: [
|
|
@@ -166,4 +165,6 @@ export function createTailwindConfig({
|
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
167
|
|
|
169
|
-
export const config:
|
|
168
|
+
export const config: Omit<Config, 'content'> = createTailwindConfig({})
|
|
169
|
+
|
|
170
|
+
export default config
|
package/src/tokenV2.test.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { unstable_createTailwindConfigTokenV2 } from './tokenV2'
|
|
|
4
4
|
describe('unstable_createTailwindConfigTokenV2', async () => {
|
|
5
5
|
const config = unstable_createTailwindConfigTokenV2()
|
|
6
6
|
const result = await TailwindBuild.run(
|
|
7
|
+
// @ts-expect-error FIXME: missing content
|
|
7
8
|
config,
|
|
8
9
|
`
|
|
9
10
|
@import 'tailwindcss/base';
|
package/src/tokenV2.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
3
1
|
import light from '@charcoal-ui/theme/unstable-tokens/css-variables.json'
|
|
4
|
-
import {
|
|
5
|
-
TailwindConfig,
|
|
6
|
-
TailwindThemeFontSizes,
|
|
7
|
-
} from 'tailwindcss/tailwind-config'
|
|
2
|
+
import type { Config } from 'tailwindcss'
|
|
8
3
|
import {
|
|
9
4
|
flattenKey as flattenKeys,
|
|
10
5
|
mapDefaultKey as mapDefaultKeys,
|
|
@@ -39,7 +34,7 @@ export function unstable_createTailwindConfigTokenV2() {
|
|
|
39
34
|
]
|
|
40
35
|
})
|
|
41
36
|
})
|
|
42
|
-
) as
|
|
37
|
+
) as NonNullable<Config['theme']>['fontSize']
|
|
43
38
|
|
|
44
39
|
// space.target.s -> p-target-s
|
|
45
40
|
// space.gap.gapButtons -> p-gap-buttons
|
|
@@ -48,7 +43,7 @@ export function unstable_createTailwindConfigTokenV2() {
|
|
|
48
43
|
// color.container.hover -> bg-container-hover
|
|
49
44
|
const colors = mapDefaultKeys(light.color)
|
|
50
45
|
|
|
51
|
-
const config:
|
|
46
|
+
const config: Omit<Config, 'content'> = {
|
|
52
47
|
darkMode: 'media',
|
|
53
48
|
theme: {
|
|
54
49
|
// borderWidth.m -> border-m
|
package/src/typography/plugin.ts
CHANGED
|
@@ -38,7 +38,6 @@ const typographyPlugin = plugin(({ addUtilities }) => {
|
|
|
38
38
|
typographyStyle(style),
|
|
39
39
|
])
|
|
40
40
|
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
42
41
|
addUtilities(
|
|
43
42
|
{
|
|
44
43
|
...typographyClasses,
|
|
@@ -52,6 +51,7 @@ const typographyPlugin = plugin(({ addUtilities }) => {
|
|
|
52
51
|
},
|
|
53
52
|
},
|
|
54
53
|
{
|
|
54
|
+
// @ts-expect-error FIXME
|
|
55
55
|
variants: ['responsive'],
|
|
56
56
|
}
|
|
57
57
|
)
|
package/src/util.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Config } from 'tailwindcss'
|
|
2
2
|
import { TailwindVersion, ThemeMap } from './types'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -19,9 +19,7 @@ export function getDefaultKeyName(version: TailwindVersion) {
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function getVariantOption(
|
|
23
|
-
version: TailwindVersion
|
|
24
|
-
): Partial<TailwindConfig> {
|
|
22
|
+
export function getVariantOption(version: TailwindVersion): Partial<Config> {
|
|
25
23
|
switch (version) {
|
|
26
24
|
case 'v3': {
|
|
27
25
|
// v3 以上では variants は variantOrders に改名された
|
|
@@ -77,7 +75,6 @@ export const mapDefaultKey = <O extends object>(o: O) => {
|
|
|
77
75
|
return JSON.parse(JSON.stringify(o), function reviver(k: string, v: string) {
|
|
78
76
|
if (k === 'default') {
|
|
79
77
|
const DefaultKey = getDefaultKeyName('v3')
|
|
80
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
81
78
|
this[DefaultKey] = v
|
|
82
79
|
return undefined
|
|
83
80
|
}
|