Skip to content

Commit

Permalink
Merge pull request #53 from crswll/simplify-transparency
Browse files Browse the repository at this point in the history
  • Loading branch information
crswll authored May 4, 2024
2 parents 10d37ec + 6de91a0 commit cda7554
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tailwindcss-theme-swapper",
"version": "0.11.0",
"version": "0.11.1",
"main": "src/index.js",
"license": "MIT",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function toConfigValue (keys, value) {
}

if (colorConfigKeys.includes(keys[0])) {
return `color-mix(in srgb, var(--${getTailwindKeyName(keys)}), transparent calc(100% - 100% * <alpha-value>))`
return `color-mix(in srgb, var(--${getTailwindKeyName(keys)}) calc(100% * <alpha-value>), transparent)`
}

return `var(--${getTailwindKeyName(keys)})`
Expand Down
8 changes: 4 additions & 4 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ postcss(tailwindcss({
expect(resolvedConfig).toMatchObject({
"theme": {
"colors": {
"with-opacity": "color-mix(in srgb, var(--colors-with-opacity), transparent calc(100% - 100% * <alpha-value>))",
"hotpink": "color-mix(in srgb, var(--colors-hotpink), transparent calc(100% - 100% * <alpha-value>))",
"with-opacity": "color-mix(in srgb, var(--colors-with-opacity) calc(100% * <alpha-value>), transparent)",
"hotpink": "color-mix(in srgb, var(--colors-hotpink) calc(100% * <alpha-value>), transparent)",
"primary": {
"default": "color-mix(in srgb, var(--colors-primary), transparent calc(100% - 100% * <alpha-value>))",
"darker": "color-mix(in srgb, var(--colors-primary-darker), transparent calc(100% - 100% * <alpha-value>))",
"default": "color-mix(in srgb, var(--colors-primary) calc(100% * <alpha-value>), transparent)",
"darker": "color-mix(in srgb, var(--colors-primary-darker) calc(100% * <alpha-value>), transparent)",
}
},
"spacing": {
Expand Down
8 changes: 4 additions & 4 deletions test/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ describe('getThemeAsCustomProps', () => {

expect(result).toEqual({
colors: {
red: "color-mix(in srgb, var(--colors-red), transparent calc(100% - 100% * <alpha-value>))",
red: "color-mix(in srgb, var(--colors-red) calc(100% * <alpha-value>), transparent)",
primary: {
default: "color-mix(in srgb, var(--colors-primary), transparent calc(100% - 100% * <alpha-value>))",
darker: "color-mix(in srgb, var(--colors-primary-darker), transparent calc(100% - 100% * <alpha-value>))",
default: "color-mix(in srgb, var(--colors-primary) calc(100% * <alpha-value>), transparent)",
darker: "color-mix(in srgb, var(--colors-primary-darker) calc(100% * <alpha-value>), transparent)",
},
},
fontSize: {
Expand Down Expand Up @@ -156,7 +156,7 @@ describe('getThemeAsCustomProps', () => {
})

test('should just return the value when it is not a color', () => {
expect(tailwindConfigValueTransformer(['colors', 'primary'], 'rgb(255, 0, 0)')).toEqual('color-mix(in srgb, var(--colors-primary), transparent calc(100% - 100% * <alpha-value>))')
expect(tailwindConfigValueTransformer(['colors', 'primary'], 'rgb(255, 0, 0)')).toEqual('color-mix(in srgb, var(--colors-primary) calc(100% * <alpha-value>), transparent)')
expect(tailwindConfigValueTransformer(['fontSize'], '16px')).toEqual('var(--font-size)')
})
})
Expand Down

0 comments on commit cda7554

Please sign in to comment.