Skip to content
Open
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
32 changes: 26 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ function trbl (prefix) {
])
}

function logical (prefix) {
const rules = [prefix]
prefix += '-'

return rules.concat([
prefix + 'block',
prefix + 'block-start',
prefix + 'block-end',
prefix + 'inline',
prefix + 'inline-start',
prefix + 'inline-end',
Comment on lines +24 to +29
Copy link
Contributor Author

@julienw julienw Nov 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we can argue about the order we want: this is different than the usual top right bottom left. I decided to group them by axis instead, but happy to change it if you think otherwise. I started by "block" because we're used to start with the top.

])
}

function minMax (suffix) {
return [suffix, 'min-' + suffix, 'max-' + suffix]
}
Expand Down Expand Up @@ -49,6 +63,7 @@ const positioning = []
'z-index'
])
.concat(trbl())
.concat(logical("inset"))

const displayAndBoxModel = []
.concat([
Expand All @@ -73,13 +88,18 @@ const displayAndBoxModel = []
'order'
])
.concat(trbl('padding'))
.concat([]
.concat(border())
.concat(border('top'))
.concat(border('right'))
.concat(border('bottom'))
.concat(border('left')))
.concat(logical('padding'))
.concat(border())
.concat(border('top'))
.concat(border('right'))
.concat(border('bottom'))
.concat(border('left'))
.concat(border('block-start'))
.concat(border('block-end'))
.concat(border('inline-start'))
.concat(border('inline-end'))
.concat(trbl('margin'))
.concat(logical('margin'))

module.exports = {
plugins: 'stylelint-order',
Expand Down
14 changes: 14 additions & 0 deletions test/expected.css
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,20 @@ hr {
margin-bottom: 1rem;
}

button {
position: absolute;
inset: 5px 2px 3px 1px;
inset-block-start: 5px;
inset-block-end: 2px;
inset-inline-start: 12px;
inset-inline-end: 2rem;
padding-inline-start: var(--selected-left-border-width);
border-block-start: 1px solid var(--grey-30);
border-inline-start: none;
margin-inline-start: 1px;
background-color: #fff;
}

small,
.small {
font-size: 80%;
Expand Down
14 changes: 14 additions & 0 deletions test/fixture.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.