Skip to content

Commit

Permalink
feat: Add support for WindiCSS
Browse files Browse the repository at this point in the history
Support WindiCSS color format in tailwind.config.js

- Moves the colors.js file into /colors/index.
- Moves the colorValues variable into its own file.
- Creates a new `colors/windi.js` file, which allows user to `require(‘daisyui/colors/windi’)`
  • Loading branch information
marshallswain committed Mar 27, 2021
1 parent 98aa0a7 commit 4f0c5d5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
20 changes: 1 addition & 19 deletions colors.js → colors/color-values.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
let colorValues = {
module.exports = {
"primary" : {name: "p", value: "259 94% 51%"},
"primary-focus" : {name: "pf", value: "259 94% 41%"},
"primary-content" : {name: "pc", value: "0 0% 100%"},
Expand All @@ -25,21 +25,3 @@ let colorValues = {
"warning" : {name: "wa", value: "36 100% 50%"},
"error" : {name: "er", value: "14 100% 57%"},
}

let colorObject = {
"transparent": "transparent",
}

for (const [key, item] of Object.entries(colorValues)) {
colorObject[key] = ({ opacityVariable, opacityValue }) => {
if (opacityValue !== undefined) {
return `hsla(var(--`+ item['name'] +`, `+ item['value'] +`) / ${opacityValue})`
}
if (opacityVariable !== undefined) {
return `hsla(var(--`+ item['name'] +`, `+ item['value'] +`) / var(${opacityVariable}, 1))`
}
return `hsl(var(--`+ item['name'] +`, `+ item['value']+ `))`
}
}

module.exports = colorObject;
19 changes: 19 additions & 0 deletions colors/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const colorValues = require('./color-values')

let colorObject = {
"transparent": "transparent",
}

for (const [key, item] of Object.entries(colorValues)) {
colorObject[key] = ({ opacityVariable, opacityValue }) => {
if (opacityValue !== undefined) {
return `hsla(var(--`+ item['name'] +`, `+ item['value'] +`) / ${opacityValue})`
}
if (opacityVariable !== undefined) {
return `hsla(var(--`+ item['name'] +`, `+ item['value'] +`) / var(${opacityVariable}, 1))`
}
return `hsl(var(--`+ item['name'] +`, `+ item['value']+ `))`
}
}

module.exports = colorObject
11 changes: 11 additions & 0 deletions colors/windi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const colorValues = require('./color-values')

let colorObject = {
"transparent": "transparent",
}

for (const [key, item] of Object.entries(colorValues)) {
colorObject[key] = `hsla(var(--${item.name}, ${item.value}) / var(--tw-bg-opacity, 1))`
}

module.exports = colorObject

0 comments on commit 4f0c5d5

Please sign in to comment.