Skip to content

Commit 62c33e6

Browse files
committed
docs: improve README.md with example and property groups
1 parent 4cf7f50 commit 62c33e6

1 file changed

Lines changed: 48 additions & 8 deletions

File tree

README.md

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,41 @@
55
[![npm](https://img.shields.io/npm/v/stylelint-config-clean-order)](https://www.npmjs.com/package/stylelint-config-clean-order)
66
[![ci](https://github.com/kutsan/stylelint-config-clean-order/actions/workflows/ci.yaml/badge.svg)](https://github.com/kutsan/stylelint-config-clean-order/actions/workflows/ci.yaml)
77

8-
Order your styles with [stylelint-order](https://github.com/hudochenkov/stylelint-order).
9-
10-
| Before | After    |
11-
| ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
12-
| ![before](https://user-images.githubusercontent.com/10108377/173256557-88f5098b-dad7-4339-a571-6850ed82828f.png) | ![after](https://user-images.githubusercontent.com/10108377/173256556-e29e892a-2d21-437c-8093-a345d5de920e.png) |
8+
Sort CSS properties into logical groups with [stylelint-order](https://github.com/hudochenkov/stylelint-order).
9+
10+
```css
11+
.card {
12+
/* Interaction */
13+
cursor: pointer;
14+
15+
/* Positioning */
16+
position: relative;
17+
z-index: 1;
18+
19+
/* Layout */
20+
display: flex;
21+
flex-direction: column;
22+
gap: var(--spacing-sm);
23+
24+
/* Box Model */
25+
width: 100%;
26+
padding: var(--spacing-md);
27+
border-radius: var(--radius-md);
28+
29+
/* Typography */
30+
font-size: var(--font-size-base);
31+
line-height: var(--line-height-normal);
32+
color: var(--color-text);
33+
34+
/* Appearance */
35+
opacity: 1;
36+
background-color: var(--color-bg);
37+
box-shadow: var(--shadow-md);
38+
39+
/* Transition */
40+
transition: transform var(--duration-fast);
41+
}
42+
```
1343

1444
## Usage
1545

@@ -28,7 +58,7 @@ export default {
2858
}
2959
```
3060

31-
That's it! Now your styles will be ordered! You can use `stylelint --fix` command to automatically fix order issues.
61+
Run `stylelint --fix` to automatically sort properties.
3262

3363
## Severity Options
3464

@@ -77,9 +107,19 @@ In addition to `stylelint-order` plugin, this package also overrides two rules (
77107

78108
If you want these rules to put into effect, make sure config packages after `stylelint-config-clean-order` do not override them.
79109

80-
## About orders
110+
## Property Order
111+
112+
Properties are organized into logical groups:
113+
114+
1. **Interaction**: `cursor`, `pointer-events`, `user-select`, etc.
115+
2. **Positioning**: `position`, `z-index`, `top`, `right`, `bottom`, `left`, `transform`, etc.
116+
3. **Layout**: `display`, `flex`, `grid`, `gap`, `align-items`, `justify-content`, etc.
117+
4. **Box Model**: `width`, `height`, `margin`, `padding`, `border`, etc.
118+
5. **Typography**: `font-size`, `line-height`, `color`, `text-align`, etc.
119+
6. **Appearance**: `background`, `opacity`, `box-shadow`, `filter`, etc.
120+
7. **Transition**: `transition`, `animation`, etc.
81121

82-
I try to hand-pick style orders in the most logical way to improve process of CSS refactoring; for example `font-size` before `line-height`, `display` before `align-items`. If you think order of a rule doesn't make sense, please open an issue so we can discuss. Thanks!
122+
Within each group, properties are ordered logically (e.g., `font-size` before `line-height`, `display` before `align-items`). If you think a property order doesn't make sense, please open an issue.
83123

84124
## License
85125

0 commit comments

Comments
 (0)