vue-vben-admin/internal/tailwind-config/src/index.ts

267 lines
8.6 KiB
TypeScript
Raw Normal View History

2024-05-19 21:20:42 +08:00
import type { Config } from 'tailwindcss';
import path from 'node:path';
import { addDynamicIconSelectors } from '@iconify/tailwind';
import { getPackagesSync } from '@manypkg/get-packages';
2024-05-28 23:38:36 +08:00
import typographyPlugin from '@tailwindcss/typography';
2024-05-19 21:20:42 +08:00
import animate from 'tailwindcss-animate';
2024-05-28 23:38:36 +08:00
2024-06-02 20:47:50 +08:00
import { enterAnimationPlugin } from './plugins/entry';
2024-05-19 21:20:42 +08:00
// import defaultTheme from 'tailwindcss/defaultTheme';
const { packages } = getPackagesSync(process.cwd());
2024-05-19 21:20:42 +08:00
const tailwindPackages: string[] = [];
packages.forEach((pkg) => {
// apps目录下和 @vben-core/tailwind-ui 包需要使用到 tailwindcss ui
// if (fs.existsSync(path.join(pkg.dir, 'tailwind.config.mjs'))) {
tailwindPackages.push(pkg.dir);
// }
2024-05-19 21:20:42 +08:00
});
const shadcnUiColors = {
accent: {
DEFAULT: 'hsl(var(--accent))',
foreground: 'hsl(var(--accent-foreground))',
hover: 'hsl(var(--accent-hover))',
lighter: 'has(val(--accent-lighter))',
},
background: {
deep: 'hsl(var(--background-deep))',
DEFAULT: 'hsl(var(--background))',
},
border: {
DEFAULT: 'hsl(var(--border))',
},
card: {
DEFAULT: 'hsl(var(--card))',
foreground: 'hsl(var(--card-foreground))',
},
destructive: {
...createColorsPalette('destructive'),
DEFAULT: 'hsl(var(--destructive))',
},
foreground: {
DEFAULT: 'hsl(var(--foreground))',
},
input: {
background: 'hsl(var(--input-background))',
DEFAULT: 'hsl(var(--input))',
},
muted: {
DEFAULT: 'hsl(var(--muted))',
foreground: 'hsl(var(--muted-foreground))',
},
popover: {
DEFAULT: 'hsl(var(--popover))',
foreground: 'hsl(var(--popover-foreground))',
},
primary: {
...createColorsPalette('primary'),
DEFAULT: 'hsl(var(--primary))',
},
ring: 'hsl(var(--ring))',
secondary: {
DEFAULT: 'hsl(var(--secondary))',
desc: 'hsl(var(--secondary-desc))',
foreground: 'hsl(var(--secondary-foreground))',
},
};
const customColors = {
green: {
...createColorsPalette('green'),
foreground: 'hsl(var(--success-foreground))',
},
header: {
DEFAULT: 'hsl(var(--header))',
},
heavy: {
DEFAULT: 'hsl(var(--heavy))',
foreground: 'hsl(var(--heavy-foreground))',
},
main: {
DEFAULT: 'hsl(var(--main))',
},
overlay: {
content: 'hsl(var(--overlay-content))',
DEFAULT: 'hsl(var(--overlay))',
},
red: {
...createColorsPalette('red'),
foreground: 'hsl(var(--destructive-foreground))',
},
2024-07-15 23:59:22 +08:00
sidebar: {
deep: 'hsl(var(--sidebar-deep))',
DEFAULT: 'hsl(var(--sidebar))',
2024-07-15 23:59:22 +08:00
},
success: {
...createColorsPalette('success'),
DEFAULT: 'hsl(var(--success))',
},
warning: {
...createColorsPalette('warning'),
DEFAULT: 'hsl(var(--warning))',
},
yellow: {
...createColorsPalette('yellow'),
foreground: 'hsl(var(--warning-foreground))',
},
};
2024-06-23 19:17:31 +08:00
2024-05-19 21:20:42 +08:00
export default {
content: [
'./index.html',
...tailwindPackages.map((item) =>
path.join(item, 'src/**/*.{vue,js,ts,jsx,tsx,svelte,astro,html}'),
),
],
2024-07-15 23:59:22 +08:00
darkMode: 'selector',
2024-06-02 20:47:50 +08:00
plugins: [
animate,
typographyPlugin,
addDynamicIconSelectors(),
enterAnimationPlugin,
],
2024-05-19 21:20:42 +08:00
prefix: '',
theme: {
container: {
center: true,
padding: '2rem',
screens: {
'2xl': '1400px',
},
},
extend: {
animation: {
'accordion-down': 'accordion-down 0.2s ease-out',
'accordion-up': 'accordion-up 0.2s ease-out',
'collapsible-down': 'collapsible-down 0.2s ease-in-out',
'collapsible-up': 'collapsible-up 0.2s ease-in-out',
float: 'float 5s linear 0ms infinite',
},
2024-06-16 15:45:15 +08:00
animationDuration: {
'2000': '2000ms',
'3000': '3000ms',
},
2024-05-19 21:20:42 +08:00
borderRadius: {
2024-06-23 14:21:27 +08:00
lg: 'var(--radius)',
md: 'calc(var(--radius) - 2px)',
sm: 'calc(var(--radius) - 4px)',
xl: 'calc(var(--radius) + 4px)',
2024-05-19 21:20:42 +08:00
},
boxShadow: {
float: `0 6px 16px 0 rgb(0 0 0 / 8%),
0 3px 6px -4px rgb(0 0 0 / 12%),
0 9px 28px 8px rgb(0 0 0 / 5%)`,
},
2024-05-19 21:20:42 +08:00
colors: {
...customColors,
...shadcnUiColors,
2024-05-19 21:20:42 +08:00
},
fontFamily: {
sans: [
2024-07-28 17:01:19 +08:00
'var(--font-family)',
2024-05-19 21:20:42 +08:00
// ...defaultTheme.fontFamily.sans
],
},
keyframes: {
'accordion-down': {
from: { height: '0' },
to: { height: 'var(--radix-accordion-content-height)' },
},
'accordion-up': {
from: { height: 'var(--radix-accordion-content-height)' },
to: { height: '0' },
},
'collapsible-down': {
from: { height: '0' },
to: { height: 'var(--radix-collapsible-content-height)' },
},
'collapsible-up': {
from: { height: 'var(--radix-collapsible-content-height)' },
to: { height: '0' },
},
float: {
'0%': { transform: 'translateY(0)' },
chore(deps): bump the non-breaking-changes group with 9 updates (#4266) * chore(deps): bump the non-breaking-changes group with 9 updates Bumps the non-breaking-changes group with 9 updates: | Package | From | To | | --- | --- | --- | | [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) | `22.5.0` | `22.5.1` | | [turbo](https://github.com/vercel/turborepo) | `2.0.14` | `2.1.0` | | [@iconify/json](https://github.com/iconify/icon-sets) | `2.2.241` | `2.2.242` | | [@tailwindcss/typography](https://github.com/tailwindlabs/tailwindcss-typography) | `0.5.14` | `0.5.15` | | [@commitlint/cli](https://github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/cli) | `19.4.0` | `19.4.1` | | [@commitlint/config-conventional](https://github.com/conventional-changelog/commitlint/tree/HEAD/@commitlint/config-conventional) | `19.2.2` | `19.4.1` | | [eslint-config-turbo](https://github.com/vercel/turborepo/tree/HEAD/packages/eslint-config-turbo) | `2.0.14` | `2.1.0` | | [eslint-plugin-perfectionist](https://github.com/azat-io/eslint-plugin-perfectionist) | `3.2.0` | `3.3.0` | | [stylelint](https://github.com/stylelint/stylelint) | `16.8.2` | `16.9.0` | Updates `@types/node` from 22.5.0 to 22.5.1 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Updates `turbo` from 2.0.14 to 2.1.0 - [Release notes](https://github.com/vercel/turborepo/releases) - [Changelog](https://github.com/vercel/turborepo/blob/main/release.md) - [Commits](https://github.com/vercel/turborepo/compare/v2.0.14...v2.1.0) Updates `@iconify/json` from 2.2.241 to 2.2.242 - [Commits](https://github.com/iconify/icon-sets/compare/2.2.241...2.2.242) Updates `@tailwindcss/typography` from 0.5.14 to 0.5.15 - [Release notes](https://github.com/tailwindlabs/tailwindcss-typography/releases) - [Changelog](https://github.com/tailwindlabs/tailwindcss-typography/blob/main/CHANGELOG.md) - [Commits](https://github.com/tailwindlabs/tailwindcss-typography/compare/v0.5.14...v0.5.15) Updates `@commitlint/cli` from 19.4.0 to 19.4.1 - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/cli/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/commits/v19.4.1/@commitlint/cli) Updates `@commitlint/config-conventional` from 19.2.2 to 19.4.1 - [Release notes](https://github.com/conventional-changelog/commitlint/releases) - [Changelog](https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/CHANGELOG.md) - [Commits](https://github.com/conventional-changelog/commitlint/commits/v19.4.1/@commitlint/config-conventional) Updates `eslint-config-turbo` from 2.0.14 to 2.1.0 - [Release notes](https://github.com/vercel/turborepo/releases) - [Changelog](https://github.com/vercel/turborepo/blob/main/release.md) - [Commits](https://github.com/vercel/turborepo/commits/v2.1.0/packages/eslint-config-turbo) Updates `eslint-plugin-perfectionist` from 3.2.0 to 3.3.0 - [Release notes](https://github.com/azat-io/eslint-plugin-perfectionist/releases) - [Changelog](https://github.com/azat-io/eslint-plugin-perfectionist/blob/main/changelog.md) - [Commits](https://github.com/azat-io/eslint-plugin-perfectionist/compare/v3.2.0...v3.3.0) Updates `stylelint` from 16.8.2 to 16.9.0 - [Release notes](https://github.com/stylelint/stylelint/releases) - [Changelog](https://github.com/stylelint/stylelint/blob/main/CHANGELOG.md) - [Commits](https://github.com/stylelint/stylelint/compare/16.8.2...16.9.0) --- updated-dependencies: - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: non-breaking-changes - dependency-name: turbo dependency-type: direct:development update-type: version-update:semver-minor dependency-group: non-breaking-changes - dependency-name: "@iconify/json" dependency-type: direct:production update-type: version-update:semver-patch dependency-group: non-breaking-changes - dependency-name: "@tailwindcss/typography" dependency-type: direct:production update-type: version-update:semver-patch dependency-group: non-breaking-changes - dependency-name: "@commitlint/cli" dependency-type: direct:production update-type: version-update:semver-patch dependency-group: non-breaking-changes - dependency-name: "@commitlint/config-conventional" dependency-type: direct:production update-type: version-update:semver-minor dependency-group: non-breaking-changes - dependency-name: eslint-config-turbo dependency-type: direct:production update-type: version-update:semver-minor dependency-group: non-breaking-changes - dependency-name: eslint-plugin-perfectionist dependency-type: direct:development update-type: version-update:semver-minor dependency-group: non-breaking-changes - dependency-name: stylelint dependency-type: direct:development update-type: version-update:semver-minor dependency-group: non-breaking-changes ... Signed-off-by: dependabot[bot] <support@github.com> * chore: update deps * chore: update ci --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: vince <vince292007@gmail.com>
2024-08-29 07:28:23 +08:00
'50%': { transform: 'translateY(-20px)' },
'100%': { transform: 'translateY(0)' },
2024-05-19 21:20:42 +08:00
},
},
zIndex: {
'100': '100',
'1000': '1000',
},
},
},
safelist: ['dark'],
2024-05-19 21:20:42 +08:00
} as Config;
function createColorsPalette(name: string) {
// backgroundLightest: '#EFF6FF', // Tailwind CSS 默认的 `blue-50`
// backgroundLighter: '#DBEAFE', // Tailwind CSS 默认的 `blue-100`
// backgroundLight: '#BFDBFE', // Tailwind CSS 默认的 `blue-200`
// borderLight: '#93C5FD', // Tailwind CSS 默认的 `blue-300`
// border: '#60A5FA', // Tailwind CSS 默认的 `blue-400`
// main: '#3B82F6', // Tailwind CSS 默认的 `blue-500`
// hover: '#2563EB', // Tailwind CSS 默认的 `blue-600`
// active: '#1D4ED8', // Tailwind CSS 默认的 `blue-700`
// backgroundDark: '#1E40AF', // Tailwind CSS 默认的 `blue-800`
// backgroundDarker: '#1E3A8A', // Tailwind CSS 默认的 `blue-900`
// backgroundDarkest: '#172554', // Tailwind CSS 默认的 `blue-950`
// • backgroundLightest (#EFF6FF): 适用于最浅的背景色,可能用于非常轻微的阴影或卡片的背景。
// • backgroundLighter (#DBEAFE): 适用于略浅的背景色,通常用于次要背景或略浅的区域。
// • backgroundLight (#BFDBFE): 适用于浅色背景,可能用于输入框或表单区域的背景。
// • borderLight (#93C5FD): 适用于浅色边框,可能用于输入框或卡片的边框。
// • border (#60A5FA): 适用于普通边框,可能用于按钮或卡片的边框。
// • main (#3B82F6): 适用于主要的主题色,通常用于按钮、链接或主要的强调色。
// • hover (#2563EB): 适用于鼠标悬停状态下的颜色,例如按钮悬停时的背景色或边框色。
// • active (#1D4ED8): 适用于激活状态下的颜色,例如按钮按下时的背景色或边框色。
// • backgroundDark (#1E40AF): 适用于深色背景,可能用于主要按钮或深色卡片背景。
// • backgroundDarker (#1E3A8A): 适用于更深的背景,通常用于头部导航栏或页脚。
// • backgroundDarkest (#172554): 适用于最深的背景,可能用于非常深色的区域或极端对比色。
return {
50: `hsl(var(--${name}-50))`,
100: `hsl(var(--${name}-100))`,
200: `hsl(var(--${name}-200))`,
300: `hsl(var(--${name}-300))`,
400: `hsl(var(--${name}-400))`,
500: `hsl(var(--${name}-500))`,
600: `hsl(var(--${name}-600))`,
700: `hsl(var(--${name}-700))`,
// 800: `hsl(var(--${name}-800))`,
// 900: `hsl(var(--${name}-900))`,
// 950: `hsl(var(--${name}-950))`,
// 激活状态下的颜色,适用于按钮按下时的背景色或边框色。
active: `hsl(var(--${name}-700))`,
// 浅色背景,适用于输入框或表单区域的背景。
'background-light': `hsl(var(--${name}-200))`,
// 适用于略浅的背景色,通常用于次要背景或略浅的区域。
'background-lighter': `hsl(var(--${name}-100))`,
// 最浅的背景色,适用于非常轻微的阴影或卡片的背景。
'background-lightest': `hsl(var(--${name}-50))`,
// 适用于普通边框,可能用于按钮或卡片的边框。
border: `hsl(var(--${name}-400))`,
// 浅色边框,适用于输入框或卡片的边框。
'border-light': `hsl(var(--${name}-300))`,
foreground: `hsl(var(--${name}-foreground))`,
// 鼠标悬停状态下的颜色,适用于按钮悬停时的背景色或边框色。
hover: `hsl(var(--${name}-600))`,
// 主色文本
text: `hsl(var(--${name}-500))`,
// 主色文本激活态
'text-active': `hsl(var(--${name}-700))`,
// 主色文本悬浮态
'text-hover': `hsl(var(--${name}-600))`,
};
}