colbrush 1.0.0 → 1.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.
@@ -1,27 +1,27 @@
1
- <svg width="42" height="30" viewBox="0 0 42 30" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <g clip-path="url(#clip0_85_784)" filter="url(#filter0_d_85_784)">
3
- <path d="M3 3H39V27H3V3Z" fill="white"/>
4
- <path fill-rule="evenodd" clip-rule="evenodd" d="M8.49609 10.27L11.8243 5.27771L12.7001 5.86161L9.37194 10.8539L8.49609 10.27ZM9.74417 11.1021L13.0724 6.10976L13.9482 6.69366L10.62 11.686L9.74417 11.1021ZM10.9922 11.9341L14.3204 6.94181L15.1963 7.52571L11.8681 12.518L10.9922 11.9341ZM26.8012 22.4734L30.1294 17.4811L31.0053 18.065L27.6771 23.0573L26.8012 22.4734ZM28.0493 23.3055L31.3775 18.3131L32.2533 18.897L28.9251 23.8893L28.0493 23.3055ZM33.5014 19.7291L30.1732 24.7214L29.2974 24.1375L32.6256 19.1452L33.5014 19.7291Z" fill="black"/>
5
- <path fill-rule="evenodd" clip-rule="evenodd" d="M31.9884 22.8526L27.8281 20.0791L28.3147 19.3492L32.475 22.1227L31.9884 22.8526Z" fill="white"/>
6
- <path d="M25.9915 18.3277C27.8296 15.5705 27.0846 11.8453 24.3274 10.0072C21.5702 8.16905 17.845 8.9141 16.0069 11.6713C14.1688 14.4284 14.9138 18.1537 17.671 19.9918C20.4282 21.8299 24.1534 21.0848 25.9915 18.3277Z" fill="#CA163A"/>
7
- <path d="M16.0069 11.6713C15.0883 13.0491 15.4611 14.9129 16.839 15.8315C18.2168 16.7501 20.0806 16.3773 20.9992 14.9995C21.9178 13.6216 23.7816 13.2488 25.1595 14.1674C26.5373 15.086 26.9101 16.9498 25.9915 18.3277C24.1544 21.0834 20.4268 21.8289 17.671 19.9918C14.9153 18.1546 14.1697 14.427 16.0069 11.6713Z" fill="#0E4896"/>
8
- <path fill-rule="evenodd" clip-rule="evenodd" d="M30.1732 5.27734L33.5014 10.2697L32.6255 10.8536L29.2973 5.86124L30.1732 5.27734ZM28.9251 6.10942L32.2533 11.1017L31.3775 11.6856L28.0493 6.69332L28.9251 6.10942ZM27.677 6.94146L31.0052 11.9337L30.1294 12.5176L26.8012 7.52536L27.677 6.94146ZM11.868 17.4807L15.1962 22.4731L14.3204 23.057L10.9922 18.0646L11.868 17.4807ZM10.6199 18.3128L13.9481 23.3051L13.0723 23.889L9.74409 18.8967L10.6199 18.3128ZM9.37194 19.1449L12.7001 24.1372L11.8243 24.7211L8.49609 19.7288L9.37194 19.1449Z" fill="black"/>
9
- <path d="M11.2241 21.5159L12.4722 20.6839L11.2241 21.5159ZM28.0714 10.2844L29.5292 9.31252L28.0714 10.2844ZM30.7773 8.48048L32.0254 7.64844L30.7773 8.48048Z" fill="black"/>
10
- <path fill-rule="evenodd" clip-rule="evenodd" d="M32.2688 8.01308L31.0207 8.84512L30.5341 8.11524L31.7822 7.2832L32.2688 8.01308ZM29.7726 9.67715L28.3148 10.649L27.8283 9.91912L29.286 8.94728L29.7726 9.67715ZM12.7156 21.0486L11.4675 21.8806L10.981 21.1507L12.229 20.3187L12.7156 21.0486Z" fill="white"/>
11
- </g>
12
- <defs>
13
- <filter id="filter0_d_85_784" x="0.658202" y="0.658202" width="40.6836" height="28.6836" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
14
- <feFlood flood-opacity="0" result="BackgroundImageFix"/>
15
- <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
16
- <feOffset/>
17
- <feGaussianBlur stdDeviation="1.1709"/>
18
- <feComposite in2="hardAlpha" operator="out"/>
19
- <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
20
- <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_85_784"/>
21
- <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_85_784" result="shape"/>
22
- </filter>
23
- <clipPath id="clip0_85_784">
24
- <rect width="36" height="24" fill="white" transform="translate(3 3)"/>
25
- </clipPath>
26
- </defs>
27
- </svg>
1
+ <svg width="42" height="30" viewBox="0 0 42 30" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_85_784)" filter="url(#filter0_d_85_784)">
3
+ <path d="M3 3H39V27H3V3Z" fill="white"/>
4
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M8.49609 10.27L11.8243 5.27771L12.7001 5.86161L9.37194 10.8539L8.49609 10.27ZM9.74417 11.1021L13.0724 6.10976L13.9482 6.69366L10.62 11.686L9.74417 11.1021ZM10.9922 11.9341L14.3204 6.94181L15.1963 7.52571L11.8681 12.518L10.9922 11.9341ZM26.8012 22.4734L30.1294 17.4811L31.0053 18.065L27.6771 23.0573L26.8012 22.4734ZM28.0493 23.3055L31.3775 18.3131L32.2533 18.897L28.9251 23.8893L28.0493 23.3055ZM33.5014 19.7291L30.1732 24.7214L29.2974 24.1375L32.6256 19.1452L33.5014 19.7291Z" fill="black"/>
5
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M31.9884 22.8526L27.8281 20.0791L28.3147 19.3492L32.475 22.1227L31.9884 22.8526Z" fill="white"/>
6
+ <path d="M25.9915 18.3277C27.8296 15.5705 27.0846 11.8453 24.3274 10.0072C21.5702 8.16905 17.845 8.9141 16.0069 11.6713C14.1688 14.4284 14.9138 18.1537 17.671 19.9918C20.4282 21.8299 24.1534 21.0848 25.9915 18.3277Z" fill="#CA163A"/>
7
+ <path d="M16.0069 11.6713C15.0883 13.0491 15.4611 14.9129 16.839 15.8315C18.2168 16.7501 20.0806 16.3773 20.9992 14.9995C21.9178 13.6216 23.7816 13.2488 25.1595 14.1674C26.5373 15.086 26.9101 16.9498 25.9915 18.3277C24.1544 21.0834 20.4268 21.8289 17.671 19.9918C14.9153 18.1546 14.1697 14.427 16.0069 11.6713Z" fill="#0E4896"/>
8
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M30.1732 5.27734L33.5014 10.2697L32.6255 10.8536L29.2973 5.86124L30.1732 5.27734ZM28.9251 6.10942L32.2533 11.1017L31.3775 11.6856L28.0493 6.69332L28.9251 6.10942ZM27.677 6.94146L31.0052 11.9337L30.1294 12.5176L26.8012 7.52536L27.677 6.94146ZM11.868 17.4807L15.1962 22.4731L14.3204 23.057L10.9922 18.0646L11.868 17.4807ZM10.6199 18.3128L13.9481 23.3051L13.0723 23.889L9.74409 18.8967L10.6199 18.3128ZM9.37194 19.1449L12.7001 24.1372L11.8243 24.7211L8.49609 19.7288L9.37194 19.1449Z" fill="black"/>
9
+ <path d="M11.2241 21.5159L12.4722 20.6839L11.2241 21.5159ZM28.0714 10.2844L29.5292 9.31252L28.0714 10.2844ZM30.7773 8.48048L32.0254 7.64844L30.7773 8.48048Z" fill="black"/>
10
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M32.2688 8.01308L31.0207 8.84512L30.5341 8.11524L31.7822 7.2832L32.2688 8.01308ZM29.7726 9.67715L28.3148 10.649L27.8283 9.91912L29.286 8.94728L29.7726 9.67715ZM12.7156 21.0486L11.4675 21.8806L10.981 21.1507L12.229 20.3187L12.7156 21.0486Z" fill="white"/>
11
+ </g>
12
+ <defs>
13
+ <filter id="filter0_d_85_784" x="0.658202" y="0.658202" width="40.6836" height="28.6836" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
14
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
15
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
16
+ <feOffset/>
17
+ <feGaussianBlur stdDeviation="1.1709"/>
18
+ <feComposite in2="hardAlpha" operator="out"/>
19
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
20
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_85_784"/>
21
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_85_784" result="shape"/>
22
+ </filter>
23
+ <clipPath id="clip0_85_784">
24
+ <rect width="36" height="24" fill="white" transform="translate(3 3)"/>
25
+ </clipPath>
26
+ </defs>
27
+ </svg>
@@ -1,23 +1,23 @@
1
- <svg width="50" height="38" viewBox="0 0 50 38" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <g clip-path="url(#clip0_85_779)" filter="url(#filter0_d_85_779)">
3
- <path d="M7 7H42.7847V30.8565H7V7Z" fill="white"/>
4
- <path d="M7 7H42.7847V8.83458H7V7ZM7 10.6692H42.7847V12.5037H7V10.6692ZM7 14.3383H42.7847V16.1729H7V14.3383ZM7 18.0075H42.7847V19.842H7V18.0075ZM7 21.6836H42.7847V23.5182H7V21.6836ZM7 25.3527H42.7847V27.1873H7V25.3527ZM7 29.0219H42.7847V30.8565H7V29.0219Z" fill="#D80027"/>
5
- <path d="M7 7H24.8923V19.842H7V7Z" fill="#2E52B2"/>
6
- <path d="M10.3344 16.6892L10.0553 15.7964L9.74841 16.6892H8.82764L9.57402 17.2264L9.295 18.1192L10.0553 17.5682L10.7947 18.1192L10.5087 17.2264L11.2691 16.6892H10.3344ZM14.2616 16.6892L13.9756 15.7964L13.6826 16.6892H12.7619L13.5082 17.2264L13.2292 18.1192L13.9756 17.5682L14.729 18.1192L14.4499 17.2264L15.1963 16.6892H14.2616ZM18.2028 16.6892L17.9029 15.7964L17.6238 16.6892H16.6821L17.4494 17.2264L17.1565 18.1192L17.9029 17.5682L18.6702 18.1192L18.3772 17.2264L19.1236 16.6892H18.2028ZM22.1231 16.6892L21.8441 15.7964L21.5511 16.6892H20.6233L21.3767 17.2264L21.0977 18.1192L21.8441 17.5682L22.5974 18.1192L22.2975 17.2264L23.0648 16.6892H22.1231ZM13.9756 12.2528L13.6826 13.1457H12.7619L13.5082 13.6967L13.2292 14.5757L13.9756 14.0316L14.729 14.5757L14.4499 13.6967L15.1963 13.1457H14.2616L13.9756 12.2528ZM10.0553 12.2528L9.74841 13.1457H8.82764L9.57402 13.6967L9.295 14.5757L10.0553 14.0316L10.7947 14.5757L10.5087 13.6967L11.2691 13.1457H10.3344L10.0553 12.2528ZM17.9029 12.2528L17.6238 13.1457H16.6821L17.4494 13.6967L17.1565 14.5757L17.9029 14.0316L18.6702 14.5757L18.3772 13.6967L19.1236 13.1457H18.2028L17.9029 12.2528ZM21.8441 12.2528L21.5511 13.1457H20.6233L21.3767 13.6967L21.0977 14.5757L21.8441 14.0316L22.5974 14.5757L22.2975 13.6967L23.0648 13.1457H22.1231L21.8441 12.2528ZM10.0553 8.72314L9.74841 9.60207H8.82764L9.57402 10.1531L9.295 11.039L10.0553 10.488L10.7947 11.039L10.5087 10.1531L11.2691 9.60207H10.3344L10.0553 8.72314ZM13.9756 8.72314L13.6826 9.60207H12.7619L13.5082 10.1531L13.2292 11.039L13.9756 10.488L14.729 11.039L14.4499 10.1531L15.1963 9.60207H14.2616L13.9756 8.72314ZM17.9029 8.72314L17.6238 9.60207H16.6821L17.4494 10.1531L17.1565 11.039L17.9029 10.488L18.6702 11.039L18.3772 10.1531L19.1236 9.60207H18.2028L17.9029 8.72314ZM21.8441 8.72314L21.5511 9.60207H20.6233L21.3767 10.1531L21.0977 11.039L21.8441 10.488L22.5974 11.039L22.2975 10.1531L23.0648 9.60207H22.1231L21.8441 8.72314Z" fill="white"/>
7
- </g>
8
- <defs>
9
- <filter id="filter0_d_85_779" x="0.761634" y="0.761634" width="48.2614" height="36.3332" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
10
- <feFlood flood-opacity="0" result="BackgroundImageFix"/>
11
- <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
12
- <feOffset/>
13
- <feGaussianBlur stdDeviation="3.11918"/>
14
- <feComposite in2="hardAlpha" operator="out"/>
15
- <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
16
- <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_85_779"/>
17
- <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_85_779" result="shape"/>
18
- </filter>
19
- <clipPath id="clip0_85_779">
20
- <rect width="35.7847" height="23.8565" fill="white" transform="translate(7 7)"/>
21
- </clipPath>
22
- </defs>
23
- </svg>
1
+ <svg width="50" height="38" viewBox="0 0 50 38" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <g clip-path="url(#clip0_85_779)" filter="url(#filter0_d_85_779)">
3
+ <path d="M7 7H42.7847V30.8565H7V7Z" fill="white"/>
4
+ <path d="M7 7H42.7847V8.83458H7V7ZM7 10.6692H42.7847V12.5037H7V10.6692ZM7 14.3383H42.7847V16.1729H7V14.3383ZM7 18.0075H42.7847V19.842H7V18.0075ZM7 21.6836H42.7847V23.5182H7V21.6836ZM7 25.3527H42.7847V27.1873H7V25.3527ZM7 29.0219H42.7847V30.8565H7V29.0219Z" fill="#D80027"/>
5
+ <path d="M7 7H24.8923V19.842H7V7Z" fill="#2E52B2"/>
6
+ <path d="M10.3344 16.6892L10.0553 15.7964L9.74841 16.6892H8.82764L9.57402 17.2264L9.295 18.1192L10.0553 17.5682L10.7947 18.1192L10.5087 17.2264L11.2691 16.6892H10.3344ZM14.2616 16.6892L13.9756 15.7964L13.6826 16.6892H12.7619L13.5082 17.2264L13.2292 18.1192L13.9756 17.5682L14.729 18.1192L14.4499 17.2264L15.1963 16.6892H14.2616ZM18.2028 16.6892L17.9029 15.7964L17.6238 16.6892H16.6821L17.4494 17.2264L17.1565 18.1192L17.9029 17.5682L18.6702 18.1192L18.3772 17.2264L19.1236 16.6892H18.2028ZM22.1231 16.6892L21.8441 15.7964L21.5511 16.6892H20.6233L21.3767 17.2264L21.0977 18.1192L21.8441 17.5682L22.5974 18.1192L22.2975 17.2264L23.0648 16.6892H22.1231ZM13.9756 12.2528L13.6826 13.1457H12.7619L13.5082 13.6967L13.2292 14.5757L13.9756 14.0316L14.729 14.5757L14.4499 13.6967L15.1963 13.1457H14.2616L13.9756 12.2528ZM10.0553 12.2528L9.74841 13.1457H8.82764L9.57402 13.6967L9.295 14.5757L10.0553 14.0316L10.7947 14.5757L10.5087 13.6967L11.2691 13.1457H10.3344L10.0553 12.2528ZM17.9029 12.2528L17.6238 13.1457H16.6821L17.4494 13.6967L17.1565 14.5757L17.9029 14.0316L18.6702 14.5757L18.3772 13.6967L19.1236 13.1457H18.2028L17.9029 12.2528ZM21.8441 12.2528L21.5511 13.1457H20.6233L21.3767 13.6967L21.0977 14.5757L21.8441 14.0316L22.5974 14.5757L22.2975 13.6967L23.0648 13.1457H22.1231L21.8441 12.2528ZM10.0553 8.72314L9.74841 9.60207H8.82764L9.57402 10.1531L9.295 11.039L10.0553 10.488L10.7947 11.039L10.5087 10.1531L11.2691 9.60207H10.3344L10.0553 8.72314ZM13.9756 8.72314L13.6826 9.60207H12.7619L13.5082 10.1531L13.2292 11.039L13.9756 10.488L14.729 11.039L14.4499 10.1531L15.1963 9.60207H14.2616L13.9756 8.72314ZM17.9029 8.72314L17.6238 9.60207H16.6821L17.4494 10.1531L17.1565 11.039L17.9029 10.488L18.6702 11.039L18.3772 10.1531L19.1236 9.60207H18.2028L17.9029 8.72314ZM21.8441 8.72314L21.5511 9.60207H20.6233L21.3767 10.1531L21.0977 11.039L21.8441 10.488L22.5974 11.039L22.2975 10.1531L23.0648 9.60207H22.1231L21.8441 8.72314Z" fill="white"/>
7
+ </g>
8
+ <defs>
9
+ <filter id="filter0_d_85_779" x="0.761634" y="0.761634" width="48.2614" height="36.3332" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
10
+ <feFlood flood-opacity="0" result="BackgroundImageFix"/>
11
+ <feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"/>
12
+ <feOffset/>
13
+ <feGaussianBlur stdDeviation="3.11918"/>
14
+ <feComposite in2="hardAlpha" operator="out"/>
15
+ <feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.25 0"/>
16
+ <feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_85_779"/>
17
+ <feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_85_779" result="shape"/>
18
+ </filter>
19
+ <clipPath id="clip0_85_779">
20
+ <rect width="35.7847" height="23.8565" fill="white" transform="translate(7 7)"/>
21
+ </clipPath>
22
+ </defs>
23
+ </svg>
@@ -0,0 +1,63 @@
1
+ // src/utils/core/colorScale.ts
2
+ import Color from "colorjs.io";
3
+
4
+ // src/constants/variation.ts
5
+ var DEFAULT_KEYS = [
6
+ "50",
7
+ "100",
8
+ "200",
9
+ "300",
10
+ "400",
11
+ "500",
12
+ "600",
13
+ "700",
14
+ "800",
15
+ "900"
16
+ ];
17
+ var DEFAULT_SCALE = {
18
+ "50": { dL: 0.36, cMul: 0.95 },
19
+ "100": { dL: 0.28, cMul: 0.96 },
20
+ "200": { dL: 0.18, cMul: 0.98 },
21
+ "300": { dL: 0.08, cMul: 0.99 },
22
+ "400": { dL: 0.02, cMul: 1 },
23
+ "500": { dL: 0, cMul: 1 },
24
+ "600": { dL: -0.05, cMul: 0.98 },
25
+ "700": { dL: -0.15, cMul: 0.94 },
26
+ "800": { dL: -0.22, cMul: 0.9 },
27
+ "900": { dL: -0.3, cMul: 0.88 }
28
+ };
29
+
30
+ // src/utils/core/colorScale.ts
31
+ var CLAMP01 = (x) => Math.max(0, Math.min(1, x));
32
+ function hexToOKLCH(hex) {
33
+ const c = new Color(hex);
34
+ const o = c.to("oklch");
35
+ return { l: o.l, c: o.c, h: o.h ?? 0 };
36
+ }
37
+ function oklchToHex(l, c, h) {
38
+ const color = new Color("oklch", [l, c, h]);
39
+ const srgb = color.to("srgb");
40
+ const r = CLAMP01(srgb.r), g = CLAMP01(srgb.g), b = CLAMP01(srgb.b);
41
+ return new Color("srgb", [r, g, b]).toString({ format: "hex" });
42
+ }
43
+ function buildScaleFromBaseHex(baseHex, opts) {
44
+ const keys = opts?.keys ?? DEFAULT_KEYS;
45
+ const cMin = opts?.cMin ?? 0.02;
46
+ const cMax = opts?.cMax ?? 0.4;
47
+ const lockHue = true;
48
+ const base = hexToOKLCH(baseHex);
49
+ const out = {};
50
+ for (const k of keys) {
51
+ const pat = DEFAULT_SCALE[k] ?? DEFAULT_SCALE["500"];
52
+ const L = CLAMP01(base.l + pat.dL);
53
+ const C = Math.max(cMin, Math.min(cMax, base.c * pat.cMul));
54
+ const H = lockHue ? base.h : base.h;
55
+ out[k] = oklchToHex(L, C, H);
56
+ }
57
+ return out;
58
+ }
59
+
60
+ export {
61
+ DEFAULT_KEYS,
62
+ buildScaleFromBaseHex
63
+ };
@@ -0,0 +1,103 @@
1
+ import {
2
+ DEFAULT_KEYS,
3
+ buildScaleFromBaseHex
4
+ } from "./chunk-4UJAETSM.js";
5
+
6
+ // src/node/applyThemes.ts
7
+ import fs from "fs";
8
+ import postcss, { Rule } from "postcss";
9
+ import safeParser from "postcss-safe-parser";
10
+
11
+ // src/constants/regex.ts
12
+ var variableRegex = /(--color-[\w-]+):\s*(#[0-9a-fA-F]{3,8})/g;
13
+ var variationRegex = /^--(.+?)-(50|100|200|300|400|500|600|700|800|900)$/i;
14
+
15
+ // src/node/applyThemes.ts
16
+ var CSS_PATH = "src/index.css";
17
+ function toThemeColor(hex, _vision) {
18
+ return hex;
19
+ }
20
+ function loadRoot(cssPath = CSS_PATH) {
21
+ const css = fs.readFileSync(cssPath, "utf8");
22
+ return postcss().process(css, { parser: safeParser }).root;
23
+ }
24
+ function getExistingKeysForToken(root, token) {
25
+ const keys = /* @__PURE__ */ new Set();
26
+ root.walkDecls((d) => {
27
+ if (!d.prop.startsWith("--")) return;
28
+ const m = d.prop.match(variationRegex);
29
+ if (!m) return;
30
+ const [, t, k] = m;
31
+ if (t === token) keys.add(k);
32
+ });
33
+ return Array.from(keys);
34
+ }
35
+ function upsertBlock(root, selector, kv) {
36
+ let rule;
37
+ root.walkRules((r) => {
38
+ if (r.selector === selector) rule = r;
39
+ });
40
+ if (!rule) {
41
+ rule = new Rule({ selector });
42
+ root.append(rule);
43
+ }
44
+ const remain = new Map(Object.entries(kv));
45
+ rule.walkDecls((d) => {
46
+ if (remain.has(d.prop)) {
47
+ d.value = remain.get(d.prop);
48
+ remain.delete(d.prop);
49
+ }
50
+ });
51
+ for (const [prop, value] of remain) rule.append({ prop, value });
52
+ }
53
+ function getColorVariablesFromRoot(root) {
54
+ const vars = {};
55
+ root.walkDecls((decl) => {
56
+ const name = decl.prop.trim();
57
+ const value = decl.value.trim();
58
+ if (name.startsWith("--color")) {
59
+ vars[name] = value;
60
+ }
61
+ });
62
+ return vars;
63
+ }
64
+ function applyThemes(input, cssPath = CSS_PATH) {
65
+ const root = loadRoot(cssPath);
66
+ const originalVars = getColorVariablesFromRoot(root);
67
+ const varsForTheme = {};
68
+ for (const [varName, value] of Object.entries(originalVars)) {
69
+ varsForTheme[varName] = value;
70
+ }
71
+ for (const [varName, val] of Object.entries(input.variables)) {
72
+ const rich = typeof val === "string" ? inferRich(varName, val) : val;
73
+ const m = varName.match(variationRegex);
74
+ const isPattern = !!m;
75
+ if (isPattern) {
76
+ const [, token] = m;
77
+ const keys = rich.keys && rich.keys.length ? rich.keys : getExistingKeysForToken(root, token).length ? getExistingKeysForToken(root, token) : Array.from(DEFAULT_KEYS);
78
+ if (rich.scale !== false) {
79
+ const scaleMap = buildScaleFromBaseHex(rich.base, { keys });
80
+ for (const k of keys) {
81
+ const hex = scaleMap[k];
82
+ varsForTheme[`--${token}-${k}`] = toThemeColor(hex, input.vision);
83
+ }
84
+ } else {
85
+ varsForTheme[varName] = toThemeColor(rich.base, input.vision);
86
+ }
87
+ } else {
88
+ varsForTheme[varName] = toThemeColor(rich.base, input.vision);
89
+ }
90
+ }
91
+ upsertBlock(root, `[data-theme='${input.vision}']`, varsForTheme);
92
+ fs.writeFileSync(cssPath, root.toString(), "utf8");
93
+ console.log(`\u2705 [${input.vision}] theme updated in ${cssPath}`);
94
+ }
95
+ function inferRich(varName, baseHex) {
96
+ return variationRegex.test(varName) ? { base: baseHex, scale: true } : { base: baseHex, scale: false };
97
+ }
98
+
99
+ export {
100
+ variableRegex,
101
+ applyThemes,
102
+ inferRich
103
+ };
package/dist/cli.cjs CHANGED
@@ -141,10 +141,24 @@ function upsertBlock(root, selector, kv) {
141
141
  });
142
142
  for (const [prop, value] of remain) rule.append({ prop, value });
143
143
  }
