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
13 changes: 4 additions & 9 deletions src/__tests__/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,10 @@ it('omits line height if not specified', () => {
})
})

it('allows line height as multiple', () => {
expect(transformCss([['font', '16px/1.5 "Helvetica"']])).toEqual({
fontFamily: 'Helvetica',
fontSize: 16,
fontWeight: 'normal',
fontStyle: 'normal',
fontVariant: [],
lineHeight: 24,
})
it('does not allow line height as multiple', () => {
expect(() => {
transformCss([['font', '16px/1.5 "Helvetica"']])
}).toThrow()
})

it('transforms font without quotes', () => {
Expand Down
7 changes: 1 addition & 6 deletions src/transforms/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
SPACE,
LENGTH,
UNSUPPORTED_LENGTH_UNIT,
NUMBER,
SLASH,
} from '../tokenTypes'

Expand Down Expand Up @@ -46,11 +45,7 @@ export default tokenStream => {
const fontSize = tokenStream.expect(LENGTH, UNSUPPORTED_LENGTH_UNIT)

if (tokenStream.matches(SLASH)) {
if (tokenStream.matches(NUMBER)) {
lineHeight = fontSize * tokenStream.lastValue
} else {
lineHeight = tokenStream.expect(LENGTH, UNSUPPORTED_LENGTH_UNIT)
}
lineHeight = tokenStream.expect(LENGTH, UNSUPPORTED_LENGTH_UNIT)
}

tokenStream.expect(SPACE)
Expand Down