-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
185 lines (161 loc) · 5.51 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
---
title: theme_experiment
slug: Mozilla/Add-ons/WebExtensions/manifest.json/theme_experiment
page-type: webextension-manifest-key
browser-compat: webextensions.manifest.theme_experiment
---
{{AddonSidebar}}
<table class="fullwidth-table standard-table">
<tbody>
<tr>
<th scope="row">Type</th>
<td><code>Object</code></td>
</tr>
<tr>
<th scope="row">Mandatory</th>
<td>No</td>
</tr>
<tr>
<th scope="row">Manifest version</th>
<td>2 or higher</td>
</tr>
<tr>
<th scope="row">Example</th>
<td>
<pre class="brush: json">
"theme_experiment": {
"stylesheet": "style.css",
"colors": {
"popup_affordance": "--arrowpanel-dimmed"
},
"images": {
"theme_toolbar": "--toolbar-bgimage"
},
"properties": {
"toolbar_image_alignment":
"--toolbar-bgalignment"
}
}</pre
>
</td>
</tr>
</tbody>
</table>
This key enables the definition of experimental [`theme`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/theme) key properties for the Firefox interface. These experiments are a precursor to proposing new theme features for inclusion in Firefox. Experimentation is done by:
- creating a stylesheet that defines mappings between internal CSS selectors for Firefox UI elements and arbitrary CSS variables. The CSS variables are then mapped in the `colors`, `images`, and `properties` objects to new `theme` key properties.
- (without a stylesheet) using `colors`, `images`, and `properties` to map internal Firefox CSS selectors, such as `--arrowpanel-dimmed` to new `theme` key properties. This option limits experimentation to UI components that are associated with an inbuilt CSS variable.
To discover the CSS selectors for Firefox UI elements or internal Firefox CSS variables use the [browser toolbox](https://firefox-source-docs.mozilla.org/devtools-user/browser_toolbox/index.html).
> **Note:** This key is only available for use in Firefox Developer Edition and Firefox Nightly channels and requires the `extensions.experiments.enabled` preference to be enabled. In Firefox 73 and earlier, the `extensions.legacy.enabled` had to be used instead.
> **Warning:** This feature is experimental and could be subject to change.
## Syntax
The theme_experiment key is an object that takes the following properties:
<table class="fullwidth-table standard-table">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Type</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>stylesheet</code></td>
<td><code>String</code></td>
<td>
<p>Optional</p>
<p>
Name of a stylesheet providing mapping of Firefox UI element CSS
selectors to CSS variables.
</p>
</td>
</tr>
<tr>
<td><code>images</code></td>
<td><code>Object</code></td>
<td>
<p>Optional</p>
<p>
Mappings of CSS variables (as defined in Firefox or by the stylesheet
defined in <code>stylesheet</code>) to <code>images</code> property
names for use in the
<code
><a
href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/theme"
>theme</a
></code
>
key.
</p>
</td>
</tr>
<tr>
<td><code>colors</code></td>
<td><code>Object</code></td>
<td>
<p>Optional</p>
<p>
Mappings of CSS variables (as defined in Firefox or by the stylesheet
defined in <code>stylesheet</code>) to <code>colors</code> property
names for use in the
<code
><a
href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/theme"
>theme</a
></code
>
key.
</p>
</td>
</tr>
<tr>
<td><code>properties</code></td>
<td><code>Object</code></td>
<td>
<p>Optional</p>
<p>
Mappings of CSS variables (as defined in Firefox or by the stylesheet
defined in <code>stylesheet</code>) to
<code>properties</code> property names for use in the
<code
><a
href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/theme"
>theme</a
></code
>
key.
</p>
</td>
</tr>
</tbody>
</table>
## Examples
This example uses a stylesheet named `style.css` to provide the ability to set a color for the browser reload button in the [`theme`](/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/theme) key.
The stylesheet defines:
```css
#reload-button {
fill: var(--reload-button-color);
}
```
where `#reload-button` is the Firefox internal CSS selector for the reload button and `--reload-button-color` is an arbitrary name.
In the `manifest.json` file, `--reload-button-color` is then mapped to the name to be used in the `colors` property of `theme`:
```json
"theme_experiment": {
"stylesheet": "style.css",
"colors": {
"reload_button": "--reload-button-color"
}
}
```
The argument `reload_button` is used in the same way as any other `theme` property:
```json
"theme": {
"colors": {
"reload_button": "orange"
}
}
```
This has the effect of making the reload icon orange.
![Outcome of a theme experiment, showing the reload button colored orange.](theme_experiment.png)
This property can also be used in `browser.theme.update()`. `images` and `properties` work in a similar way to `colors`.
## Browser compatibility
{{Compat}}