Skip to content

Commit d5afcca

Browse files
authored
Merge pull request #28 from dev-five-git/add-custom-shadow-and-length
Add CustomShadows and CustomLength
2 parents bfdbdfd + 102d012 commit d5afcca

File tree

6 files changed

+29
-25
lines changed

6 files changed

+29
-25
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"changes":{"package.json":"Patch"},"note":"Add CustomShadows and CustomLength","date":"2026-03-24T12:10:37.421989100Z"}

__tests__/convert-type.test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ import { expect, test } from 'bun:test'
22

33
import { convertType } from '../convert-type'
44

5-
test.each([['string', '"string" | Globals']])(
6-
'convertType',
7-
(type, expected) => {
8-
expect(convertType(type, {})).toEqual(expected)
9-
},
10-
)
5+
test.each([
6+
['string', '"string" | Globals'],
7+
])('convertType', (type, expected) => {
8+
expect(convertType(type, {})).toEqual(expected)
9+
})

build.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { convertType } from './convert-type'
22
import { toCamelCase } from './to-camelcase'
33
import { toPascalCase } from './to-pascalcase'
44

5-
let output = `// biome-ignore lint/suspicious/noEmptyInterface: gen\nexport interface CustomColors{}\nexport as namespace CSS;\n`
5+
let output = `// biome-ignore lint/suspicious/noEmptyInterface: gen\nexport interface CustomColors{}\n// biome-ignore lint/suspicious/noEmptyInterface: gen\nexport interface CustomLength{}\n// biome-ignore lint/suspicious/noEmptyInterface: gen\nexport interface CustomShadows{}\nexport as namespace CSS;\n`
66

77
const syntaxes = (await fetch(
88
'https://raw.githubusercontent.com/mdn/data/refs/heads/main/css/syntaxes.json',
@@ -177,7 +177,7 @@ for (const [property, value] of Object.entries(syntaxes)) {
177177
if (property in customSyntaxes) {
178178
continue
179179
}
180-
output += `export type T${toPascalCase(property)} = ${convertType(value.syntax.replace('<image |', '<image> |'), syntaxes)}${property === 'color' ? ' | keyof CustomColors' : ''};\n`
180+
output += `export type T${toPascalCase(property)} = ${convertType(value.syntax.replace('<image |', '<image> |'), syntaxes)}${property === 'color' ? ' | keyof CustomColors' : property === 'length-percentage' ? ' | keyof CustomLength' : property === 'shadow' ? ' | keyof CustomShadows' : ''};\n`
181181
}
182182

183183
Bun.write('src/index.d.ts', output)

bun.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
],
2525
"types": "src/index.d.ts",
2626
"devDependencies": {
27-
"@biomejs/biome": "^2.3",
27+
"@biomejs/biome": "^2.4",
2828
"@types/bun": "latest",
2929
"@types/css-tree": "^2.3.11",
30-
"css-tree": "^3.1.0",
30+
"css-tree": "^3.2.1",
3131
"husky": "^9.1"
3232
},
3333
"peerDependencies": {

src/index.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// biome-ignore lint/suspicious/noEmptyInterface: gen
22
export interface CustomColors {}
3+
// biome-ignore lint/suspicious/noEmptyInterface: gen
4+
export interface CustomLength {}
5+
// biome-ignore lint/suspicious/noEmptyInterface: gen
6+
export interface CustomShadows {}
37
export as namespace CSS
48
export interface StandardLonghandProperties {
59
accentColor?: Property.AccentColor | undefined
@@ -4155,7 +4159,7 @@ export type TKeyframeSelector =
41554159
export type TKeyframesName = (string & {}) | Globals
41564160
export type TLayerName = "'.'" | Globals
41574161
export type TLeaderType = 'dotted' | 'solid' | 'space' | (string & {}) | Globals
4158-
export type TLengthPercentage = number | Globals
4162+
export type TLengthPercentage = number | Globals | keyof CustomLength
41594163
export type TLineNameList = TLineNames | TNameRepeat | Globals
41604164
export type TLineNames = "'['" | "']'" | Globals
41614165
export type TLineStyle =
@@ -4661,7 +4665,7 @@ export type TSelfPosition =
46614665
| 'flex-start'
46624666
| 'flex-end'
46634667
| Globals
4664-
export type TShadow = 'inset' | number | TColor | Globals
4668+
export type TShadow = 'inset' | number | TColor | Globals | keyof CustomShadows
46654669
export type TShadowT = number | TColor | Globals
46664670
export type TShape = Globals
46674671
export type TShapeBox = TVisualBox | 'margin-box' | Globals

0 commit comments

Comments
 (0)