Skip to content
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

Add default units to logical properties #1415

Merged
merged 2 commits into from
Nov 10, 2020
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
43 changes: 39 additions & 4 deletions packages/jss-plugin-default-unit/src/defaultUnits.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,49 @@ export default {
'border-top-right-radius': px,
'border-top-width': px,
'border-width': px,

'border-block': px,
'border-block-end': px,
'border-block-end-width': px,
'border-block-start': px,
'border-block-start-width': px,
'border-block-width': px,
'border-inline': px,
'border-inline-end': px,
'border-inline-end-width': px,
'border-inline-start': px,
'border-inline-start-width': px,
'border-inline-width': px,
'border-start-start-radius': px,
'border-start-end-radius': px,
'border-end-start-radius': px,
'border-end-end-radius': px,

// Margin properties
margin: px,
'margin-bottom': px,
'margin-left': px,
'margin-right': px,
'margin-top': px,

'margin-block': px,
'margin-block-end': px,
'margin-block-start': px,
'margin-inline': px,
'margin-inline-end': px,
'margin-inline-start': px,

// Padding properties
padding: px,
'padding-bottom': px,
'padding-left': px,
'padding-right': px,
'padding-top': px,

'padding-block': px,
'padding-block-end': px,
'padding-block-start': px,
'padding-inline': px,
'padding-inline-end': px,
'padding-inline-start': px,

// Mask properties
'mask-position-x': px,
'mask-position-y': px,
Expand All @@ -71,7 +99,14 @@ export default {
left: px,
top: px,
right: px,

'inset': px,
'inset-block': px,
'inset-block-end': px,
'inset-block-start': px,
'inset-inline': px,
'inset-inline-end': px,
'inset-inline-start': px,

// Shadow properties
'box-shadow': px,
'text-shadow': px,
Expand Down
20 changes: 20 additions & 0 deletions packages/jss-plugin-default-unit/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,24 @@ describe('jss-plugin-default-unit', () => {
`)
})
})

describe('logical properties with px units', () => {
let sheet

beforeEach(() => {
sheet = jss.createStyleSheet({
a: {
'margin-inline-start': 10
}
})
})

it('should add rule', () => {
expect(sheet.getRule('a')).to.not.be(undefined)
})

it('should generate correct CSS', () => {
expect(sheet.toString()).to.be('.a-id {\n margin-inline-start: 10px;\n}')
})
})
})