144
+ function getColorVariablesFromRoot(root) {
145
+ const vars = {};
146
+ root.walkDecls((decl) => {
147
+ const name = decl.prop.trim();
148
+ const value = decl.value.trim();
149
+ if (name.startsWith("--color")) {
150
+ vars[name] = value;
151
+ }
152
+ });
153
+ return vars;
154
+ }
144
155
  function applyThemes(input, cssPath = CSS_PATH) {
145
156
  const root = loadRoot(cssPath);
146
- const selector = `[data-theme='${input.vision}']`;
157
+ const originalVars = getColorVariablesFromRoot(root);
147
158
  const varsForTheme = {};
159
+ for (const [varName, value] of Object.entries(originalVars)) {
160
+ varsForTheme[varName] = value;
161
+ }
148
162
  for (const [varName, val] of Object.entries(input.variables)) {
149
163
  const rich = typeof val === "string" ? inferRich(varName, val) : val;
150
164
  const m = varName.match(variationRegex);
@@ -153,15 +167,10 @@ function applyThemes(input, cssPath = CSS_PATH) {
153
167
  const [, token] = m;
154
168
  const keys = rich.keys && rich.keys.length ? rich.keys : getExistingKeysForToken(root, token).length ? getExistingKeysForToken(root, token) : Array.from(DEFAULT_KEYS);
155
169
  if (rich.scale !== false) {
156
- const scaleMap = buildScaleFromBaseHex(rich.base, {
157
- keys
158
- });
170
+ const scaleMap = buildScaleFromBaseHex(rich.base, { keys });
159
171
  for (const k of keys) {
160
172
  const hex = scaleMap[k];
161
- varsForTheme[`--${token}-${k}`] = toThemeColor(
162
- hex,
163
- input.vision
164
- );
173
+ varsForTheme[`--${token}-${k}`] = toThemeColor(hex, input.vision);
165
174
  }
166
175
  } else {
167
176
  varsForTheme[varName] = toThemeColor(rich.base, input.vision);
@@ -170,7 +179,7 @@ function applyThemes(input, cssPath = CSS_PATH) {
170
179
  varsForTheme[varName] = toThemeColor(rich.base, input.vision);
171
180
  }
172
181
  }
173
- upsertBlock(root, selector, varsForTheme);
182
+ upsertBlock(root, `[data-theme='${input.vision}']`, varsForTheme);
174
183
  import_node_fs.default.writeFileSync(cssPath, root.toString(), "utf8");
175
184
  console.log(`\u2705 [${input.vision}] theme updated in ${cssPath}`);
176
185
  }
@@ -326,6 +335,23 @@ function removeExistingThemeBlocks(content) {
326
335
  }
327
336
 
328
337
  // src/node/runThemeApply.ts
338
+ function hexToRgb(hex) {
339
+ let clean = hex.replace("#", "").toLowerCase();
340
+ if (clean.length === 3) {
341
+ clean = clean.split("").map((c) => c + c).join("");
342
+ }
343
+ if (clean.length !== 6) return null;
344
+ const r = parseInt(clean.substring(0, 2), 16);
345
+ const g = parseInt(clean.substring(2, 4), 16);
346
+ const b = parseInt(clean.substring(4, 6), 16);
347
+ return [r, g, b];
348
+ }
349
+ function isNeutralColor(value) {
350
+ const rgb = hexToRgb(value);
351
+ if (!rgb) return false;
352
+ const [r, g, b] = rgb;
353
+ return r === g && g === b;
354
+ }
329
355
  function isBlackOrWhite(hexColor) {
330
356
  const hex = hexColor.toLowerCase().replace("#", "");
331
357
  const fullHex = hex.length === 3 ? hex.split("").map((char) => char + char).join("") : hex;
@@ -353,7 +379,10 @@ async function runThemeApply(cssPath) {
353
379
  while ((match = variableRegex.exec(content)) !== null) {
354
380
  const [, key, value] = match;
355
381
  const cleanKey = key.trim();
356
- const cleanValue = value.trim();
382
+ const cleanValue = value.trim().toLowerCase();
383
+ if (isNeutralColor(cleanValue)) {
384
+ continue;
385
+ }
357
386
  const scale = calculateScale(cleanKey, cleanValue);
358
387
  const rich = {
359
388
  base: cleanValue,
package/dist/cli.js CHANGED
@@ -118,10 +118,24 @@ function upsertBlock(root, selector, kv) {
118
118
  });
119
119
  for (const [prop, value] of remain) rule.append({ prop, value });
120
120
  }
121
+ function getColorVariablesFromRoot(root) {
122
+ const vars = {};
123
+ root.walkDecls((decl) => {
124
+ const name = decl.prop.trim();
125
+ const value = decl.value.trim();
126
+ if (name.startsWith("--color")) {
127
+ vars[name] = value;
128
+ }
129
+ });
130
+ return vars;
131
+ }
121
132
  function applyThemes(input, cssPath = CSS_PATH) {
122
133
  const root = loadRoot(cssPath);
123
- const selector = `[data-theme='${input.vision}']`;
134
+ const originalVars = getColorVariablesFromRoot(root);
124
135
  const varsForTheme = {};
136
+ for (const [varName, value] of Object.entries(originalVars)) {
137
+ varsForTheme[varName] = value;
138
+ }
125
139
  for (const [varName, val] of Object.entries(input.variables)) {
126
140
  const rich = typeof val === "string" ? inferRich(varName, val) : val;
127
141
  const m = varName.match(variationRegex);
@@ -130,15 +144,10 @@ function applyThemes(input, cssPath = CSS_PATH) {
130
144
  const [, token] = m;
131
145
  const keys = rich.keys && rich.keys.length ? rich.keys : getExistingKeysForToken(root, token).length ? getExistingKeysForToken(root, token) : Array.from(DEFAULT_KEYS);
132
146
  if (rich.scale !== false) {
133
- const scaleMap = buildScaleFromBaseHex(rich.base, {
134
- keys
135
- });
147
+ const scaleMap = buildScaleFromBaseHex(rich.base, { keys });
136
148
  for (const k of keys) {
137
149
  const hex = scaleMap[k];
138
- varsForTheme[`--${token}-${k}`] = toThemeColor(
139
- hex,
140
- input.vision
141
- );
150
+ varsForTheme[`--${token}-${k}`] = toThemeColor(hex, input.vision);
142
151
  }
143
152
  } else {
144
153
  varsForTheme[varName] = toThemeColor(rich.base, input.vision);
@@ -147,7 +156,7 @@ function applyThemes(input, cssPath = CSS_PATH) {
147
156
  varsForTheme[varName] = toThemeColor(rich.base, input.vision);
148
157
  }
149
158
  }
150
- upsertBlock(root, selector, varsForTheme);
159
+ upsertBlock(root, `[data-theme='${input.vision}']`, varsForTheme);
151
160
  fs.writeFileSync(cssPath, root.toString(), "utf8");
152
161
  console.log(`\u2705 [${input.vision}] theme updated in ${cssPath}`);
153
162
  }
@@ -303,6 +312,23 @@ function removeExistingThemeBlocks(content) {
303
312
  }
304
313
 
305
314
  // src/node/runThemeApply.ts
315
+ function hexToRgb(hex) {
316
+ let clean = hex.replace("#", "").toLowerCase();
317
+ if (clean.length === 3) {
318
+ clean = clean.split("").map((c) => c + c).join("");
319
+ }
320
+ if (clean.length !== 6) return null;
321
+ const r = parseInt(clean.substring(0, 2), 16);
322
+ const g = parseInt(clean.substring(2, 4), 16);
323
+ const b = parseInt(clean.substring(4, 6), 16);
324
+ return [r, g, b];
325
+ }
326
+ function isNeutralColor(value) {
327
+ const rgb = hexToRgb(value);
328
+ if (!rgb) return false;
329
+ const [r, g, b] = rgb;
330
+ return r === g && g === b;
331
+ }
306
332
  function isBlackOrWhite(hexColor) {
307
333
  const hex = hexColor.toLowerCase().replace("#", "");
308
334
  const fullHex = hex.length === 3 ? hex.split("").map((char) => char + char).join("") : hex;
@@ -330,7 +356,10 @@ async function runThemeApply(cssPath) {
330
356
  while ((match = variableRegex.exec(content)) !== null) {
331
357
  const [, key, value] = match;
332
358
  const cleanKey = key.trim();
333
- const cleanValue = value.trim();
359
+ const cleanValue = value.trim().toLowerCase();
360
+ if (isNeutralColor(cleanValue)) {
361
+ continue;
362
+ }
334
363
  const scale = calculateScale(cleanKey, cleanValue);
335
364
  const rich = {
336
365
  base: cleanValue,