@oneplatformdev/tokens 0.0.1-5 → 0.0.1-6
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/.babelrc +12 -0
- package/CHANGELOG.md +19 -0
- package/dist/package.json +2 -1
- package/package.json +2 -1
- package/src/applyBrandTokens.ts +19 -0
- package/src/index.ts +19 -0
- package/tsconfig.json +10 -0
- package/tsconfig.lib.json +33 -0
- package/vite.config.ts +70 -0
package/.babelrc
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## 0.0.1-6 (2025-09-11)
|
|
2
|
+
|
|
3
|
+
This was a version bump only for @oneplatformdev/tokens to align it with other projects, there were no code changes.
|
|
4
|
+
|
|
5
|
+
## 0.0.1-5 (2025-09-11)
|
|
6
|
+
|
|
7
|
+
This was a version bump only for @oneplatformdev/tokens to align it with other projects, there were no code changes.
|
|
8
|
+
|
|
9
|
+
## 0.0.1-4 (2025-09-11)
|
|
10
|
+
|
|
11
|
+
This was a version bump only for @oneplatformdev/tokens to align it with other projects, there were no code changes.
|
|
12
|
+
|
|
13
|
+
## 0.0.1-3 (2025-09-11)
|
|
14
|
+
|
|
15
|
+
This was a version bump only for @oneplatformdev/tokens to align it with other projects, there were no code changes.
|
|
16
|
+
|
|
17
|
+
## 0.0.1-2 (2025-09-11)
|
|
18
|
+
|
|
19
|
+
This was a version bump only for @oneplatformdev/tokens to align it with other projects, there were no code changes.
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneplatformdev/tokens",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-5",
|
|
4
4
|
"description": "tokens",
|
|
5
5
|
"author": "One Platform Development Team",
|
|
6
6
|
"keywords": [
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
40
|
+
"**/*",
|
|
40
41
|
"dist",
|
|
41
42
|
"README.md",
|
|
42
43
|
"LICENSE",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oneplatformdev/tokens",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-6",
|
|
4
4
|
"description": "tokens",
|
|
5
5
|
"author": "One Platform Development Team",
|
|
6
6
|
"keywords": [
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"files": [
|
|
40
|
+
"**/*",
|
|
40
41
|
"dist",
|
|
41
42
|
"README.md",
|
|
42
43
|
"LICENSE",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { BrandTokens } from './index'
|
|
2
|
+
const STYLE_ID = 'oneplatform-brand-tokens'
|
|
3
|
+
|
|
4
|
+
export function applyBrandTokens(tokens: BrandTokens) {
|
|
5
|
+
const el = (document.getElementById(STYLE_ID) as HTMLStyleElement)
|
|
6
|
+
?? Object.assign(document.createElement('style'), { id: STYLE_ID })
|
|
7
|
+
|
|
8
|
+
const set = (k: string, v?: string) => (v ? `--${k}: ${v};` : '')
|
|
9
|
+
el.textContent = `:root{${[
|
|
10
|
+
set('background', tokens.background),
|
|
11
|
+
set('foreground', tokens.foreground),
|
|
12
|
+
set('primary', tokens.primary),
|
|
13
|
+
set('primary-fg', tokens.primaryFg),
|
|
14
|
+
set('muted', tokens.muted),
|
|
15
|
+
set('muted-fg', tokens.mutedFg)
|
|
16
|
+
].join('')}}`
|
|
17
|
+
|
|
18
|
+
if (!el.parentNode) document.head.appendChild(el)
|
|
19
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type BrandTokens = {
|
|
2
|
+
background?: string
|
|
3
|
+
foreground?: string
|
|
4
|
+
primary?: string
|
|
5
|
+
primaryFg?: string
|
|
6
|
+
muted?: string
|
|
7
|
+
mutedFg?: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const defaultTokens: Required<BrandTokens> = {
|
|
11
|
+
background: 'hsl(0 0% 100%)',
|
|
12
|
+
foreground: 'hsl(0 0% 10%)',
|
|
13
|
+
primary: 'hsl(210 90% 50%)',
|
|
14
|
+
primaryFg: 'hsl(0 0% 100%)',
|
|
15
|
+
muted: 'hsl(220 14% 96%)',
|
|
16
|
+
mutedFg: 'hsl(220 8% 35%)'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { applyBrandTokens } from './applyBrandTokens'
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"types": [
|
|
6
|
+
"node",
|
|
7
|
+
"@nx/react/typings/cssmodule.d.ts",
|
|
8
|
+
"@nx/react/typings/image.d.ts",
|
|
9
|
+
"vite/client"
|
|
10
|
+
],
|
|
11
|
+
"rootDir": "src",
|
|
12
|
+
"jsx": "react-jsx",
|
|
13
|
+
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo"
|
|
14
|
+
},
|
|
15
|
+
"exclude": [
|
|
16
|
+
"out-tsc",
|
|
17
|
+
"dist",
|
|
18
|
+
"**/*.spec.ts",
|
|
19
|
+
"**/*.test.ts",
|
|
20
|
+
"**/*.spec.tsx",
|
|
21
|
+
"**/*.test.tsx",
|
|
22
|
+
"**/*.spec.js",
|
|
23
|
+
"**/*.test.js",
|
|
24
|
+
"**/*.spec.jsx",
|
|
25
|
+
"**/*.test.jsx"
|
|
26
|
+
],
|
|
27
|
+
"include": [
|
|
28
|
+
"src/**/*.js",
|
|
29
|
+
"src/**/*.jsx",
|
|
30
|
+
"src/**/*.ts",
|
|
31
|
+
"src/**/*.tsx"
|
|
32
|
+
]
|
|
33
|
+
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/// <reference types='vitest' />
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
3
|
+
import react from '@vitejs/plugin-react';
|
|
4
|
+
import dts from 'vite-plugin-dts';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
import { globSync } from 'glob';
|
|
7
|
+
import { viteStaticCopy } from 'vite-plugin-static-copy';
|
|
8
|
+
|
|
9
|
+
export default defineConfig(() => ({
|
|
10
|
+
root: __dirname,
|
|
11
|
+
cacheDir: '../../node_modules/.vite/packages/tokens',
|
|
12
|
+
plugins: [
|
|
13
|
+
react(),
|
|
14
|
+
viteStaticCopy({
|
|
15
|
+
targets: [
|
|
16
|
+
{
|
|
17
|
+
src: path.join(__dirname, 'package.json'),
|
|
18
|
+
dest: path.join(__dirname, 'dist'),
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
src: path.join(__dirname, 'README.md'),
|
|
22
|
+
dest: path.join(__dirname, 'dist'),
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
src: path.join(__dirname, 'LICENSE'),
|
|
26
|
+
dest: path.join(__dirname, 'dist'),
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}),
|
|
30
|
+
dts({
|
|
31
|
+
entryRoot: 'src',
|
|
32
|
+
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json')
|
|
33
|
+
})
|
|
34
|
+
],
|
|
35
|
+
build: {
|
|
36
|
+
outDir: './dist',
|
|
37
|
+
emptyOutDir: true,
|
|
38
|
+
reportCompressedSize: true,
|
|
39
|
+
commonjsOptions: {
|
|
40
|
+
transformMixedEsModules: true,
|
|
41
|
+
},
|
|
42
|
+
sourcemap: false,
|
|
43
|
+
target: 'es2022',
|
|
44
|
+
lib: {
|
|
45
|
+
name: '@oneplatformdev/tokens',
|
|
46
|
+
formats: [ 'es' as const ],
|
|
47
|
+
entry: {
|
|
48
|
+
index: path.resolve(__dirname, 'src/index.ts'),
|
|
49
|
+
...Object.fromEntries(
|
|
50
|
+
globSync('src/**/*.{ts,tsx}').map((filename) => {
|
|
51
|
+
return [
|
|
52
|
+
path.relative(
|
|
53
|
+
'src',
|
|
54
|
+
filename.slice(0, filename.length - path.extname(filename).length)
|
|
55
|
+
),
|
|
56
|
+
path.resolve(__dirname, filename),
|
|
57
|
+
]
|
|
58
|
+
})
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
rollupOptions: {
|
|
63
|
+
external: [ 'react', 'react-dom', 'react/jsx-runtime', "clsx", "tailwind-merge" ],
|
|
64
|
+
output: {
|
|
65
|
+
preserveModules: true,
|
|
66
|
+
preserveModulesRoot: 'src'
|
|
67
|
+
},
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
}));
|