-
Notifications
You must be signed in to change notification settings - Fork 608
docs: add css layer names adr #6030
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# CSS Layer Names | ||
|
||
## Status | ||
|
||
| Stage | Status | | ||
| -------- | ----------- | | ||
| Approved | 🚧 | | ||
| Adopted | <!-- ✅ --> | | ||
|
||
## Context | ||
|
||
As Primer begins making use of CSS Layers, we need to define the named groups | ||
and order of the layers that we create. This will help to ensure a consistent | ||
ordering of layers and make sure that our naming is consistent across libraries. | ||
|
||
We have several areas that may be helpful to define explicit layers for: | ||
|
||
- Primitives | ||
- Octicons | ||
- Components | ||
- Resets | ||
- Utilities | ||
- Product | ||
|
||
This ADR will determine the naming convention for CSS Layers and the order in | ||
which they should be applied. | ||
|
||
## Decision | ||
|
||
Below is the list of CSS layers that we will use in Primer. They appear in the | ||
order in which they should be applied. | ||
|
||
- `base`: base styles that are applied to the document and the root element. This includes things like resets, typography, and | ||
global styles. | ||
- `theme`: styles that are applied for theming. This layer includes `@primer/primitives` | ||
- `icons`: styles that are applied to octicons | ||
- `components`: styles that are applied to components | ||
- `utilities`: an optional layer for utility classes in order to take precedence over earlier styles | ||
Comment on lines
+33
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking nitpick: I see the library mentioned (and used) below, but not in this list. Might be helpful to add it here after |
||
|
||
All layers should exist within the `primer` namespace. For example: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we differentiate PVC css, PCSS css, and PRC css? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooo good point, Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like |
||
|
||
```css | ||
@layer primer.base { | ||
/* ... */ | ||
} | ||
|
||
@layer primer.components.Button { | ||
/* ... */ | ||
} | ||
``` | ||
|
||
This will allow downstream consumers to order `primer` layers in a way that | ||
makes sense to the application. | ||
|
||
Naming for these layers must use `camelCase`. The only exception would be for | ||
the names of components which must use `PascalCase`. | ||
|
||
### Impact | ||
|
||
This change will impact the following libraries: | ||
|
||
- primer/css: styles in this library should be wrapped in either the utilities | ||
or icons layer. | ||
- primer/primitives: styles in this library should be wrapped in the theme layer | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you thinking this would be directly in our dist CSS files? |
||
- primer/octicons: styles in this library should be wrapped in the icons | ||
layer | ||
- primer/react: styles in this library should be wrapped in the components layer | ||
|
||
## Unresolved questions | ||
|
||
- Where should the order of CSS layers be defined? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feel like we should include a recommended order, but leave it up to the consumer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Just to confirm, is the ask here where we should have the suggestions documented? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah! Exactly, either documented or could be a file that we author the order in like:
|
||
|
||
## Links & Resources | ||
|
||
- [Tailwind CSS v4 Integration for Material UI](https://mui.com/material-ui/integrations/tailwindcss/tailwindcss-v4/) | ||
- [Mantine CSS Layers](https://mantine.dev/styles/mantine-styles/#css-layers) |
Uh oh!
There was an error while loading. Please reload this page.