Skip to content

Commit a6eb154

Browse files
committed
feat(color): default value depends on deps
1 parent fe8f193 commit a6eb154

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ module.exports = {
2929
* `mp` defaults to `false`, setting `mp` be `true` will enable the preset,
3030
* otherwise will enable default config of tailwindcss and disable the preset meanwhile.
3131
*
32-
* `element`, `naive`, `vant`, these params default to false, setting to true will enable the color.
33-
* If your project depends on `element-ui`, `element-plus`, `naive-ui`, `vant-ui`, the color will be enable automatically, even though you set value to false.
32+
* `element`, `naive`, `vant`, these params default to dependencies that your project uses.
33+
* If your project depends on `element-ui`, `element-plus`, `naive-ui`, `vant-ui`,
34+
* the color will be enable automatically.
35+
* Setting to false will disable the color, otherwise will enabled.
36+
*
3437
*
3538
*/
3639
preset({

packages/tailwindcss-color-preset/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@ pnpm add -D tailwindcss @leedomjs/tailwindcss-color-preset
1515
### Config `tailwind.config.js`
1616

1717
```js
18-
/** @type {import('tailwindcss').Config} */
19-
2018
const color = require('@leedomjs/tailwindcss-color-preset')
2119

22-
2320
/**
2421
* There is an object param that contains some fields `element`, `naive`, `vant`.
2522
*
26-
* These params default to false, setting to true will enable the color.
27-
* If your project depends on `element-ui`, `element-plus`, `naive-ui`, `vant-ui`, the color will be enable automatically, even though you set value to false.
23+
* These params default to dependencies that your project uses.
24+
* If your project depends on `element-ui`, `element-plus`, `naive-ui`, `vant-ui`,
25+
* the color will be enable automatically.
26+
* Setting to false will disable the color, otherwise will enabled.
2827
*
2928
*/
29+
30+
/** @type {import('tailwindcss').Config} */
3031
module.exports = {
3132
presets: [
3233
color({

packages/tailwindcss-color-preset/src/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@ const NAIVE: boolean = isPackageExists('naive-ui')
1212
const VANT: boolean = isPackageExists('vant')
1313

1414
export default (opt: ColorOption = {
15-
element: false,
16-
naive: false,
17-
vant: false,
15+
element: ELEMENT,
16+
naive: NAIVE,
17+
vant: VANT,
1818
}) => ({
1919
theme: {
2020
extend: {
2121
colors: {
22-
...((opt.element || ELEMENT) ? ElColors : {}),
23-
...((opt.naive || NAIVE) ? NaiveColors : {}),
24-
...((opt.vant || VANT) ? VanColors : {}),
22+
...(opt.element ? ElColors : {}),
23+
...(opt.naive ? NaiveColors : {}),
24+
...(opt.vant ? VanColors : {}),
2525
},
2626
backgroundImage: {
27-
...((opt.vant || VANT) ? VanBackground : {}),
27+
...(opt.vant ? VanBackground : {}),
2828
},
2929
},
3030
},

0 commit comments

Comments
 (0)