shru-design-system 0.0.1

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/package.json ADDED
@@ -0,0 +1,101 @@
1
+ {
2
+ "name": "shru-design-system",
3
+ "version": "0.0.1",
4
+ "description": "A comprehensive design system with theme toggle, components, and token-based theming",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "design-system",
8
+ "theme-toggle",
9
+ "react",
10
+ "components",
11
+ "tailwind",
12
+ "css-variables",
13
+ "theming",
14
+ "ui-components"
15
+ ],
16
+ "type": "module",
17
+ "main": "dist/index.cjs",
18
+ "module": "dist/index.js",
19
+ "types": "dist/index.d.ts",
20
+ "files": [
21
+ "dist",
22
+ "src/tokens",
23
+ "scripts",
24
+ "apps/design-system/styles/globals.css"
25
+ ],
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js",
30
+ "require": "./dist/index.cjs"
31
+ },
32
+ "./styles": "./apps/design-system/styles/globals.css"
33
+ },
34
+ "workspaces": [
35
+ "apps/*"
36
+ ],
37
+ "scripts": {
38
+ "build": "tsup src/index.ts --dts --format esm,cjs",
39
+ "build:lib": "tsup src/index.ts --dts --format esm,cjs",
40
+ "postinstall": "npm run build:lib",
41
+ "copy:tokens": "node scripts/copy-tokens.js",
42
+ "copy:globals": "node scripts/copy-globals.js",
43
+ "dev": "turbo run dev --parallel",
44
+ "lint": "turbo run lint",
45
+ "lint:fix": "turbo run lint:fix",
46
+ "preview": "turbo run preview",
47
+ "typecheck": "turbo run typecheck",
48
+ "format:write": "turbo run format:write",
49
+ "format:check": "turbo run format:check",
50
+ "check": "turbo lint typecheck format:check"
51
+ },
52
+ "bin": {
53
+ "copy-tokens": "./scripts/copy-tokens.js",
54
+ "copy-globals": "./scripts/copy-globals.js"
55
+ },
56
+ "peerDependencies": {
57
+ "react": ">=18",
58
+ "react-dom": ">=18"
59
+ },
60
+ "packageManager": "pnpm@9.0.6",
61
+ "dependencies": {
62
+ "@babel/core": "^7.22.1",
63
+ "@commitlint/cli": "^17.6.3",
64
+ "@commitlint/config-conventional": "^17.6.3",
65
+ "@ianvs/prettier-plugin-sort-imports": "^3.7.2",
66
+ "@manypkg/cli": "^0.20.0",
67
+ "@typescript-eslint/parser": "^5.59.7",
68
+ "autoprefixer": "^10.4.14",
69
+ "concurrently": "^8.0.1",
70
+ "cross-env": "^7.0.3",
71
+ "eslint": "^8.41.0",
72
+ "eslint-config-next": "13.3.0",
73
+ "eslint-config-prettier": "^8.8.0",
74
+ "eslint-config-turbo": "^1.9.9",
75
+ "eslint-plugin-react": "^7.32.2",
76
+ "eslint-plugin-tailwindcss": "3.13.1",
77
+ "motion": "^12.12.1",
78
+ "prettier": "^2.8.8",
79
+ "pretty-quick": "^3.1.3",
80
+ "tailwindcss": "^3.4.18",
81
+ "tsx": "^4.1.4",
82
+ "turbo": "^1.9.9",
83
+ "vite": "^7.1.12",
84
+ "vite-tsconfig-paths": "^4.2.0",
85
+ "vitest": "^2.1.9"
86
+ },
87
+ "devDependencies": {
88
+ "@types/hast": "^3.0.4",
89
+ "@types/node": "^20.11.27",
90
+ "@types/react": "^18.2.65",
91
+ "@types/react-dom": "^18.2.22",
92
+ "tsup": "^8.5.1",
93
+ "typescript": "^5.5.3"
94
+ },
95
+ "pnpm": {
96
+ "overrides": {
97
+ "@types/react": "19.2.2",
98
+ "@types/react-dom": "19.2.2"
99
+ }
100
+ }
101
+ }
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Copy Globals CSS Script
5
+ * Copies globals.css from the package to the user's project
6
+ */
7
+
8
+ const fs = require('fs')
9
+ const path = require('path')
10
+
11
+ // Try to find globals.css in multiple locations
12
+ let sourceFile
13
+ const nodeModulesPath = path.join(process.cwd(), 'node_modules/@shru/theme-toggle')
14
+
15
+ // Try different possible locations
16
+ const possibleSources = [
17
+ path.join(nodeModulesPath, 'apps/design-system/styles/globals.css'), // GitHub install
18
+ path.join(nodeModulesPath, 'globals.css'), // If included in package files
19
+ path.join(__dirname, '../apps/design-system/styles/globals.css'), // Development/repo root
20
+ ]
21
+
22
+ for (const possibleSource of possibleSources) {
23
+ if (fs.existsSync(possibleSource)) {
24
+ sourceFile = possibleSource
25
+ break
26
+ }
27
+ }
28
+
29
+ // Default target locations to try (in order of preference)
30
+ const possibleTargets = [
31
+ path.join(process.cwd(), 'app/globals.css'),
32
+ path.join(process.cwd(), 'src/app/globals.css'),
33
+ path.join(process.cwd(), 'styles/globals.css'),
34
+ path.join(process.cwd(), 'src/styles/globals.css'),
35
+ ]
36
+
37
+ function findExistingGlobals() {
38
+ for (const target of possibleTargets) {
39
+ if (fs.existsSync(target)) {
40
+ return target
41
+ }
42
+ }
43
+ return null
44
+ }
45
+
46
+ function findBestTarget() {
47
+ // Check if any globals.css already exists
48
+ const existing = findExistingGlobals()
49
+ if (existing) {
50
+ return existing
51
+ }
52
+
53
+ // Use the first possible target that has a parent directory
54
+ for (const target of possibleTargets) {
55
+ const parentDir = path.dirname(target)
56
+ if (fs.existsSync(parentDir)) {
57
+ return target
58
+ }
59
+ }
60
+
61
+ // Default to app/globals.css
62
+ return possibleTargets[0]
63
+ }
64
+
65
+ try {
66
+ if (!sourceFile || !fs.existsSync(sourceFile)) {
67
+ console.error('Source file not found. Tried:')
68
+ const possibleSources = [
69
+ path.join(nodeModulesPath, 'apps/design-system/styles/globals.css'),
70
+ path.join(nodeModulesPath, 'globals.css'),
71
+ path.join(__dirname, '../apps/design-system/styles/globals.css'),
72
+ ]
73
+ possibleSources.forEach(src => console.error(` - ${src}`))
74
+ console.error('\nMake sure you are running this from a project that has @shru/theme-toggle installed')
75
+ console.error('Or run this from the repository root if developing')
76
+ process.exit(1)
77
+ }
78
+
79
+ const targetFile = findBestTarget()
80
+ const targetDir = path.dirname(targetFile)
81
+
82
+ // Create target directory if it doesn't exist
83
+ if (!fs.existsSync(targetDir)) {
84
+ fs.mkdirSync(targetDir, { recursive: true })
85
+ }
86
+
87
+ // Check if file already exists
88
+ if (fs.existsSync(targetFile)) {
89
+ console.warn(`⚠️ File already exists: ${targetFile}`)
90
+ console.warn('Skipping copy. If you want to overwrite, delete the file first.')
91
+ console.log(`\nCurrent globals.css location: ${targetFile}`)
92
+ process.exit(0)
93
+ }
94
+
95
+ console.log(`Copying globals.css from ${sourceFile} to ${targetFile}...`)
96
+ fs.copyFileSync(sourceFile, targetFile)
97
+ console.log('✅ globals.css copied successfully!')
98
+ console.log(`\nFile location: ${targetFile}`)
99
+ console.log('\nNext steps:')
100
+ console.log(` 1. Import it in your root layout: import './globals.css'`)
101
+ console.log(' 2. Make sure Tailwind v4 is installed: npm install tailwindcss@next @tailwindcss/postcss@next')
102
+ console.log(' 3. Configure PostCSS with @tailwindcss/postcss plugin')
103
+ } catch (error) {
104
+ console.error('Error copying globals.css:', error)
105
+ process.exit(1)
106
+ }
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Copy Tokens Script
5
+ * Copies token files from the package to the user's public folder
6
+ */
7
+
8
+ const fs = require('fs')
9
+ const path = require('path')
10
+
11
+ const sourceDir = path.join(__dirname, '../src/tokens')
12
+ const targetDir = path.join(process.cwd(), 'public/tokens')
13
+
14
+ function copyRecursive(src, dest) {
15
+ const exists = fs.existsSync(src)
16
+ const stats = exists && fs.statSync(src)
17
+ const isDirectory = exists && stats.isDirectory()
18
+
19
+ if (isDirectory) {
20
+ if (!fs.existsSync(dest)) {
21
+ fs.mkdirSync(dest, { recursive: true })
22
+ }
23
+ fs.readdirSync(src).forEach(childItemName => {
24
+ copyRecursive(
25
+ path.join(src, childItemName),
26
+ path.join(dest, childItemName)
27
+ )
28
+ })
29
+ } else {
30
+ // Ensure parent directory exists
31
+ const parentDir = path.dirname(dest)
32
+ if (!fs.existsSync(parentDir)) {
33
+ fs.mkdirSync(parentDir, { recursive: true })
34
+ }
35
+ fs.copyFileSync(src, dest)
36
+ }
37
+ }
38
+
39
+ try {
40
+ if (!fs.existsSync(sourceDir)) {
41
+ console.error(`Source directory not found: ${sourceDir}`)
42
+ console.error('Make sure you are running this from a project that has @shru/theme-toggle installed')
43
+ process.exit(1)
44
+ }
45
+
46
+ // Create target directory if it doesn't exist
47
+ if (!fs.existsSync(path.join(process.cwd(), 'public'))) {
48
+ fs.mkdirSync(path.join(process.cwd(), 'public'), { recursive: true })
49
+ }
50
+
51
+ console.log(`Copying tokens from ${sourceDir} to ${targetDir}...`)
52
+ copyRecursive(sourceDir, targetDir)
53
+ console.log('✅ Tokens copied successfully!')
54
+ console.log(`\nTokens are now available at: ${targetDir}`)
55
+ console.log('\nYou can now add custom token files to extend themes:')
56
+ console.log(' - Add new theme files to public/tokens/themes/{category}/{name}.json')
57
+ console.log(' - Use registerTheme() or they will be auto-discovered on next load')
58
+ } catch (error) {
59
+ console.error('Error copying tokens:', error)
60
+ process.exit(1)
61
+ }
62
+
@@ -0,0 +1,161 @@
1
+ {
2
+ "color": {
3
+ "primary": "{palette.blue.500}",
4
+ "primary-hover": "{palette.blue.600}",
5
+ "primary-foreground": "{palette.white}",
6
+ "secondary": "{palette.gray.100}",
7
+ "secondary-foreground": "{palette.gray.900}",
8
+ "background": "{palette.white}",
9
+ "foreground": "{palette.gray.900}",
10
+ "card": "{palette.white}",
11
+ "card-foreground": "{palette.gray.900}",
12
+ "popover": "{palette.white}",
13
+ "popover-foreground": "{palette.gray.900}",
14
+ "muted": "{palette.gray.100}",
15
+ "muted-foreground": "{palette.gray.500}",
16
+ "accent": "{palette.gray.100}",
17
+ "accent-foreground": "{palette.gray.900}",
18
+ "destructive": "{palette.red.500}",
19
+ "destructive-foreground": "{palette.white}",
20
+ "border": "{palette.gray.200}",
21
+ "input": "{palette.gray.200}",
22
+ "ring": "{palette.gray.400}",
23
+ "chart-1": "{palette.blue.300}",
24
+ "chart-2": "{palette.blue.500}",
25
+ "chart-3": "{palette.blue.600}",
26
+ "chart-4": "{palette.blue.700}",
27
+ "chart-5": "{palette.blue.800}",
28
+ "sidebar": "{palette.white}",
29
+ "sidebar-foreground": "{palette.gray.900}",
30
+ "sidebar-primary": "{palette.blue.600}",
31
+ "sidebar-primary-foreground": "{palette.white}",
32
+ "sidebar-accent": "{palette.gray.100}",
33
+ "sidebar-accent-foreground": "{palette.gray.900}",
34
+ "sidebar-border": "{palette.gray.200}",
35
+ "sidebar-ring": "{palette.gray.400}",
36
+ "surface": "{palette.gray.50}",
37
+ "surface-foreground": "{palette.gray.900}",
38
+ "code": "{palette.gray.50}",
39
+ "code-foreground": "{palette.gray.900}",
40
+ "code-highlight": "{palette.gray.100}",
41
+ "code-number": "{palette.gray.500}",
42
+ "selection": "{palette.gray.900}",
43
+ "selection-foreground": "{palette.white}",
44
+ "skeleton": "{palette.gray.200}"
45
+ },
46
+ "spacing": {
47
+ "component": {
48
+ "xs": "0.25rem",
49
+ "sm": "0.5rem",
50
+ "md": "1rem",
51
+ "lg": "1.5rem",
52
+ "xl": "2rem"
53
+ },
54
+ "layout": {
55
+ "sm": "1rem",
56
+ "md": "2rem",
57
+ "lg": "3rem",
58
+ "xl": "4rem",
59
+ "2xl": "6rem"
60
+ },
61
+ "section": {
62
+ "sm": "2rem",
63
+ "md": "4rem",
64
+ "lg": "6rem",
65
+ "xl": "8rem"
66
+ },
67
+ "base": "0.25rem"
68
+ },
69
+ "typography": {
70
+ "font": {
71
+ "sans": "var(--font-sans)",
72
+ "mono": "var(--font-mono)"
73
+ },
74
+ "fontSize": {
75
+ "xs": "0.75rem",
76
+ "sm": "0.875rem",
77
+ "base": "1rem",
78
+ "lg": "1.125rem",
79
+ "xl": "1.25rem",
80
+ "2xl": "1.5rem",
81
+ "3xl": "1.875rem",
82
+ "4xl": "2.25rem",
83
+ "5xl": "3rem",
84
+ "6xl": "3.75rem",
85
+ "7xl": "4.5rem",
86
+ "8xl": "6rem"
87
+ },
88
+ "fontWeight": {
89
+ "normal": "400",
90
+ "medium": "500",
91
+ "semibold": "600",
92
+ "bold": "700"
93
+ },
94
+ "lineHeight": {
95
+ "tight": "1.25",
96
+ "normal": "1.5",
97
+ "relaxed": "1.75"
98
+ }
99
+ },
100
+ "shape": {
101
+ "radius": {
102
+ "none": "0",
103
+ "sm": "0.25rem",
104
+ "md": "0.5rem",
105
+ "lg": "0.625rem",
106
+ "xl": "0.75rem",
107
+ "2xl": "1rem",
108
+ "full": "9999px"
109
+ },
110
+ "radiusComponent": {
111
+ "button": "{shape.radius.md}",
112
+ "card": "{shape.radius.lg}",
113
+ "input": "{shape.radius.md}",
114
+ "modal": "{shape.radius.xl}",
115
+ "tooltip": "{shape.radius.md}",
116
+ "badge": "{shape.radius.full}"
117
+ }
118
+ },
119
+ "motion": {
120
+ "duration": {
121
+ "fast": "150ms",
122
+ "normal": "200ms",
123
+ "slow": "300ms"
124
+ },
125
+ "easing": {
126
+ "ease": "cubic-bezier(0.4, 0, 0.2, 1)",
127
+ "ease-in": "cubic-bezier(0.4, 0, 1, 1)",
128
+ "ease-out": "cubic-bezier(0, 0, 0.2, 1)",
129
+ "ease-in-out": "cubic-bezier(0.4, 0, 0.2, 1)"
130
+ }
131
+ },
132
+ "shadow": {
133
+ "xs": "0 1px 2px 0 rgb(0 0 0 / 0.05)",
134
+ "sm": "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
135
+ "md": "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",
136
+ "lg": "0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",
137
+ "xl": "0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)",
138
+ "2xl": "0 25px 50px -12px rgb(0 0 0 / 0.25)",
139
+ "none": "none"
140
+ },
141
+ "zIndex": {
142
+ "base": "0",
143
+ "dropdown": "1000",
144
+ "sticky": "1020",
145
+ "fixed": "1030",
146
+ "modal-backdrop": "1040",
147
+ "modal": "1050",
148
+ "popover": "1060",
149
+ "tooltip": "1070"
150
+ },
151
+ "breakpoint": {
152
+ "sm": "640px",
153
+ "md": "768px",
154
+ "lg": "1024px",
155
+ "xl": "1280px",
156
+ "2xl": "1536px",
157
+ "3xl": "1600px",
158
+ "4xl": "2000px"
159
+ }
160
+ }
161
+