Skip to content

Commit 8896906

Browse files
authored
Add default units to logical properties (#1415)
* Add default units to logical properties Closes #1414 * Add logical-properties test
1 parent 016eeab commit 8896906

2 files changed

Lines changed: 59 additions & 4 deletions

File tree

packages/jss-plugin-default-unit/src/defaultUnits.js

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,49 @@ export default {
3838
'border-top-right-radius': px,
3939
'border-top-width': px,
4040
'border-width': px,
41-
41+
'border-block': px,
42+
'border-block-end': px,
43+
'border-block-end-width': px,
44+
'border-block-start': px,
45+
'border-block-start-width': px,
46+
'border-block-width': px,
47+
'border-inline': px,
48+
'border-inline-end': px,
49+
'border-inline-end-width': px,
50+
'border-inline-start': px,
51+
'border-inline-start-width': px,
52+
'border-inline-width': px,
53+
'border-start-start-radius': px,
54+
'border-start-end-radius': px,
55+
'border-end-start-radius': px,
56+
'border-end-end-radius': px,
57+
4258
// Margin properties
4359
margin: px,
4460
'margin-bottom': px,
4561
'margin-left': px,
4662
'margin-right': px,
4763
'margin-top': px,
48-
64+
'margin-block': px,
65+
'margin-block-end': px,
66+
'margin-block-start': px,
67+
'margin-inline': px,
68+
'margin-inline-end': px,
69+
'margin-inline-start': px,
70+
4971
// Padding properties
5072
padding: px,
5173
'padding-bottom': px,
5274
'padding-left': px,
5375
'padding-right': px,
5476
'padding-top': px,
55-
77+
'padding-block': px,
78+
'padding-block-end': px,
79+
'padding-block-start': px,
80+
'padding-inline': px,
81+
'padding-inline-end': px,
82+
'padding-inline-start': px,
83+
5684
// Mask properties
5785
'mask-position-x': px,
5886
'mask-position-y': px,
@@ -71,7 +99,14 @@ export default {
7199
left: px,
72100
top: px,
73101
right: px,
74-
102+
'inset': px,
103+
'inset-block': px,
104+
'inset-block-end': px,
105+
'inset-block-start': px,
106+
'inset-inline': px,
107+
'inset-inline-end': px,
108+
'inset-inline-start': px,
109+
75110
// Shadow properties
76111
'box-shadow': px,
77112
'text-shadow': px,

packages/jss-plugin-default-unit/src/index.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,4 +438,24 @@ describe('jss-plugin-default-unit', () => {
438438
`)
439439
})
440440
})
441+
442+
describe('logical properties with px units', () => {
443+
let sheet
444+
445+
beforeEach(() => {
446+
sheet = jss.createStyleSheet({
447+
a: {
448+
'margin-inline-start': 10
449+
}
450+
})
451+
})
452+
453+
it('should add rule', () => {
454+
expect(sheet.getRule('a')).to.not.be(undefined)
455+
})
456+
457+
it('should generate correct CSS', () => {
458+
expect(sheet.toString()).to.be('.a-id {\n margin-inline-start: 10px;\n}')
459+
})
460+
})
441461
})

0 commit comments

Comments
 (0)