daisyui 1.25.3 → 2.0.0-next.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/index.js CHANGED
@@ -1,16 +1,16 @@
1
- const daisyuiInfo = require('./package.json')
2
- const colors = require('./colors/index')
3
- const utilities = require('./dist/utilities')
4
- const base = require('./dist/base')
5
- const unstyled = require('./dist/unstyled')
6
- const unstyledRtl = require('./dist/unstyled.rtl')
7
- const styled = require('./dist/styled')
8
- const styledRtl = require('./dist/styled.rtl')
1
+ const daisyuiInfo = require('./package.json')
2
+ const colors = require('./colors/index')
3
+ const utilities = require('./dist/utilities')
4
+ const base = require('./dist/base')
5
+ const unstyled = require('./dist/unstyled')
6
+ const unstyledRtl = require('./dist/unstyled.rtl')
7
+ const styled = require('./dist/styled')
8
+ const styledRtl = require('./dist/styled.rtl')
9
9
  const utilitiesUnstyled = require('./dist/utilities-unstyled')
10
- const utilitiesStyled = require('./dist/utilities-styled')
11
- const themes = require('./colors/themes')
12
- const colorNames = require('./colors/colorNames')
13
- const hex2hsl = require('./colors/hex2hsl')
10
+ const utilitiesStyled = require('./dist/utilities-styled')
11
+ const themes = require('./colors/themes')
12
+ const colorNames = require('./colors/colorNames')
13
+ const Color = require('color');
14
14
 
