Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changepacks/changepack_log_8vb3iWgjR0gltow_Jfi6F.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"changes":{"package.json":"Patch"},"note":"Add CustomShadows and CustomLength","date":"2026-03-24T12:10:37.421989100Z"}
11 changes: 5 additions & 6 deletions __tests__/convert-type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { expect, test } from 'bun:test'

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

test.each([['string', '"string" | Globals']])(
'convertType',
(type, expected) => {
expect(convertType(type, {})).toEqual(expected)
},
)
test.each([
['string', '"string" | Globals'],
])('convertType', (type, expected) => {
expect(convertType(type, {})).toEqual(expected)
})
4 changes: 2 additions & 2 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { convertType } from './convert-type'
import { toCamelCase } from './to-camelcase'
import { toPascalCase } from './to-pascalcase'

let output = `// biome-ignore lint/suspicious/noEmptyInterface: gen\nexport interface CustomColors{}\nexport as namespace CSS;\n`
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`

const syntaxes = (await fetch(
'https://raw.githubusercontent.com/mdn/data/refs/heads/main/css/syntaxes.json',
Expand Down Expand Up @@ -177,7 +177,7 @@ for (const [property, value] of Object.entries(syntaxes)) {
if (property in customSyntaxes) {
continue
}
output += `export type T${toPascalCase(property)} = ${convertType(value.syntax.replace('<image |', '<image> |'), syntaxes)}${property === 'color' ? ' | keyof CustomColors' : ''};\n`
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`
}

Bun.write('src/index.d.ts', output)
Expand Down
26 changes: 13 additions & 13 deletions bun.lock

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
],
"types": "src/index.d.ts",
"devDependencies": {
"@biomejs/biome": "^2.3",
"@biomejs/biome": "^2.4",
"@types/bun": "latest",
"@types/css-tree": "^2.3.11",
"css-tree": "^3.1.0",
"css-tree": "^3.2.1",
"husky": "^9.1"
},
"peerDependencies": {
Expand Down
8 changes: 6 additions & 2 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// biome-ignore lint/suspicious/noEmptyInterface: gen
export interface CustomColors {}
// biome-ignore lint/suspicious/noEmptyInterface: gen
export interface CustomLength {}
// biome-ignore lint/suspicious/noEmptyInterface: gen
export interface CustomShadows {}
export as namespace CSS
export interface StandardLonghandProperties {
accentColor?: Property.AccentColor | undefined
Expand Down Expand Up @@ -4155,7 +4159,7 @@ export type TKeyframeSelector =
export type TKeyframesName = (string & {}) | Globals
export type TLayerName = "'.'" | Globals
export type TLeaderType = 'dotted' | 'solid' | 'space' | (string & {}) | Globals
export type TLengthPercentage = number | Globals
export type TLengthPercentage = number | Globals | keyof CustomLength
export type TLineNameList = TLineNames | TNameRepeat | Globals
export type TLineNames = "'['" | "']'" | Globals
export type TLineStyle =
Expand Down Expand Up @@ -4661,7 +4665,7 @@ export type TSelfPosition =
| 'flex-start'
| 'flex-end'
| Globals
export type TShadow = 'inset' | number | TColor | Globals
export type TShadow = 'inset' | number | TColor | Globals | keyof CustomShadows
export type TShadowT = number | TColor | Globals
export type TShape = Globals
export type TShapeBox = TVisualBox | 'margin-box' | Globals
Expand Down