tailwind-preset-antd 0.0.1 → 0.0.2
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/dist/_virtual/_@oxc-project_runtime@0.127.0/helpers/defineProperty.js +12 -0
- package/dist/_virtual/_@oxc-project_runtime@0.127.0/helpers/objectSpread2.js +25 -0
- package/dist/_virtual/_@oxc-project_runtime@0.127.0/helpers/toPrimitive.js +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.127.0/helpers/toPropertyKey.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.127.0/helpers/typeof.js +11 -0
- package/dist/components.d.ts +7 -0
- package/dist/components.js +23 -0
- package/dist/core/genCssVarByTokens.js +31 -0
- package/dist/core/genTailwindTheme.js +46 -0
- package/dist/plugin.d.ts +28 -0
- package/dist/plugin.js +32 -0
- package/dist/preset/tokens/borderRadius.d.ts +4 -0
- package/dist/preset/tokens/borderRadius.js +9 -0
- package/dist/preset/tokens/colorPalettes.d.ts +7 -0
- package/dist/preset/tokens/colorPalettes.js +19 -0
- package/dist/preset/tokens/fontSizes.d.ts +4 -0
- package/dist/preset/tokens/fontSizes.js +9 -0
- package/dist/preset/tokens/functionalColors.d.ts +4 -0
- package/dist/preset/tokens/functionalColors.js +70 -0
- package/dist/preset/tokens/margins.d.ts +4 -0
- package/dist/preset/tokens/margins.js +13 -0
- package/dist/preset/tokens/semanticColors.d.ts +4 -0
- package/dist/preset/tokens/semanticColors.js +26 -0
- package/dist/preset.d.ts +11 -0
- package/dist/preset.js +14 -0
- package/dist/utils/index.js +11 -0
- package/package.json +12 -1
- package/.github/workflows/gh-pages.yml +0 -49
- package/.vscode/settings.json +0 -25
- package/oxfmt.config.ts +0 -22
- package/oxlint.config.ts +0 -6
- package/playground/index.html +0 -12
- package/playground/src/App.tsx +0 -226
- package/playground/src/global.css +0 -4
- package/playground/src/index.tsx +0 -15
- package/src/components.test.tsx +0 -56
- package/src/components.tsx +0 -33
- package/src/constants/index.ts +0 -1
- package/src/core/genCssVarByToken.test.ts +0 -46
- package/src/core/genCssVarByTokens.ts +0 -45
- package/src/core/genTailwindTheme.test.ts +0 -95
- package/src/core/genTailwindTheme.ts +0 -62
- package/src/plugin.ts +0 -71
- package/src/preset/index.ts +0 -13
- package/src/preset/tokens/borderRadius.ts +0 -6
- package/src/preset/tokens/colorPalettes.ts +0 -24
- package/src/preset/tokens/fontSizes.ts +0 -6
- package/src/preset/tokens/functionalColors.ts +0 -72
- package/src/preset/tokens/margins.ts +0 -11
- package/src/preset/tokens/semanticColors.ts +0 -29
- package/src/utils/index.ts +0 -10
- package/tsconfig.json +0 -21
- package/tsdown.config.ts +0 -14
- package/vite.config.ts +0 -23
- package/vitest.setup.ts +0 -11
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { toPropertyKey } from "./toPropertyKey.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/defineProperty.js
|
|
3
|
+
function _defineProperty(e, r, t) {
|
|
4
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
5
|
+
value: t,
|
|
6
|
+
enumerable: !0,
|
|
7
|
+
configurable: !0,
|
|
8
|
+
writable: !0
|
|
9
|
+
}) : e[r] = t, e;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { _defineProperty };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { _defineProperty } from "./defineProperty.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/objectSpread2.js
|
|
3
|
+
function ownKeys(e, r) {
|
|
4
|
+
var t = Object.keys(e);
|
|
5
|
+
if (Object.getOwnPropertySymbols) {
|
|
6
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
7
|
+
r && (o = o.filter(function(r) {
|
|
8
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
9
|
+
})), t.push.apply(t, o);
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
}
|
|
13
|
+
function _objectSpread2(e) {
|
|
14
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
15
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
16
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
17
|
+
_defineProperty(e, r, t[r]);
|
|
18
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
19
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return e;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { _objectSpread2 };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { _typeof } from "./typeof.js";
|
|
2
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/toPrimitive.js
|
|
3
|
+
function toPrimitive(t, r) {
|
|
4
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
5
|
+
var e = t[Symbol.toPrimitive];
|
|
6
|
+
if (void 0 !== e) {
|
|
7
|
+
var i = e.call(t, r || "default");
|
|
8
|
+
if ("object" != _typeof(i)) return i;
|
|
9
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
10
|
+
}
|
|
11
|
+
return ("string" === r ? String : Number)(t);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { toPrimitive };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { _typeof } from "./typeof.js";
|
|
2
|
+
import { toPrimitive } from "./toPrimitive.js";
|
|
3
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/toPropertyKey.js
|
|
4
|
+
function toPropertyKey(t) {
|
|
5
|
+
var i = toPrimitive(t, "string");
|
|
6
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { toPropertyKey };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.127.0/helpers/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
5
|
+
return typeof o;
|
|
6
|
+
} : function(o) {
|
|
7
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { _typeof };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { genCSSVarByTokens } from "./core/genCssVarByTokens.js";
|
|
2
|
+
import { theme } from "antd";
|
|
3
|
+
import { useInsertionEffect } from "react";
|
|
4
|
+
//#region src/components.tsx
|
|
5
|
+
const styleId = "antd-token-inject";
|
|
6
|
+
function AntdTokenCssVar(props) {
|
|
7
|
+
const { cssVarPrefix } = props;
|
|
8
|
+
const { token } = theme.useToken();
|
|
9
|
+
useInsertionEffect(() => {
|
|
10
|
+
const cssVar = genCSSVarByTokens(token, cssVarPrefix);
|
|
11
|
+
const style = document.querySelector(`#${styleId}`) || document.createElement("style");
|
|
12
|
+
style.id = styleId;
|
|
13
|
+
style.setAttribute("plugin-name", "tailwind-preset-antd");
|
|
14
|
+
style.textContent = `:root{${cssVar}}`;
|
|
15
|
+
document.head.appendChild(style);
|
|
16
|
+
return () => {
|
|
17
|
+
document.head.removeChild(style);
|
|
18
|
+
};
|
|
19
|
+
}, [token, cssVarPrefix]);
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { AntdTokenCssVar as default };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { hexToRgb, isRGBColor } from "../utils/index.js";
|
|
2
|
+
import { functionalColors } from "../preset/tokens/functionalColors.js";
|
|
3
|
+
import { colorPalettes } from "../preset/tokens/colorPalettes.js";
|
|
4
|
+
import { semanticColors } from "../preset/tokens/semanticColors.js";
|
|
5
|
+
import { margins } from "../preset/tokens/margins.js";
|
|
6
|
+
import { fontSizes } from "../preset/tokens/fontSizes.js";
|
|
7
|
+
import { borderRadius } from "../preset/tokens/borderRadius.js";
|
|
8
|
+
//#region src/core/genCssVarByTokens.ts
|
|
9
|
+
function genCSSVarByTokens(tokens, cssVarPrefix = "a") {
|
|
10
|
+
let colorsVariables = "";
|
|
11
|
+
for (const [key, value] of Object.entries(tokens)) {
|
|
12
|
+
if (colorPalettes.includes(key)) colorsVariables += `--${cssVarPrefix}-${key}:${hexToRgb(value)};`;
|
|
13
|
+
if (functionalColors.includes(key)) {
|
|
14
|
+
const rgb = hexToRgb(value);
|
|
15
|
+
colorsVariables += `--${cssVarPrefix}-${key}:${rgb};`;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (semanticColors.includes(key)) {
|
|
19
|
+
const rgb = isRGBColor(value) ? value : `rgb(${hexToRgb(value)})`;
|
|
20
|
+
colorsVariables += `--${cssVarPrefix}-${key}:${rgb};`;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (fontSizes.includes(key) || margins.includes(key) || borderRadius.includes(key)) {
|
|
24
|
+
colorsVariables += `--${cssVarPrefix}-${key}:${value}px;`;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return colorsVariables;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { genCSSVarByTokens };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { functionalColors } from "../preset/tokens/functionalColors.js";
|
|
2
|
+
import { colorPalettes } from "../preset/tokens/colorPalettes.js";
|
|
3
|
+
import { semanticColors } from "../preset/tokens/semanticColors.js";
|
|
4
|
+
import { margins } from "../preset/tokens/margins.js";
|
|
5
|
+
import { fontSizes } from "../preset/tokens/fontSizes.js";
|
|
6
|
+
import { borderRadius } from "../preset/tokens/borderRadius.js";
|
|
7
|
+
//#region src/core/genTailwindTheme.ts
|
|
8
|
+
function genTwPrefixKey(key, prefix) {
|
|
9
|
+
return prefix ? `${prefix}-${key}` : key;
|
|
10
|
+
}
|
|
11
|
+
function createColorPalettes(cssVarPrefix = "a", twPrefix) {
|
|
12
|
+
const colorPaletteVar = {};
|
|
13
|
+
colorPalettes.forEach((color) => {
|
|
14
|
+
colorPaletteVar[genTwPrefixKey(color, twPrefix)] = `rgb(var(--${cssVarPrefix}-${color}))`;
|
|
15
|
+
});
|
|
16
|
+
functionalColors.forEach((key) => {
|
|
17
|
+
colorPaletteVar[genTwPrefixKey(key, twPrefix)] = `rgb(var(--${cssVarPrefix}-${key}))`;
|
|
18
|
+
});
|
|
19
|
+
semanticColors.forEach((key) => {
|
|
20
|
+
colorPaletteVar[genTwPrefixKey(key, twPrefix)] = `var(--${cssVarPrefix}-${key})`;
|
|
21
|
+
});
|
|
22
|
+
return colorPaletteVar;
|
|
23
|
+
}
|
|
24
|
+
function createFontSize(cssVarPrefix = "a", twPrefix) {
|
|
25
|
+
const fontSizeVar = {};
|
|
26
|
+
fontSizes.forEach((key) => {
|
|
27
|
+
fontSizeVar[genTwPrefixKey(key, twPrefix)] = `var(--${cssVarPrefix}-${key})`;
|
|
28
|
+
});
|
|
29
|
+
return fontSizeVar;
|
|
30
|
+
}
|
|
31
|
+
function createSpacing(cssVarPrefix = "a", twPrefix) {
|
|
32
|
+
const spacingVar = {};
|
|
33
|
+
margins.forEach((key) => {
|
|
34
|
+
spacingVar[genTwPrefixKey(key, twPrefix)] = `var(--${cssVarPrefix}-${key})`;
|
|
35
|
+
});
|
|
36
|
+
return spacingVar;
|
|
37
|
+
}
|
|
38
|
+
function createBorderRadius(cssVarPrefix = "a", twPrefix) {
|
|
39
|
+
const radiusVar = {};
|
|
40
|
+
borderRadius.forEach((key) => {
|
|
41
|
+
radiusVar[genTwPrefixKey(key, twPrefix)] = `var(--${cssVarPrefix}-${key})`;
|
|
42
|
+
});
|
|
43
|
+
return radiusVar;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { createBorderRadius, createColorPalettes, createFontSize, createSpacing };
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//#region src/plugin.d.ts
|
|
2
|
+
interface PluginOptions {
|
|
3
|
+
/**
|
|
4
|
+
* @description tw class prefix
|
|
5
|
+
* @default '''
|
|
6
|
+
*/
|
|
7
|
+
twPrefix?: string;
|
|
8
|
+
/**
|
|
9
|
+
* @description css variables prefix
|
|
10
|
+
* @default 'a'
|
|
11
|
+
*/
|
|
12
|
+
cssVarPrefix?: string;
|
|
13
|
+
}
|
|
14
|
+
interface PluginWithOptions<T> {
|
|
15
|
+
(options?: T): {
|
|
16
|
+
handler: (api: any) => void;
|
|
17
|
+
};
|
|
18
|
+
__isOptionsFunction: true;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* @description 使用 Ant Design 的 Design Token 扩展 Tailwind CSS 类名,相关扩展有 color radius fontSize padding
|
|
22
|
+
* @example `bg-colorPrimary` --> `backgroundColor: token.colorPrimary`;
|
|
23
|
+
* @see https://ant-design.antgroup.com/docs/react/customize-theme-cn#seedtoken
|
|
24
|
+
* @see https://github.com/tailwindlabs/tailwindcss/discussions/13292#discussioncomment-14256365
|
|
25
|
+
*/
|
|
26
|
+
declare const twAntdPresetPlugin: PluginWithOptions<PluginOptions>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { twAntdPresetPlugin as default };
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createBorderRadius, createColorPalettes, createFontSize, createSpacing } from "./core/genTailwindTheme.js";
|
|
2
|
+
import { _objectSpread2 } from "./_virtual/_@oxc-project_runtime@0.127.0/helpers/objectSpread2.js";
|
|
3
|
+
import plugin from "tailwindcss/plugin";
|
|
4
|
+
//#region src/plugin.ts
|
|
5
|
+
/**
|
|
6
|
+
* @description 使用 Ant Design 的 Design Token 扩展 Tailwind CSS 类名,相关扩展有 color radius fontSize padding
|
|
7
|
+
* @example `bg-colorPrimary` --> `backgroundColor: token.colorPrimary`;
|
|
8
|
+
* @see https://ant-design.antgroup.com/docs/react/customize-theme-cn#seedtoken
|
|
9
|
+
* @see https://github.com/tailwindlabs/tailwindcss/discussions/13292#discussioncomment-14256365
|
|
10
|
+
*/
|
|
11
|
+
const twAntdPresetPlugin = plugin.withOptions(() => () => {}, (options = {}) => {
|
|
12
|
+
const { cssVarPrefix = "a", twPrefix = "" } = options;
|
|
13
|
+
return { theme: {
|
|
14
|
+
/**
|
|
15
|
+
* @see https://tailwindcss.com/docs/customizing-colors#using-css-variables
|
|
16
|
+
*/
|
|
17
|
+
extend: {
|
|
18
|
+
colors: _objectSpread2(_objectSpread2({}, createColorPalettes(cssVarPrefix, twPrefix)), {}, {
|
|
19
|
+
white: "rgb(255 255 255)",
|
|
20
|
+
black: "rgb(0 0 0)",
|
|
21
|
+
current: "currentColor",
|
|
22
|
+
inherit: "inherit",
|
|
23
|
+
transparent: "transparent"
|
|
24
|
+
}),
|
|
25
|
+
fontSize: _objectSpread2({}, createFontSize(cssVarPrefix, twPrefix)),
|
|
26
|
+
radius: _objectSpread2({}, createBorderRadius(cssVarPrefix, twPrefix)),
|
|
27
|
+
borderRadius: _objectSpread2({}, createBorderRadius(cssVarPrefix, twPrefix)),
|
|
28
|
+
spacing: _objectSpread2({}, createSpacing(cssVarPrefix, twPrefix))
|
|
29
|
+
} } };
|
|
30
|
+
});
|
|
31
|
+
//#endregion
|
|
32
|
+
export { twAntdPresetPlugin as default };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `['red', 'red-1', 'red-2', ……, 'red-10', 'magenta',……]`
|
|
3
|
+
*/
|
|
4
|
+
const colorPalettes = [
|
|
5
|
+
"red",
|
|
6
|
+
"volcano",
|
|
7
|
+
"orange",
|
|
8
|
+
"lime",
|
|
9
|
+
"gold",
|
|
10
|
+
"yellow",
|
|
11
|
+
"green",
|
|
12
|
+
"cyan",
|
|
13
|
+
"blue",
|
|
14
|
+
"geekblue",
|
|
15
|
+
"purple",
|
|
16
|
+
"magenta"
|
|
17
|
+
].flatMap((color) => [color, ...Array.from({ length: 10 }, (_, i) => `${color}-${i + 1}`)]);
|
|
18
|
+
//#endregion
|
|
19
|
+
export { colorPalettes };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//#region src/preset/tokens/functionalColors.ts
|
|
2
|
+
const brandColors = [
|
|
3
|
+
"colorPrimary",
|
|
4
|
+
"colorPrimaryBg",
|
|
5
|
+
"colorPrimaryBgHover",
|
|
6
|
+
"colorPrimaryBorder",
|
|
7
|
+
"colorPrimaryBorderHover",
|
|
8
|
+
"colorPrimaryHover",
|
|
9
|
+
"colorPrimaryActive",
|
|
10
|
+
"colorPrimaryTextHover",
|
|
11
|
+
"colorPrimaryText",
|
|
12
|
+
"colorPrimaryTextActive"
|
|
13
|
+
];
|
|
14
|
+
const successColors = [
|
|
15
|
+
"colorSuccess",
|
|
16
|
+
"colorSuccessBg",
|
|
17
|
+
"colorSuccessBgHover",
|
|
18
|
+
"colorSuccessBorder",
|
|
19
|
+
"colorSuccessBorderHover",
|
|
20
|
+
"colorSuccessHover",
|
|
21
|
+
"colorSuccessActive",
|
|
22
|
+
"colorSuccessTextHover",
|
|
23
|
+
"colorSuccessText",
|
|
24
|
+
"colorSuccessTextActive"
|
|
25
|
+
];
|
|
26
|
+
const warningColors = [
|
|
27
|
+
"colorWarning",
|
|
28
|
+
"colorWarningBg",
|
|
29
|
+
"colorWarningBgHover",
|
|
30
|
+
"colorWarningBorder",
|
|
31
|
+
"colorWarningBorderHover",
|
|
32
|
+
"colorWarningHover",
|
|
33
|
+
"colorWarningActive",
|
|
34
|
+
"colorWarningTextHover",
|
|
35
|
+
"colorWarningText",
|
|
36
|
+
"colorWarningTextActive"
|
|
37
|
+
];
|
|
38
|
+
const errorColors = [
|
|
39
|
+
"colorError",
|
|
40
|
+
"colorErrorBg",
|
|
41
|
+
"colorErrorBgHover",
|
|
42
|
+
"colorErrorBorder",
|
|
43
|
+
"colorErrorBorderHover",
|
|
44
|
+
"colorErrorHover",
|
|
45
|
+
"colorErrorActive",
|
|
46
|
+
"colorErrorTextHover",
|
|
47
|
+
"colorErrorText",
|
|
48
|
+
"colorErrorTextActive"
|
|
49
|
+
];
|
|
50
|
+
const infoColors = [
|
|
51
|
+
"colorInfo",
|
|
52
|
+
"colorInfoBg",
|
|
53
|
+
"colorInfoBgHover",
|
|
54
|
+
"colorInfoBorder",
|
|
55
|
+
"colorInfoBorderHover",
|
|
56
|
+
"colorInfoHover",
|
|
57
|
+
"colorInfoActive",
|
|
58
|
+
"colorInfoTextHover",
|
|
59
|
+
"colorInfoText",
|
|
60
|
+
"colorInfoTextActive"
|
|
61
|
+
];
|
|
62
|
+
const functionalColors = [
|
|
63
|
+
...brandColors,
|
|
64
|
+
...successColors,
|
|
65
|
+
...warningColors,
|
|
66
|
+
...errorColors,
|
|
67
|
+
...infoColors
|
|
68
|
+
];
|
|
69
|
+
//#endregion
|
|
70
|
+
export { functionalColors };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/preset/tokens/semanticColors.ts
|
|
2
|
+
const semanticColors = [
|
|
3
|
+
"colorText",
|
|
4
|
+
"colorTextSecondary",
|
|
5
|
+
"colorTextTertiary",
|
|
6
|
+
"colorTextQuaternary",
|
|
7
|
+
"colorTextDescription",
|
|
8
|
+
"colorTextDisabled",
|
|
9
|
+
"colorTextHeading",
|
|
10
|
+
"colorTextLabel",
|
|
11
|
+
"colorTextLightSolid",
|
|
12
|
+
"colorTextPlaceholder",
|
|
13
|
+
"colorBgContainer",
|
|
14
|
+
"colorBgElevated",
|
|
15
|
+
"colorBgLayout",
|
|
16
|
+
"colorBgSpotlight",
|
|
17
|
+
"colorBgMask",
|
|
18
|
+
"colorBorder",
|
|
19
|
+
"colorBorderSecondary",
|
|
20
|
+
"colorFill",
|
|
21
|
+
"colorFillSecondary",
|
|
22
|
+
"colorFillTertiary",
|
|
23
|
+
"colorFillQuaternary"
|
|
24
|
+
];
|
|
25
|
+
//#endregion
|
|
26
|
+
export { semanticColors };
|
package/dist/preset.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { functionalColors } from "./preset/tokens/functionalColors.js";
|
|
2
|
+
import { colorPalettes } from "./preset/tokens/colorPalettes.js";
|
|
3
|
+
import { semanticColors } from "./preset/tokens/semanticColors.js";
|
|
4
|
+
import { margins } from "./preset/tokens/margins.js";
|
|
5
|
+
import { fontSizes } from "./preset/tokens/fontSizes.js";
|
|
6
|
+
import { borderRadius } from "./preset/tokens/borderRadius.js";
|
|
7
|
+
|
|
8
|
+
//#region src/preset/index.d.ts
|
|
9
|
+
declare const colorPresets: string[];
|
|
10
|
+
//#endregion
|
|
11
|
+
export { borderRadius, colorPalettes, colorPresets, fontSizes, functionalColors, margins, semanticColors };
|
package/dist/preset.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { functionalColors } from "./preset/tokens/functionalColors.js";
|
|
2
|
+
import { colorPalettes } from "./preset/tokens/colorPalettes.js";
|
|
3
|
+
import { semanticColors } from "./preset/tokens/semanticColors.js";
|
|
4
|
+
import { margins } from "./preset/tokens/margins.js";
|
|
5
|
+
import { fontSizes } from "./preset/tokens/fontSizes.js";
|
|
6
|
+
import { borderRadius } from "./preset/tokens/borderRadius.js";
|
|
7
|
+
//#region src/preset/index.ts
|
|
8
|
+
const colorPresets = [
|
|
9
|
+
...colorPalettes,
|
|
10
|
+
...functionalColors,
|
|
11
|
+
...semanticColors
|
|
12
|
+
];
|
|
13
|
+
//#endregion
|
|
14
|
+
export { borderRadius, colorPalettes, colorPresets, fontSizes, functionalColors, margins, semanticColors };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import hexRgb from "hex-rgb";
|
|
2
|
+
//#region src/utils/index.ts
|
|
3
|
+
function isRGBColor(color) {
|
|
4
|
+
return color.trim().startsWith("rgb");
|
|
5
|
+
}
|
|
6
|
+
function hexToRgb(hex) {
|
|
7
|
+
const { red, green, blue } = hexRgb(hex);
|
|
8
|
+
return `${red}, ${green}, ${blue}`;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { hexToRgb, isRGBColor };
|
package/package.json
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tailwind-preset-antd",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Use Tailwind CSS with Ant Design tokens",
|
|
5
|
+
"homepage": "https://github.com/json-q/tailwind-preset-antd",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "json-q",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/json-q/tailwind-preset-antd.git"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
5
15
|
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
6
17
|
"exports": {
|
|
7
18
|
"./components": "./dist/components.js",
|
|
8
19
|
"./plugin": "./dist/plugin.js",
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
name: github pages
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
|
|
8
|
-
jobs:
|
|
9
|
-
deploy:
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- name: Checkout
|
|
13
|
-
uses: actions/checkout@v4
|
|
14
|
-
|
|
15
|
-
- name: Setup Node.js
|
|
16
|
-
uses: actions/setup-node@v4
|
|
17
|
-
with:
|
|
18
|
-
node-version: 24
|
|
19
|
-
|
|
20
|
-
- name: Install pnpm
|
|
21
|
-
uses: pnpm/action-setup@v4
|
|
22
|
-
with:
|
|
23
|
-
version: 10
|
|
24
|
-
|
|
25
|
-
# pnpm cache
|
|
26
|
-
- name: Get pnpm store directory
|
|
27
|
-
shell: bash
|
|
28
|
-
run: |
|
|
29
|
-
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
|
30
|
-
|
|
31
|
-
- name: Setup pnpm cache
|
|
32
|
-
uses: actions/cache@v4
|
|
33
|
-
with:
|
|
34
|
-
path: ${{ env.STORE_PATH }}
|
|
35
|
-
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
|
36
|
-
restore-keys: |
|
|
37
|
-
${{ runner.os }}-pnpm-store-
|
|
38
|
-
|
|
39
|
-
- name: Install workspace dependencies
|
|
40
|
-
run: pnpm install
|
|
41
|
-
|
|
42
|
-
- name: Build Docs
|
|
43
|
-
run: pnpm build:play
|
|
44
|
-
|
|
45
|
-
- name: Deploy to GitHub Pages
|
|
46
|
-
uses: peaceiris/actions-gh-pages@v4
|
|
47
|
-
with:
|
|
48
|
-
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
49
|
-
publish_dir: ./playground/docs-dist
|
package/.vscode/settings.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
3
|
-
"editor.formatOnSave": true,
|
|
4
|
-
"editor.codeActionsOnSave": {
|
|
5
|
-
"source.fixAll.oxc": "explicit"
|
|
6
|
-
},
|
|
7
|
-
"[json]": {
|
|
8
|
-
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
9
|
-
},
|
|
10
|
-
"[jsonc]": {
|
|
11
|
-
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
12
|
-
},
|
|
13
|
-
"[markdown]": {
|
|
14
|
-
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
15
|
-
},
|
|
16
|
-
"[typescript]": {
|
|
17
|
-
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
18
|
-
},
|
|
19
|
-
"[typescriptreact]": {
|
|
20
|
-
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
21
|
-
},
|
|
22
|
-
"[yaml]": {
|
|
23
|
-
"editor.defaultFormatter": "oxc.oxc-vscode"
|
|
24
|
-
}
|
|
25
|
-
}
|
package/oxfmt.config.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "oxfmt";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
useTabs: false,
|
|
5
|
-
tabWidth: 2,
|
|
6
|
-
printWidth: 100,
|
|
7
|
-
arrowParens: "always",
|
|
8
|
-
bracketSameLine: false,
|
|
9
|
-
bracketSpacing: true,
|
|
10
|
-
endOfLine: "lf",
|
|
11
|
-
jsxSingleQuote: false,
|
|
12
|
-
quoteProps: "as-needed",
|
|
13
|
-
semi: true,
|
|
14
|
-
singleQuote: false,
|
|
15
|
-
sortPackageJson: true,
|
|
16
|
-
trailingComma: "es5",
|
|
17
|
-
sortTailwindcss: {
|
|
18
|
-
functions: ["clsx", "cn"],
|
|
19
|
-
preserveWhitespace: true,
|
|
20
|
-
},
|
|
21
|
-
ignorePatterns: ["**/node_modules/**", "**/dist/**", "**/pnpm-lock.yaml"],
|
|
22
|
-
});
|
package/oxlint.config.ts
DELETED
package/playground/index.html
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>tailwind-preset-antd</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="app"></div>
|
|
10
|
-
<script type="module" src="/src/index.tsx"></script>
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|