Skip to content

Commit 0347b89

Browse files
authored
chore(css-modules): 🤖 Enable linter on CSS files (#945)
* chore: 🤖 add style linter * chore: 🤖 add base style lint configuration file * chore: 🤖 add distinction code and css linter commands * chore: 🤖 create a browser list listing >= 2020 * chore: 🤖 set browser list rc for latest 4 years and filter out obscure browsers * chore: 🤖 Browser compatibility issues are now properly handled. * chore: 🤖 ignore edgecase * refactor: 💡 Selectors with lower specificity should come before those with higher specificity * chore: 🤖 property ordering by logical groups * chore: 🤖 exclude obscure browsers * style: 💄 reorder fix * docs: 📝 browser support * chore: 🤖 remove deprecated rid-gap * style: 💄 remove typo * chore: 🤖 allow empty lines * docs: 📝 show only top 4 browsers in doc * refactor: 💡 update stylelinter to prefer BEM's naming convention * refactor: 💡 rename class names to favour BEM's naming convention (remove double dashes) * refactor: 💡 rename class names in css module * chore: 🤖 remove link to BEM's two dashes * docs: 📝 standard BEM naming * chore: 🤖 update comment
1 parent c3c3d74 commit 0347b89

File tree

8 files changed

+1067
-139
lines changed

8 files changed

+1067
-139
lines changed

.browserslistrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# NOTE: Modern browsers from the last 4 years with >0.5% market share, but explicitly exclude obscure browsers that have limited CSS feature support
2+
last 4 years
3+
> 0.5%
4+
not and_qq > 0
5+
not baidu > 0
6+
not and_uc > 0
7+
not kaios > 0
8+
not op_mini all

.llm/CONVENTIONS.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,24 @@ export interface ComponentProps extends React.HTMLAttributes<HTMLElement> {
2727
- Use transient props (prefixed with `$`) for styled-component internal state
2828
- Use `data-*` attributes for styling hooks instead of generated class names
2929

30-
### CSS Modules (BEM Naming)
30+
### CSS Modules (Standard BEM Naming)
3131

3232
When using CSS Modules (migration in progress from styled-components):
3333

34-
- **Follow BEM naming convention**:
34+
- **Follow standard BEM naming convention** (https://en.bem.info/methodology/naming-convention/):
3535
- `.button` - Block (component root)
36-
- `.button__icon` - Element (child of block, use double underscore)
37-
- `.button--primary` - Modifier (variant/state, use double dash)
38-
- `.button--primary:hover` - State pseudo-classes
36+
- `.button__icon` - Element (child of block, use double underscore `__`)
37+
- `.button_primary` - Modifier (variant/state, use single underscore `_`)
38+
- `.button_align-center` - Modifier with hyphenated value
39+
- `.button_primary:hover` - Pseudo-classes on modifiers
40+
- `.button_primary.button_loading` - Multiple modifiers on same element
3941

4042
- **Example structure**:
4143
```css
4244
.button { /* base styles */ }
4345
.button__icon { /* icon element */ }
44-
.button--primary { /* primary variant */ }
45-
.button--primary:focus-visible { /* keyboard focus state */ }
46+
.button_primary { /* primary variant */ }
47+
.button_primary:focus-visible { /* keyboard focus state */ }
4648
```
4749
- Use CSS custom properties from theme tokens: `var(--click-button-basic-color-primary-background-default)`
4850
- Always include `:focus-visible` styles for keyboard accessibility, never use `outline: none` without replacement
@@ -97,7 +99,7 @@ src/components/
9799
├── Button/
98100
│ ├── Button.tsx # Main component implementation
99101
│ ├── Button.types.ts # Type definitions (interfaces, types)
100-
│ ├── Button.styles.ts # Styled-components
102+
│ ├── Button.module.css # CSS Modules styles
101103
│ ├── Button.test.tsx # Unit tests
102104
│ ├── Button.stories.tsx # Storybook documentation
103105
│ └── index.ts # Public exports

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ You can find the official docs for the Click UI design system and component libr
1818
## Overview
1919

2020
* [Requirements](#requirements)
21+
* [Browser Support](#browser-support)
2122
* [Quick Start](#quick-start)
2223
* [Development](#development)
2324
- [Generating design tokens](#generating-design-tokens)
@@ -56,6 +57,27 @@ You can find the official docs for the Click UI design system and component libr
5657
- Nodejs (>= 22.12.x) as runtime
5758
- Yarn (>= 4.5.3) for development, any other package manager in a host project
5859

60+
## Browser Support
61+
62+
Click UI targets modern browsers from the last 4 years with significant market share (>0.5%). This ensures broad compatibility while allowing the use of modern CSS features.
63+
64+
| Browser | Minimum Version |
65+
|---------|-----------------|
66+
| Chrome | 100+ |
67+
| Edge | 100+ |
68+
| Firefox | 99+ |
69+
| Safari | 15.5+ |
70+
71+
The following browsers are explicitly **not supported** due to limited CSS feature support:
72+
- QQ Browser
73+
- Baidu Browser
74+
- UC Browser
75+
- KaiOS Browser
76+
- Opera Mini
77+
78+
> [!NOTE]
79+
> The browser support list is defined in `.browserslistrc` and enforced via CSS linting during development. CSS features that aren't supported by the target browsers will trigger linting errors.
80+
5981
## Quick Start
6082

6183
Install the package via npm or your favourite package manager:

package.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,12 @@
377377
"format:fix": ".scripts/bash/format --write",
378378
"generate:exports": ".scripts/js/generate-exports",
379379
"generate:tokens": "node ./.scripts/js/generate-tokens.js && yarn format:fix src/theme/tokens/**/*.ts",
380-
"lint": "eslint src --report-unused-disable-directives",
381-
"lint:fix": "eslint src --report-unused-disable-directives --fix",
380+
"lint": "yarn lint:code && yarn lint:css",
381+
"lint:fix": "yarn lint:code:fix && yarn lint:css:fix",
382+
"lint:code": "eslint src --report-unused-disable-directives",
383+
"lint:code:fix": "eslint src --report-unused-disable-directives --fix",
384+
"lint:css": "stylelint \"src/**/*.css\"",
385+
"lint:css:fix": "stylelint \"src/**/*.css\" --fix",
382386
"prepare": "husky",
383387
"prettify": "yarn format:fix",
384388
"preview": "vite preview",
@@ -467,6 +471,10 @@
467471
"storybook": "^10.1.10",
468472
"storybook-addon-pseudo-states": "^10.1.10",
469473
"style-dictionary": "^5.0.0",
474+
"stylelint": "^17.5.0",
475+
"stylelint-config-standard": "^40.0.0",
476+
"stylelint-no-unsupported-browser-features": "^8.1.1",
477+
"stylelint-order": "^8.1.1",
470478
"stylis": "^4.3.0",
471479
"ts-node": "^10.9.1",
472480
"typescript": "^5.5.3",

0 commit comments

Comments
 (0)