Skip to content

Allow multiple font variant values to be used, fixes #175 #176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 6, 2023
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
8 changes: 8 additions & 0 deletions src/__tests__/fontVariant.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ it('transforms font variant as an array', () => {
fontVariant: ['tabular-nums'],
})
})

it('transforms multiple font variant as an array', () => {
expect(
transformCss([['font-variant', 'tabular-nums oldstyle-nums']])
).toEqual({
fontVariant: ['tabular-nums', 'oldstyle-nums'],
})
})
14 changes: 14 additions & 0 deletions src/transforms/fontVariant.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { SPACE, IDENT } from '../tokenTypes'

export default tokenStream => {
const values = [tokenStream.expect(IDENT)]

while (tokenStream.hasTokens()) {
tokenStream.expect(SPACE)
values.push(tokenStream.expect(IDENT))
}

return {
fontVariant: values,
}
}
12 changes: 5 additions & 7 deletions src/transforms/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import {
IDENT,
WORD,
AUTO,
COLOR,
LENGTH,
UNSUPPORTED_LENGTH_UNIT,
PERCENT,
AUTO,
UNSUPPORTED_LENGTH_UNIT,
WORD,
} from '../tokenTypes'
import border from './border'
import boxShadow from './boxShadow'
import flex from './flex'
import flexFlow from './flexFlow'
import font from './font'
import fontFamily from './fontFamily'
import fontVariant from './fontVariant'
import placeContent from './placeContent'
import textDecoration from './textDecoration'
import textDecorationLine from './textDecorationLine'
Expand All @@ -39,9 +39,7 @@ const margin = directionFactory({
prefix: 'margin',
})
const padding = directionFactory({ prefix: 'padding' })
const fontVariant = tokenStream => ({
fontVariant: [tokenStream.expect(IDENT)],
})

const fontWeight = tokenStream => ({
fontWeight: tokenStream.expect(WORD), // Also match numbers as strings
})
Expand Down