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
18 changes: 11 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,25 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- run: npm install --ignore-scripts --no-audit --no-fund
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
cache: "npm"
node-version: 22
- run: npm ci --ignore-scripts --no-audit --no-fund
- run: npm test

publish-npm:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: actions/checkout@v5
- uses: actions/setup-node@v5
with:
cache: 'npm'
node-version: 22
cache: "npm"
registry-url: https://registry.npmjs.org/
- run: npm install --ignore-scripts --no-audit --no-fund
- run: npm ci --ignore-scripts --no-audit --no-fund
- run: npm run build
- run: npm publish --public
env:
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,25 @@ jobs:
name: Unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Use Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
cache: "npm"
node-version: 22
- run: npm install --ignore-scripts --no-audit --no-fund
- run: npm test

check:
name: Check types
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Use Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
cache: "npm"
node-version: 22
- run: npm install --ignore-scripts --no-audit --no-fund
- run: npm run check

Expand All @@ -39,11 +41,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Use Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
cache: "npm"
node-version: 22
- run: npm install --ignore-scripts --no-audit --no-fund
- name: Build package
run: npm run build
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"default": "./dist/css-design-tokens.js"
},
"engines": {
"node": ">=18"
"node": ">=22"
},
"scripts": {
"test": "vitest run",
Expand Down
10 changes: 10 additions & 0 deletions src/destructure-line-height.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ test('percentage', () => {

test('number', () => {
expect.soft(destructure_line_height('1')).toEqual(1)
expect.soft(destructure_line_height('1.0')).toEqual(1)
expect.soft(destructure_line_height('1.1')).toEqual(1.1)
expect.soft(destructure_line_height('1e2')).toEqual(100)
})
Expand All @@ -36,6 +37,15 @@ test('length', () => {
expect.soft(destructure_line_height('1e2em')).toEqual({ value: 100, unit: 'em' })
})

test('zero', () => {
expect.soft(destructure_line_height('0%')).toEqual(0)
expect.soft(destructure_line_height('0.0%')).toEqual(0)
expect.soft(destructure_line_height('0px')).toEqual(0)
expect.soft(destructure_line_height('0.0px')).toEqual(0)
expect.soft(destructure_line_height('0')).toEqual(0)
expect.soft(destructure_line_height('0.0')).toEqual(0)
})

test('unprocessable values', () => {
expect.soft(destructure_line_height('var(--my-line-height)')).toEqual(null)
expect.soft(destructure_line_height('var(--my-line-height, 1.2)')).toEqual(null)
Expand Down
6 changes: 5 additions & 1 deletion src/destructure-line-height.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ export function destructure_line_height(value: string): Length | number | null {

switch (maybe_dimension.type) {
case 'Dimension': {
let value = Number(maybe_dimension.value)
if (value === 0) {
return 0
}
return {
value: Number(maybe_dimension.value),
value,
unit: maybe_dimension.unit
}
}
Expand Down
Loading