@vobs/tailwind 1.0.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/LICENSE +21 -0
- package/README.md +39 -0
- package/package.json +29 -0
- package/src/index.test.ts +20 -0
- package/src/index.ts +2 -0
- package/src/styles-prefixed.css +4 -0
- package/src/styles.css +4 -0
- package/src/styles.test.ts +27 -0
- package/src/theme.css +28 -0
- package/src/theme.test.ts +23 -0
- package/src/vite.ts +9 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 vobs contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @vobs/tailwind
|
|
2
|
+
|
|
3
|
+
Tailwind CSS v4 integration for Vobs, with theme tokens exposed through Tailwind's namespaces.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @vobs/tailwind
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
// vite.config.ts
|
|
15
|
+
import { defineConfig } from 'vite'
|
|
16
|
+
import { vobsTailwind } from '@vobs/tailwind'
|
|
17
|
+
|
|
18
|
+
export default defineConfig({
|
|
19
|
+
plugins: [vobsTailwind()]
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```css
|
|
24
|
+
/* app.css */
|
|
25
|
+
@import "@vobs/tailwind/styles.css";
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API
|
|
29
|
+
|
|
30
|
+
| Signature | Description |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| `vobsTailwind(options?)` | Thin wrapper around the Tailwind v4 Vite plugin (`@tailwindcss/vite`); returns the plugin array and passes options through unchanged. |
|
|
33
|
+
| `@vobs/tailwind/styles.css` | Tailwind theme and utilities layers plus Vobs theme tokens. |
|
|
34
|
+
| `@vobs/tailwind/styles-prefixed.css` | Same stylesheet with utilities under the `vobs` prefix, for class name collisions. |
|
|
35
|
+
| `@vobs/tailwind/theme.css` | Vobs semantic tokens mapped to Tailwind's color, spacing and radius namespaces. |
|
|
36
|
+
|
|
37
|
+
## Types
|
|
38
|
+
|
|
39
|
+
VobsTailwindOptions
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"license": "MIT",
|
|
3
|
+
"files": [
|
|
4
|
+
"src",
|
|
5
|
+
"README.md",
|
|
6
|
+
"LICENSE"
|
|
7
|
+
],
|
|
8
|
+
"name": "@vobs/tailwind",
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"description": "Tailwind CSS integration for Vobs theme conventions.",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "src/index.ts",
|
|
13
|
+
"types": "src/index.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./src/index.ts",
|
|
16
|
+
"./vite": "./src/vite.ts",
|
|
17
|
+
"./theme.css": "./src/theme.css",
|
|
18
|
+
"./styles.css": "./src/styles.css",
|
|
19
|
+
"./styles-prefixed.css": "./src/styles-prefixed.css",
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./src/*.css"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
27
|
+
"tailwindcss": "^4.3.3"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
import { vobsTailwind } from './index'
|
|
5
|
+
|
|
6
|
+
describe('@vobs/tailwind', () => {
|
|
7
|
+
it('暴露 Tailwind Vite 插件数组', () => {
|
|
8
|
+
const plugins = vobsTailwind()
|
|
9
|
+
|
|
10
|
+
expect(Array.isArray(plugins)).toBe(true)
|
|
11
|
+
expect(plugins.length).toBeGreaterThan(0)
|
|
12
|
+
expect(plugins.every(plugin => typeof plugin.name === 'string')).toBe(true)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('透传 Tailwind Vite 优化选项', () => {
|
|
16
|
+
const plugins = vobsTailwind({ optimize: false })
|
|
17
|
+
|
|
18
|
+
expect(plugins.length).toBeGreaterThan(0)
|
|
19
|
+
})
|
|
20
|
+
})
|
package/src/index.ts
ADDED
package/src/styles.css
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import { describe, expect, it } from 'vitest'
|
|
5
|
+
|
|
6
|
+
async function readEntry(name: string): Promise<string> {
|
|
7
|
+
return readFile(new URL(`./${name}`, import.meta.url), 'utf8')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
describe('@vobs/tailwind CSS entries', () => {
|
|
11
|
+
it('provides utilities without Tailwind Preflight', async () => {
|
|
12
|
+
const source = await readEntry('styles.css')
|
|
13
|
+
|
|
14
|
+
expect(source).toContain('tailwindcss/theme.css')
|
|
15
|
+
expect(source).toContain('tailwindcss/utilities.css')
|
|
16
|
+
expect(source).toContain('./theme.css')
|
|
17
|
+
expect(source).not.toContain('tailwindcss/preflight.css')
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
it('provides an isolated prefixed utilities entry', async () => {
|
|
21
|
+
const source = await readEntry('styles-prefixed.css')
|
|
22
|
+
|
|
23
|
+
expect(source).toContain('tailwindcss/utilities.css" prefix(vobs)')
|
|
24
|
+
expect(source).toContain('./theme.css')
|
|
25
|
+
expect(source).not.toContain('tailwindcss/preflight.css')
|
|
26
|
+
})
|
|
27
|
+
})
|
package/src/theme.css
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* Vobs semantic tokens exposed through Tailwind's color, spacing, and radius namespaces. */
|
|
2
|
+
@theme inline {
|
|
3
|
+
--color-brand: var(--vobs-brand-primary, #2563eb);
|
|
4
|
+
--color-brand-secondary: var(--vobs-brand-secondary, #0f766e);
|
|
5
|
+
--color-brand-accent: var(--vobs-brand-accent, #d97706);
|
|
6
|
+
|
|
7
|
+
--color-background: var(--vobs-neutral-background, #ffffff);
|
|
8
|
+
--color-surface: var(--vobs-neutral-surface, var(--vobs-neutral-background, #f8fafc));
|
|
9
|
+
--color-foreground: var(--vobs-neutral-foreground, #172033);
|
|
10
|
+
--color-muted: var(--vobs-neutral-muted, #64748b);
|
|
11
|
+
--color-border: var(--vobs-neutral-border, #cbd5e1);
|
|
12
|
+
|
|
13
|
+
--color-success: var(--vobs-semantic-success, #15803d);
|
|
14
|
+
--color-warning: var(--vobs-semantic-warning, #b45309);
|
|
15
|
+
--color-danger: var(--vobs-semantic-danger, #b91c1c);
|
|
16
|
+
--color-info: var(--vobs-semantic-info, #0369a1);
|
|
17
|
+
|
|
18
|
+
--spacing-vobs-sm: var(--vobs-spacing-sm, 4px);
|
|
19
|
+
--spacing-vobs-md: var(--vobs-spacing-md, 8px);
|
|
20
|
+
--spacing-vobs-lg: var(--vobs-spacing-lg, 16px);
|
|
21
|
+
|
|
22
|
+
--radius-vobs-sm: var(--vobs-radius-sm, 2px);
|
|
23
|
+
--radius-vobs-md: var(--vobs-radius-md, 4px);
|
|
24
|
+
--radius-vobs-lg: var(--vobs-radius-lg, 6px);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* Follow the Vobs theme boundary instead of maintaining a second class-based dark state. */
|
|
28
|
+
@custom-variant dark (&:where([data-vobs-mode="dark"], [data-vobs-mode="dark"] *));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
|
|
3
|
+
import { readFile } from 'node:fs/promises'
|
|
4
|
+
import { describe, expect, it } from 'vitest'
|
|
5
|
+
|
|
6
|
+
describe('@vobs/tailwind theme bridge', () => {
|
|
7
|
+
it('does not depend on @vobs/ui token names', async () => {
|
|
8
|
+
const source = await readFile(new URL('./theme.css', import.meta.url), 'utf8')
|
|
9
|
+
|
|
10
|
+
expect(source).not.toMatch(/var\(--(?:bg|text|border|status|radius)-/u)
|
|
11
|
+
expect(source).toContain('--color-brand: var(--vobs-brand-primary')
|
|
12
|
+
expect(source).toContain('--color-foreground: var(--vobs-neutral-foreground')
|
|
13
|
+
expect(source).toContain('--color-surface: var(--vobs-neutral-surface, var(--vobs-neutral-background')
|
|
14
|
+
expect(source).toContain('--spacing-vobs-md: var(--vobs-spacing-md')
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('uses the Vobs theme boundary for dark variants', async () => {
|
|
18
|
+
const source = await readFile(new URL('./theme.css', import.meta.url), 'utf8')
|
|
19
|
+
|
|
20
|
+
expect(source).toContain('@custom-variant dark')
|
|
21
|
+
expect(source).toContain('[data-vobs-mode="dark"]')
|
|
22
|
+
})
|
|
23
|
+
})
|
package/src/vite.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import tailwindcss, { type PluginOptions } from '@tailwindcss/vite'
|
|
2
|
+
import type { Plugin } from 'vite'
|
|
3
|
+
|
|
4
|
+
export type VobsTailwindOptions = PluginOptions
|
|
5
|
+
|
|
6
|
+
/** Vite integration for Tailwind CSS with Vobs theme conventions. */
|
|
7
|
+
export function vobsTailwind(options: VobsTailwindOptions = {}): Plugin[] {
|
|
8
|
+
return tailwindcss(options)
|
|
9
|
+
}
|