Skip to content

Commit 129ae6d

Browse files
authored
Add guidelines on attributes and CSS variables (#483)
Describes some of what was changed in #282, plus some notes on attributes
1 parent 2e68fb6 commit 129ae6d

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,20 @@ powered by Elasticsearch.
7171
## Deployment
7272

7373
Deploy documentation is available in our published docs here: https://readthedocs-addons.readthedocs.io/releasing.html
74+
75+
## Development guidelines
76+
77+
### Element attributes
78+
79+
- Don't use CSS classes on web component elements, these have tended to conflict with parent DOM styles. If needed, use CSS selectors against web component attributes like `:host[position="inline"]` instead.
80+
- When adding an attribute on a custom web components, don't use `data` prefixed attributes, for example `<readthedocs-flyout position="inline">`.
81+
- When using a custom attribute on a native element, do use `data` prefixed attributes, for example `<div data-position="inline">`.
82+
83+
### CSS variables
84+
85+
We use CSS variables to provide end users and theme maintainers with some light control of element styling of the inner shadow DOM elements.
86+
Variables have several layers of prefixing/inheritance, as shown here using `font-size` as an example:
87+
88+
- `--readthedocs-font-size`: This can be set at `html`/`:root` in the parent DOM to affect font size on all of our elements.
89+
- `--readthedocs-flyout-font-size`: This can be set at `html`/`:root` in the parent DOM to affect font size on only the flyout element.
90+
- `--addons-flyout-font-size`: This is an inner variable used by the addon shadow DOM CSS. It's set inside each addon `:host` CSS selector to give a default value to `--readthedocs-flyout-font-size` without overriding a user supplied value for this variable.

0 commit comments

Comments
 (0)