tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

css.md (5274B)


CSS

This page is for information about CSS used by DevTools. Wondering about the Dev Edition theme? See this page for more information about the Developer Edition theme.

Basics

The CSS code is in devtools/client/themes.

Here are some basic tips that can optimize reviews if you are changing CSS:

Boilerplate

Make sure each file starts with the standard copyright header (see License Boilerplate).

Testing

CSS changes should generally be similar across platforms since they used a shared implementation, but there can still be differences worth checking out. Check major changes on Windows, OS X and Ubuntu.

Naming conventions

Naming standards for class names:

Light and Dark theme support

DevTools supports 2 different themes: the dark theme and the light theme. In order to support them, there are 2 class names available (theme-dark and theme-light).

Example:

.theme-light {
  --some-variable-name: <color-for-light-theme>;
}
.theme-dark {
  --some-variable-name: <color-for-dark-theme>;
}
#myElement {
  background-color: var(--some-variable-name);
}

HDPI support

It's recommended to use SVG since it keeps the CSS clean when supporting multiple resolutions. However, if only 1x and 2x PNG assets are available, you can use this @media query to target higher density displays (HDPI): @media (min-resolution: 1.1dppx). <!--TODO an example would be good here-->

Performance

* Descendent selectors should be avoided. * If possible, find ways to use only id selectors, class selectors and selector groups.

Localization

Text Direction

* Example: Use margin-inline-start: 3px; not margin-left: 3px.

RTL support for html modules

By default, new HTML modules support only left-to-right (LTR) and do not reuse the current direction of the browser.

To enable right-to-left (RTL) support in a module, set the [dir] attribute on the document element of the module:

The appropriate value for the dir attribute will then be set when the toolbox loads this module.

Testing

The recommended workflow to test RTL on DevTools is to use the Force RTL extension. After changing the direction using Force RTL, you should restart DevTools to make sure all modules apply the new direction. A future version of Force RTL will be able to update dynamically all DevTools documents.<!--TODO: update when the fate of this addon/webextension is known-->

Toggles

Sometimes you have a style that you want to turn on and off. For example a tree twisty (a expand-collapse arrow), a tab background, etc.

The Mozilla way is to perform the toggle using an attribute rather than a class:

.tree-node {
  background-image: url(right-arrow.svg);
}
.tree-node[open] {
  background-image: url(down-arrow.svg);
}

Tips