15
15
  const mainFunction = ({ addBase, addComponents, addUtilities, config }) => {
16
16
  let diasyuiIncludedItems = []
@@ -56,9 +56,10 @@ const mainFunction = ({ addBase, addComponents, addUtilities, config }) => {
56
56
  let resultObj = {}
57
57
  if (typeof input === 'object' && input !== null) {
58
58
  Object.entries(input).forEach(([rule, value]) => {
59
- if(colorNames.hasOwnProperty(rule)){
60
- resultObj[colorNames[rule]] = hex2hsl(value)
61
- }else{
59
+ if (colorNames.hasOwnProperty(rule)) {
60
+ const hslArray = Color(value).hsl().round().array()
61
+ resultObj[colorNames[rule]] = hslArray[0] + " " + hslArray[1] + "%" + " " + hslArray[2] + "%"
62
+ } else {
62
63
  resultObj[rule] = value
63
64
  // console.log(input)
64
65
  }
@@ -83,48 +84,54 @@ const mainFunction = ({ addBase, addComponents, addUtilities, config }) => {
83
84
  }
84
85
 
85
86
  // add custom themes
86
- if(Array.isArray(config('daisyui.themes'))){
87
+ if (Array.isArray(config('daisyui.themes'))) {
87
88
  config('daisyui.themes').forEach((item, index) => {
88
- if(typeof item === 'object' && item !== null){
89
+ if (typeof item === 'object' && item !== null) {
89
90
  Object.entries(item).forEach(([customThemeName, customThemevalue]) => {
90
- includedThemesObj['[data-theme='+customThemeName+']'] = convertThemeColorsToHsl(customThemevalue)
91
+ includedThemesObj['[data-theme=' + customThemeName + ']'] = convertThemeColorsToHsl(customThemevalue)
91
92
  })
92
93
  }
93
94
  })
94
95
  }
95
96
 
96
97
  let themeOrder = []
97
- if (Array.isArray( config('daisyui.themes') )) {
98
+ if (Array.isArray(config('daisyui.themes'))) {
98
99
  config('daisyui.themes').forEach((theme, index) => {
99
- if (typeof theme === 'object' && theme !== null){
100
+ if (typeof theme === 'object' && theme !== null) {
100
101
  Object.entries(theme).forEach(([customThemeName, customThemevalue]) => {
101
102
  themeOrder.push(customThemeName)
102
103
  })
103
- }else if(includedThemesObj.hasOwnProperty('[data-theme='+theme+']')){
104
+ } else if (includedThemesObj.hasOwnProperty('[data-theme=' + theme + ']')) {
104
105
  themeOrder.push(theme)
105
106
  }
106
107
  })
107
- }else if (config('daisyui.themes') != false) {
108
- themeOrder= ['light','dark','cupcake','bumblebee','emerald','corporate','synthwave','retro','cyberpunk','valentine','halloween','garden','forest','aqua','lofi','pastel','fantasy','wireframe','black','luxury','dracula','cmyk',]
109
- }else if (config('daisyui.themes') == false) {
108
+ } else if (config('daisyui.themes') != false) {
109
+ themeOrder = ['light', 'dark', 'cupcake', 'bumblebee', 'emerald', 'corporate', 'synthwave', 'retro', 'cyberpunk', 'valentine', 'halloween', 'garden', 'forest', 'aqua', 'lofi', 'pastel', 'fantasy', 'wireframe', 'black', 'luxury', 'dracula', 'cmyk',]
110
+ } else if (config('daisyui.themes') == false) {
110
111
  themeOrder.push('light')
111
112
  }
112
113
 
113
114
  // inject themes in order
114
115
  themeOrder.forEach((themeName, index) => {
115
116
  if (index === 0) { // first theme as root
116
- addBase({[':root']: includedThemesObj['[data-theme='+themeName+']']})
117
- }else if (index === 1) {
117
+ addBase({ [':root']: includedThemesObj['[data-theme=' + themeName + ']'] })
118
+ } else if (index === 1) {
118
119
  // auto dark
119
- if (themeOrder[0] != 'dark' && themeOrder.includes('dark')){
120
- addBase({['@media (prefers-color-scheme: dark)']: {[':root']: includedThemesObj['[data-theme=dark]']}})
120
+ if (config('daisyui.darkTheme')) {
121
+ if (themeOrder[0] != config('daisyui.darkTheme') && themeOrder.includes(config('daisyui.darkTheme'))) {
122
+ addBase({ ['@media (prefers-color-scheme: dark)']: { [':root']: includedThemesObj[`[data-theme=${config('daisyui.darkTheme')}]`] } })
123
+ }
124
+ } else {
125
+ if (themeOrder[0] != 'dark' && themeOrder.includes('dark')) {
126
+ addBase({ ['@media (prefers-color-scheme: dark)']: { [':root']: includedThemesObj['[data-theme=dark]'] } })
127
+ }
121
128
  }
122
129
  // theme 0 with name
123
- addBase({['[data-theme='+themeOrder[0]+']']: includedThemesObj['[data-theme='+themeOrder[0]+']']})
130
+ addBase({ ['[data-theme=' + themeOrder[0] + ']']: includedThemesObj['[data-theme=' + themeOrder[0] + ']'] })
124
131
  // theme 1 with name
125
- addBase({['[data-theme='+themeOrder[1]+']']: includedThemesObj['[data-theme='+themeOrder[1]+']']})
126
- }else{
127
- addBase({['[data-theme='+themeName+']']: includedThemesObj['[data-theme='+themeName+']']})
132
+ addBase({ ['[data-theme=' + themeOrder[1] + ']']: includedThemesObj['[data-theme=' + themeOrder[1] + ']'] })
133
+ } else {
134
+ addBase({ ['[data-theme=' + themeName + ']']: includedThemesObj['[data-theme=' + themeName + ']'] })
128
135
  }
129
136
  })
130
137
  diasyuiIncludedItems.push('themes[' + themeOrder.length + ']')
@@ -139,40 +146,14 @@ const mainFunction = ({ addBase, addComponents, addUtilities, config }) => {
139
146
  }
140
147
  if (logs) {
141
148
  console.log('\x1b[32m%s\x1b[0m', '✔︎ Including:', '\x1b[0m', '' + diasyuiIncludedItems.join(', '));
142
- if (isTailwindInstalled === false) {
143
- console.log(`\n\x1b[33;1m! warning\x1b[0m - unable to require \x1b[36mtailwindcss/plugin\x1b[0m
144
- daisyUI color are now only available for daisyUI components.
145
- If you want to use daisyUI color as utility classes (like 'bg-primary')
146
- you need to add this to your \x1b[34mtailwind.config.js\x1b[0m file:
147
- ───────────────────────────────────────
148
- \x1b[34mmodule.exports = {
149
- \x1b[32mtheme: {
150
- extend: {
151
- colors: require('daisyui/colors'),
152
- },
153
- },\x1b[0m
154
- \x1b[34m}\x1b[0m
155
- ───────────────────────────────────────
156
- `)
157
- }
158
149
  console.log()
159
150
  console.groupEnd()
160
151
  }
161
152
  }
162
153
 
163
- // check if tailwindcss package exists
164
- let isTailwindInstalled = false;
165
- try {
166
- require.resolve('tailwindcss/plugin')
167
- isTailwindInstalled = true
168
- } catch (er) {
169
- isTailwindInstalled = false
170
- }
171
- if (isTailwindInstalled !== false) {
172
- module.exports = require("tailwindcss/plugin")(
173
- mainFunction, { theme: { extend: { colors } } }
174
- );
175
- } else {
176
- module.exports = mainFunction;
177
- }
154
+
155
+ module.exports = require("tailwindcss/plugin")(
156
+ mainFunction, { theme: { extend: { colors } } }
157
+ );
158
+
178
159
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daisyui",
3
- "version": "1.25.3",
3
+ "version": "2.0.0-next.2",
4
4
  "description": "daisyUI - Tailwind CSS Components",
5
5
  "author": "Pouya Saadeghi",
6
6
  "license": "MIT",
@@ -35,6 +35,9 @@
35
35
  "index.js",
36
36
  "colors"
37
37
  ],
38
+ "browserslist": [
39
+ "> 7%"
40
+ ],
38
41
  "publishConfig": {
39
42
  "access": "public",
40
43
  "branches": [
@@ -49,8 +52,7 @@
49
52
  "postcss-import": "13.0.0",
50
53
  "postcss-nested": "5.0.1",
51
54
  "prejss-cli": "0.3.3",
52
- "rtlcss": "3.0.0",
53
- "tailwindcss": "2.0.1"
55
+ "rtlcss": "3.0.0"
54
56
  },
55
57
  "scripts": {
56
58
  "index": "cp -R ./src/index.js ./index.js",
@@ -80,5 +82,9 @@
80
82
  "dev": "cd src/docs && npm run dev",
81
83
  "add": "touch src/components/unstyled/$npm_config_name.css && touch src/components/styled/$npm_config_name.css",
82
84
  "postadd": "open src/components/unstyled/$npm_config_name.css && open src/components/styled/$npm_config_name.css"
85
+ },
86
+ "dependencies": {
87
+ "color": "^4.2",
88
+ "tailwindcss": "^3.0"
83
89
  }
84
90
  }