@atlaskit/tokens 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,375 @@
1
+ /**
2
+ * These styles have been copy-pasted from the output
3
+ * in packages/design-system/tokens/css
4
+ * this includes namespaced and non-namespaced tokens
5
+ */
6
+
7
+ html[data-theme='light'] {
8
+ --accent-boldBlue: #579dff;
9
+ --accent-boldGreen: #3acf91;
10
+ --accent-boldOrange: #ffa333;
11
+ --accent-boldPurple: #9f8fef;
12
+ --accent-boldRed: #f97362;
13
+ --accent-boldTeal: #53c8d5;
14
+ --accent-subtleBlue: #cce0ff;
15
+ --accent-subtleGreen: #aff3d6;
16
+ --accent-subtleMagenta: #fdd0ec;
17
+ --accent-subtleOrange: #ffdeb8;
18
+ --accent-subtlePurple: #dfd8fd;
19
+ --accent-subtleRed: #ffd2cc;
20
+ --accent-subtleTeal: #adeef5;
21
+ --background-sunken: #091e4208;
22
+ --background-default: #ffffff;
23
+ --background-card: #ffffff;
24
+ --background-overlay: #ffffff;
25
+ --background-selected-resting: #e9f2ff;
26
+ --background-selected-hover: #cce0ff;
27
+ --background-selected-pressed: #85b8ff;
28
+ --background-blanket: #091e427a;
29
+ --background-disabled: #091e420f;
30
+ --background-boldBrand-resting: #0c66e4;
31
+ --background-boldBrand-hover: #0055cc;
32
+ --background-boldBrand-pressed: #09326c;
33
+ --background-subtleBrand-resting: #e9f2ff;
34
+ --background-subtleBrand-hover: #cce0ff;
35
+ --background-subtleBrand-pressed: #85b8ff;
36
+ --background-boldDanger-resting: #ce2e1c;
37
+ --background-boldDanger-hover: #b22515;
38
+ --background-boldDanger-pressed: #601d16;
39
+ --background-subtleDanger-resting: #ffedeb;
40
+ --background-subtleDanger-hover: #ffd2cc;
41
+ --background-subtleDanger-pressed: #ff9a8f;
42
+ --background-boldWarning-resting: #ebb800;
43
+ --background-boldWarning-hover: #d19d00;
44
+ --background-boldWarning-pressed: #b38600;
45
+ --background-subtleWarning-resting: #fff7d6;
46
+ --background-subtleWarning-hover: #ffe785;
47
+ --background-subtleWarning-pressed: #ffd138;
48
+ --background-boldSuccess-resting: #1f845a;
49
+ --background-boldSuccess-hover: #216e4e;
50
+ --background-boldSuccess-pressed: #164b35;
51
+ --background-subtleSuccess-resting: #dffcf0;
52
+ --background-subtleSuccess-hover: #aff3d6;
53
+ --background-subtleSuccess-pressed: #76e0b4;
54
+ --background-boldDiscovery-resting: #6e5dc6;
55
+ --background-boldDiscovery-hover: #5e4db2;
56
+ --background-boldDiscovery-pressed: #352c63;
57
+ --background-subtleDiscovery-resting: #f3f0ff;
58
+ --background-subtleDiscovery-hover: #dfd8fd;
59
+ --background-subtleDiscovery-pressed: #b8acf6;
60
+ --background-boldNeutral-resting: #44546f;
61
+ --background-boldNeutral-hover: #2c3e5d;
62
+ --background-boldNeutral-pressed: #172b4d;
63
+ --background-transparentNeutral-hover: #091e420f;
64
+ --background-transparentNeutral-pressed: #091e4224;
65
+ --background-subtleNeutral-resting: #091e420f;
66
+ --background-subtleNeutral-hover: #091e4224;
67
+ --background-subtleNeutral-pressed: #091e424f;
68
+ --background-subtleBorderedNeutral-resting: #091e4208;
69
+ --background-subtleBorderedNeutral-pressed: #091e420f;
70
+ --border-focus: #388bff;
71
+ --border-neutral: #091e4224;
72
+ --iconBorder-brand: #1d7afc;
73
+ --iconBorder-danger: #e8422c;
74
+ --iconBorder-warning: #db6e00;
75
+ --iconBorder-success: #22a06b;
76
+ --iconBorder-discovery: #8270db;
77
+ --overlay-hover: #091e424f;
78
+ --overlay-pressed: #091e427a;
79
+ --text-selected: #0c66e4;
80
+ --text-highEmphasis: #172b4d;
81
+ --text-mediumEmphasis: #44546f;
82
+ --text-lowEmphasis: #626f86;
83
+ --text-onBold: #ffffff;
84
+ --text-onBoldWarning: #172b4d;
85
+ --text-link-resting: #0c66e4;
86
+ --text-link-pressed: #0055cc;
87
+ --text-brand: #0055cc;
88
+ --text-warning: #974f0c;
89
+ --text-danger: #b22515;
90
+ --text-success: #216e4e;
91
+ --text-discovery: #5e4db2;
92
+ --text-disabled: #8993a5;
93
+ --card: 0px 1px 1px #091e4240, 0px 0px 1px #091e424f;
94
+ --overlay: 0px 8px 12px #091e4226, 0px 0px 1px #091e424f;
95
+ --UNSAFE_util-transparent: transparent;
96
+ --UNSAFE_util-MISSING_TOKEN: hotpink;
97
+
98
+ /* namespaced */
99
+
100
+ --ds-accent-boldBlue: #579dff;
101
+ --ds-accent-boldGreen: #3acf91;
102
+ --ds-accent-boldOrange: #ffa333;
103
+ --ds-accent-boldPurple: #9f8fef;
104
+ --ds-accent-boldRed: #f97362;
105
+ --ds-accent-boldTeal: #53c8d5;
106
+ --ds-accent-subtleBlue: #cce0ff;
107
+ --ds-accent-subtleGreen: #aff3d6;
108
+ --ds-accent-subtleMagenta: #fdd0ec;
109
+ --ds-accent-subtleOrange: #ffdeb8;
110
+ --ds-accent-subtlePurple: #dfd8fd;
111
+ --ds-accent-subtleRed: #ffd2cc;
112
+ --ds-accent-subtleTeal: #adeef5;
113
+ --ds-background-sunken: #091e4208;
114
+ --ds-background-default: #ffffff;
115
+ --ds-background-card: #ffffff;
116
+ --ds-background-overlay: #ffffff;
117
+ --ds-background-selected-resting: #e9f2ff;
118
+ --ds-background-selected-hover: #cce0ff;
119
+ --ds-background-selected-pressed: #85b8ff;
120
+ --ds-background-blanket: #091e427a;
121
+ --ds-background-disabled: #091e420f;
122
+ --ds-background-boldBrand-resting: #0c66e4;
123
+ --ds-background-boldBrand-hover: #0055cc;
124
+ --ds-background-boldBrand-pressed: #09326c;
125
+ --ds-background-subtleBrand-resting: #e9f2ff;
126
+ --ds-background-subtleBrand-hover: #cce0ff;
127
+ --ds-background-subtleBrand-pressed: #85b8ff;
128
+ --ds-background-boldDanger-resting: #ce2e1c;
129
+ --ds-background-boldDanger-hover: #b22515;
130
+ --ds-background-boldDanger-pressed: #601d16;
131
+ --ds-background-subtleDanger-resting: #ffedeb;
132
+ --ds-background-subtleDanger-hover: #ffd2cc;
133
+ --ds-background-subtleDanger-pressed: #ff9a8f;
134
+ --ds-background-boldWarning-resting: #ebb800;
135
+ --ds-background-boldWarning-hover: #d19d00;
136
+ --ds-background-boldWarning-pressed: #b38600;
137
+ --ds-background-subtleWarning-resting: #fff7d6;
138
+ --ds-background-subtleWarning-hover: #ffe785;
139
+ --ds-background-subtleWarning-pressed: #ffd138;
140
+ --ds-background-boldSuccess-resting: #1f845a;
141
+ --ds-background-boldSuccess-hover: #216e4e;
142
+ --ds-background-boldSuccess-pressed: #164b35;
143
+ --ds-background-subtleSuccess-resting: #dffcf0;
144
+ --ds-background-subtleSuccess-hover: #aff3d6;
145
+ --ds-background-subtleSuccess-pressed: #76e0b4;
146
+ --ds-background-boldDiscovery-resting: #6e5dc6;
147
+ --ds-background-boldDiscovery-hover: #5e4db2;
148
+ --ds-background-boldDiscovery-pressed: #352c63;
149
+ --ds-background-subtleDiscovery-resting: #f3f0ff;
150
+ --ds-background-subtleDiscovery-hover: #dfd8fd;
151
+ --ds-background-subtleDiscovery-pressed: #b8acf6;
152
+ --ds-background-boldNeutral-resting: #44546f;
153
+ --ds-background-boldNeutral-hover: #2c3e5d;
154
+ --ds-background-boldNeutral-pressed: #172b4d;
155
+ --ds-background-transparentNeutral-hover: #091e420f;
156
+ --ds-background-transparentNeutral-pressed: #091e4224;
157
+ --ds-background-subtleNeutral-resting: #091e420f;
158
+ --ds-background-subtleNeutral-hover: #091e4224;
159
+ --ds-background-subtleNeutral-pressed: #091e424f;
160
+ --ds-background-subtleBorderedNeutral-resting: #091e4208;
161
+ --ds-background-subtleBorderedNeutral-pressed: #091e420f;
162
+ --ds-border-focus: #388bff;
163
+ --ds-border-neutral: #091e4224;
164
+ --ds-iconBorder-brand: #1d7afc;
165
+ --ds-iconBorder-danger: #e8422c;
166
+ --ds-iconBorder-warning: #db6e00;
167
+ --ds-iconBorder-success: #22a06b;
168
+ --ds-iconBorder-discovery: #8270db;
169
+ --ds-overlay-hover: #091e424f;
170
+ --ds-overlay-pressed: #091e427a;
171
+ --ds-text-selected: #0c66e4;
172
+ --ds-text-highEmphasis: #172b4d;
173
+ --ds-text-mediumEmphasis: #44546f;
174
+ --ds-text-lowEmphasis: #626f86;
175
+ --ds-text-onBold: #ffffff;
176
+ --ds-text-onBoldWarning: #172b4d;
177
+ --ds-text-link-resting: #0c66e4;
178
+ --ds-text-link-pressed: #0055cc;
179
+ --ds-text-brand: #0055cc;
180
+ --ds-text-warning: #974f0c;
181
+ --ds-text-danger: #b22515;
182
+ --ds-text-success: #216e4e;
183
+ --ds-text-discovery: #5e4db2;
184
+ --ds-text-disabled: #8993a5;
185
+ --ds-card: 0px 1px 1px #091e4240, 0px 0px 1px #091e424f;
186
+ --ds-overlay: 0px 8px 12px #091e4226, 0px 0px 1px #091e424f;
187
+ --ds-UNSAFE_util-transparent: transparent;
188
+ --ds-UNSAFE_util-MISSING_TOKEN: #fa11f2;
189
+ }
190
+
191
+ html[data-theme='dark'] {
192
+ --accent-boldBlue: #0c66e4;
193
+ --accent-boldGreen: #1f845a;
194
+ --accent-boldOrange: #b85c00;
195
+ --accent-boldPurple: #6e5dc6;
196
+ --accent-boldRed: #ce2e1c;
197
+ --accent-boldTeal: #1d7f8c;
198
+ --accent-subtleBlue: #09326c;
199
+ --accent-subtleGreen: #164b35;
200
+ --accent-subtleMagenta: #50253f;
201
+ --accent-subtleOrange: #5f3811;
202
+ --accent-subtlePurple: #352c63;
203
+ --accent-subtleRed: #601d16;
204
+ --accent-subtleTeal: #1d474c;
205
+ --background-sunken: #03040454;
206
+ --background-default: #161a1d;
207
+ --background-card: #1d2125;
208
+ --background-overlay: #22272b;
209
+ --background-selected-resting: #a1bdd914;
210
+ --background-selected-hover: #a6c5e229;
211
+ --background-selected-pressed: #bfdbf847;
212
+ --background-blanket: #03040454;
213
+ --background-disabled: #a1bdd914;
214
+ --background-boldBrand-resting: #579dff;
215
+ --background-boldBrand-hover: #85b8ff;
216
+ --background-boldBrand-pressed: #cce0ff;
217
+ --background-subtleBrand-resting: #082145;
218
+ --background-subtleBrand-hover: #09326c;
219
+ --background-subtleBrand-pressed: #0055cc;
220
+ --background-boldDanger-resting: #f97362;
221
+ --background-boldDanger-hover: #ff9a8f;
222
+ --background-boldDanger-pressed: #ffd2cc;
223
+ --background-subtleDanger-resting: #391713;
224
+ --background-subtleDanger-hover: #601d16;
225
+ --background-subtleDanger-pressed: #b22515;
226
+ --background-boldWarning-resting: #ebb800;
227
+ --background-boldWarning-hover: #ffd138;
228
+ --background-boldWarning-pressed: #ffe785;
229
+ --background-subtleWarning-resting: #3d2e00;
230
+ --background-subtleWarning-hover: #533f04;
231
+ --background-subtleWarning-pressed: #7f5f01;
232
+ --background-boldSuccess-resting: #3acf91;
233
+ --background-boldSuccess-hover: #76e0b4;
234
+ --background-boldSuccess-pressed: #aff3d6;
235
+ --background-subtleSuccess-resting: #133527;
236
+ --background-subtleSuccess-hover: #164b35;
237
+ --background-subtleSuccess-pressed: #216e4e;
238
+ --background-boldDiscovery-resting: #9f8fef;
239
+ --background-boldDiscovery-hover: #b8acf6;
240
+ --background-boldDiscovery-pressed: #dfd8fd;
241
+ --background-subtleDiscovery-resting: #231c3f;
242
+ --background-subtleDiscovery-hover: #352c63;
243
+ --background-subtleDiscovery-pressed: #5e4db2;
244
+ --background-boldNeutral-resting: #9fadbc;
245
+ --background-boldNeutral-hover: #b6c2cf;
246
+ --background-boldNeutral-pressed: #c7d1db;
247
+ --background-transparentNeutral-hover: #a1bdd914;
248
+ --background-transparentNeutral-pressed: #a6c5e229;
249
+ --background-subtleNeutral-resting: #a1bdd914;
250
+ --background-subtleNeutral-hover: #a6c5e229;
251
+ --background-subtleNeutral-pressed: #bfdbf847;
252
+ --background-subtleBorderedNeutral-resting: #bcd6f00a;
253
+ --background-subtleBorderedNeutral-pressed: #a1bdd914;
254
+ --border-focus: #85b8ff;
255
+ --border-neutral: #a6c5e229;
256
+ --iconBorder-brand: #388bff;
257
+ --iconBorder-danger: #f35844;
258
+ --iconBorder-warning: #d19d00;
259
+ --iconBorder-success: #2abb7f;
260
+ --iconBorder-discovery: #8f7ee7;
261
+ --overlay-hover: #bfdbf847;
262
+ --overlay-pressed: #a3c0db7a;
263
+ --text-selected: #579dff;
264
+ --text-highEmphasis: #c7d1db;
265
+ --text-mediumEmphasis: #9fadbc;
266
+ --text-lowEmphasis: #8696a7;
267
+ --text-onBold: #161a1d;
268
+ --text-onBoldWarning: #161a1d;
269
+ --text-link-resting: #579dff;
270
+ --text-link-pressed: #85b8ff;
271
+ --text-brand: #85b8ff;
272
+ --text-warning: #ffd138;
273
+ --text-danger: #ff9a8f;
274
+ --text-success: #76e0b4;
275
+ --text-discovery: #b8acf6;
276
+ --text-disabled: #5a6977;
277
+ --card: 0px 1px 1px #03040480, 0px 0px 1px #03040480;
278
+ --overlay: inset 0px 0px 0px 1px #bcd6f00a, 0px 8px 12px #0304045c,
279
+ 0px 0px 1px #03040480;
280
+ --UNSAFE_util-transparent: transparent;
281
+ --UNSAFE_util-MISSING_TOKEN: hotpink;
282
+
283
+ /* namespaced */
284
+
285
+ --ds-accent-boldBlue: #0c66e4;
286
+ --ds-accent-boldGreen: #1f845a;
287
+ --ds-accent-boldOrange: #b85c00;
288
+ --ds-accent-boldPurple: #6e5dc6;
289
+ --ds-accent-boldRed: #ce2e1c;
290
+ --ds-accent-boldTeal: #1d7f8c;
291
+ --ds-accent-subtleBlue: #09326c;
292
+ --ds-accent-subtleGreen: #164b35;
293
+ --ds-accent-subtleMagenta: #50253f;
294
+ --ds-accent-subtleOrange: #5f3811;
295
+ --ds-accent-subtlePurple: #352c63;
296
+ --ds-accent-subtleRed: #601d16;
297
+ --ds-accent-subtleTeal: #1d474c;
298
+ --ds-background-sunken: #03040454;
299
+ --ds-background-default: #161a1d;
300
+ --ds-background-card: #1d2125;
301
+ --ds-background-overlay: #22272b;
302
+ --ds-background-selected-resting: #a1bdd914;
303
+ --ds-background-selected-hover: #a6c5e229;
304
+ --ds-background-selected-pressed: #bfdbf847;
305
+ --ds-background-blanket: #03040454;
306
+ --ds-background-disabled: #a1bdd914;
307
+ --ds-background-boldBrand-resting: #579dff;
308
+ --ds-background-boldBrand-hover: #85b8ff;
309
+ --ds-background-boldBrand-pressed: #cce0ff;
310
+ --ds-background-subtleBrand-resting: #082145;
311
+ --ds-background-subtleBrand-hover: #09326c;
312
+ --ds-background-subtleBrand-pressed: #0055cc;
313
+ --ds-background-boldDanger-resting: #f97362;
314
+ --ds-background-boldDanger-hover: #ff9a8f;
315
+ --ds-background-boldDanger-pressed: #ffd2cc;
316
+ --ds-background-subtleDanger-resting: #391713;
317
+ --ds-background-subtleDanger-hover: #601d16;
318
+ --ds-background-subtleDanger-pressed: #b22515;
319
+ --ds-background-boldWarning-resting: #ebb800;
320
+ --ds-background-boldWarning-hover: #ffd138;
321
+ --ds-background-boldWarning-pressed: #ffe785;
322
+ --ds-background-subtleWarning-resting: #3d2e00;
323
+ --ds-background-subtleWarning-hover: #533f04;
324
+ --ds-background-subtleWarning-pressed: #7f5f01;
325
+ --ds-background-boldSuccess-resting: #3acf91;
326
+ --ds-background-boldSuccess-hover: #76e0b4;
327
+ --ds-background-boldSuccess-pressed: #aff3d6;
328
+ --ds-background-subtleSuccess-resting: #133527;
329
+ --ds-background-subtleSuccess-hover: #164b35;
330
+ --ds-background-subtleSuccess-pressed: #216e4e;
331
+ --ds-background-boldDiscovery-resting: #9f8fef;
332
+ --ds-background-boldDiscovery-hover: #b8acf6;
333
+ --ds-background-boldDiscovery-pressed: #dfd8fd;
334
+ --ds-background-subtleDiscovery-resting: #231c3f;
335
+ --ds-background-subtleDiscovery-hover: #352c63;
336
+ --ds-background-subtleDiscovery-pressed: #5e4db2;
337
+ --ds-background-boldNeutral-resting: #9fadbc;
338
+ --ds-background-boldNeutral-hover: #b6c2cf;
339
+ --ds-background-boldNeutral-pressed: #c7d1db;
340
+ --ds-background-transparentNeutral-hover: #a1bdd914;
341
+ --ds-background-transparentNeutral-pressed: #a6c5e229;
342
+ --ds-background-subtleNeutral-resting: #a1bdd914;
343
+ --ds-background-subtleNeutral-hover: #a6c5e229;
344
+ --ds-background-subtleNeutral-pressed: #bfdbf847;
345
+ --ds-background-subtleBorderedNeutral-resting: #bcd6f00a;
346
+ --ds-background-subtleBorderedNeutral-pressed: #a1bdd914;
347
+ --ds-border-focus: #85b8ff;
348
+ --ds-border-neutral: #a6c5e229;
349
+ --ds-iconBorder-brand: #388bff;
350
+ --ds-iconBorder-danger: #f35844;
351
+ --ds-iconBorder-warning: #d19d00;
352
+ --ds-iconBorder-success: #2abb7f;
353
+ --ds-iconBorder-discovery: #8f7ee7;
354
+ --ds-overlay-hover: #bfdbf847;
355
+ --ds-overlay-pressed: #a3c0db7a;
356
+ --ds-text-selected: #579dff;
357
+ --ds-text-highEmphasis: #c7d1db;
358
+ --ds-text-mediumEmphasis: #9fadbc;
359
+ --ds-text-lowEmphasis: #8696a7;
360
+ --ds-text-onBold: #161a1d;
361
+ --ds-text-onBoldWarning: #161a1d;
362
+ --ds-text-link-resting: #579dff;
363
+ --ds-text-link-pressed: #85b8ff;
364
+ --ds-text-brand: #85b8ff;
365
+ --ds-text-warning: #ffd138;
366
+ --ds-text-danger: #ff9a8f;
367
+ --ds-text-success: #76e0b4;
368
+ --ds-text-discovery: #b8acf6;
369
+ --ds-text-disabled: #5a6977;
370
+ --ds-card: 0px 1px 1px #03040480, 0px 0px 1px #03040480;
371
+ --ds-overlay: inset 0px 0px 0px 1px #bcd6f00a, 0px 8px 12px #0304045c,
372
+ 0px 0px 1px #03040480;
373
+ --ds-UNSAFE_util-transparent: transparent;
374
+ --ds-UNSAFE_util-MISSING_TOKEN: #fa11f2;
375
+ }
@@ -0,0 +1,75 @@
1
+ /* eslint-disable func-names */
2
+ /* eslint-disable no-console */
3
+ /* eslint-disable no-undef */
4
+ /* eslint-disable no-unused-vars */
5
+
6
+ // Chrome automatically creates a background.html page for this to execute.
7
+ // This can access the inspected page via executeScript
8
+ //
9
+ // Can use:
10
+ // chrome.tabs.*
11
+ // chrome.extension.*
12
+
13
+ // sync options settings
14
+ function setOptions(data = {}) {
15
+ chrome.storage.sync.set(data, function () {
16
+ console.log('Settings saved');
17
+ });
18
+ }
19
+
20
+ function getOptions(keys, callback) {
21
+ chrome.storage.sync.get(keys, function (data) {
22
+ console.log('Settings retrieved', data);
23
+ callback(data);
24
+ });
25
+ }
26
+
27
+ function queryTheme() {
28
+ const theme = window.localStorage && window.localStorage.theme;
29
+ console.log('theme', theme);
30
+ chrome.runtime.sendMessage({ theme });
31
+ }
32
+
33
+ // when the extension is loaded when opening devtools
34
+ chrome.runtime.onConnect.addListener(function (port) {
35
+ // check for the theme in the running tab
36
+ chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
37
+ chrome.tabs.executeScript(tabs[0].id, {
38
+ code: `(${queryTheme})()`,
39
+ });
40
+ });
41
+ const extensionListener = function (message, sender, sendResponse) {
42
+ if (message.tabId && message.action) {
43
+ // handle changing theme from extension into inspected page
44
+ // these messages come from panel.js
45
+
46
+ console.log('background', message);
47
+ switch (message.action) {
48
+ case 'removeTheme':
49
+ chrome.tabs.sendMessage(message.tabId, 'none');
50
+ break;
51
+ case 'setTheme-light':
52
+ chrome.tabs.sendMessage(message.tabId, 'light');
53
+ break;
54
+ case 'setTheme-dark':
55
+ chrome.tabs.sendMessage(message.tabId, 'dark');
56
+ break;
57
+ default:
58
+ break;
59
+ }
60
+
61
+ // This accepts messages from the inspected page and
62
+ // sends them to the panel
63
+ } else {
64
+ port.postMessage(message);
65
+ }
66
+ sendResponse(message);
67
+ };
68
+
69
+ // Listens to messages sent from the panel
70
+ chrome.runtime.onMessage.addListener(extensionListener);
71
+
72
+ port.onDisconnect.addListener(function () {
73
+ chrome.runtime.onMessage.removeListener(extensionListener);
74
+ });
75
+ });
@@ -0,0 +1,75 @@
1
+ /* eslint-disable func-names */
2
+ /* eslint-disable no-console */
3
+ /* eslint-disable no-undef */
4
+ /* eslint-disable no-unused-vars */
5
+
6
+ // This is included and executed in the inspected page
7
+
8
+ // local storage helpers
9
+ // we store the theme name here for when users refresh the page
10
+ // we can quickly check and add the theme tokens back into the page
11
+ function getLocalStorage(key) {
12
+ if (typeof window === 'undefined') {
13
+ return undefined;
14
+ }
15
+ return window.localStorage && window.localStorage[key];
16
+ }
17
+
18
+ function setLocalStorage(key, value) {
19
+ if (window && window.localStorage) {
20
+ window.localStorage[key] = value;
21
+ }
22
+ }
23
+
24
+ // these functions are almost identical to the ones in background.js
25
+ // we need them here because the extension is isolated from the inspected page
26
+ // and has no idea if someone were to delete local storage or change the theme value
27
+ // in local storage
28
+ // This file is also run on document_start - https://developer.chrome.com/docs/extensions/mv3/content_scripts/#run_time
29
+ // which allows the theme CSS to seemingly persist across page refreshes
30
+ function removeTheme() {
31
+ const html = document.querySelector('html');
32
+ if (html) {
33
+ html.removeAttribute('data-theme');
34
+ setLocalStorage('theme', 'none');
35
+ }
36
+ }
37
+
38
+ function setTheme(themeName = 'light') {
39
+ const html = document.querySelector('html');
40
+ html.setAttribute('data-theme', themeName);
41
+ setLocalStorage('theme', themeName);
42
+ }
43
+
44
+ function handleTheme(theme) {
45
+ if (!theme || theme === 'none') {
46
+ removeTheme();
47
+ } else if (theme === 'light') {
48
+ setTheme(theme);
49
+ } else if (theme === 'dark') {
50
+ setTheme(theme);
51
+ }
52
+ }
53
+
54
+ function init() {
55
+ console.log('tokens extension script attached');
56
+ const theme = getLocalStorage('theme');
57
+ handleTheme(theme);
58
+
59
+ const port = chrome.runtime.connect({
60
+ name: 'Theming Communication',
61
+ });
62
+ // tell extension what the theme value was from local storage
63
+ port.postMessage({ theme });
64
+ }
65
+
66
+ function main() {
67
+ init();
68
+
69
+ chrome.runtime.onMessage.addListener(function (message) {
70
+ // the theme value from panel.html
71
+ const theme = message || 'none';
72
+ handleTheme(theme);
73
+ });
74
+ }
75
+ main();
@@ -0,0 +1 @@
1
+ <script src="devtools.js"></script>
@@ -0,0 +1,14 @@
1
+ /* eslint-disable func-names */
2
+ /* eslint-disable no-undef */
3
+
4
+ // Can use
5
+ // chrome.devtools.*
6
+ // chrome.extension.*
7
+
8
+ // Create a tab in the devtools area
9
+ chrome.devtools.panels.create(
10
+ 'Tokens theming controls',
11
+ 'toast.png',
12
+ 'panel.html',
13
+ function () {},
14
+ );
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "Tokens Test Theming Extension",
3
+ "version": "0.2",
4
+ "description": "An extension to test theming implementations with @atlaskit/tokens",
5
+ "devtools_page": "devtools.html",
6
+ "background": {
7
+ "scripts": [
8
+ "background.js"
9
+ ]
10
+ },
11
+ "permissions": [
12
+ "tabs",
13
+ "activeTab",
14
+ "http://*/*",
15
+ "https://*/*",
16
+ "storage",
17
+ "webNavigation"
18
+ ],
19
+ "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs88BPdeATfZMpEmyioaG2gS8OXpcEYKTnfriDiOPrHApjiMOrbiMU2cFZsbxqKpBMktKrmOa6PRq328H6N4QN42p2c9eGdY1Mgun9UAQFV1EQWsUelAWzKeZRMRPWVBTnMHVRIHe7p9cXoHCTRB0kIbqR+P7zhxaf2bCaaiQ/UUMeX7LFLDoXNCmuFOnjLLupkNgJJdPIDCHpEypwQCpNNUH4UsOxJ0yTfAplYdw7cc7ZwSh/BJqAWRplywkXwRrL5FeFfXknIi/tMZzxYv4ZM89CY5ogPr1JZMVA5sw0xW0oh81wLHa6Y47mmPXgMtzyNKZ/QJRP6b66uNuot+FXQIDAQAB",
20
+ "content_scripts": [
21
+ {
22
+ "matches": [
23
+ "http://*/*",
24
+ "https://*/*"
25
+ ],
26
+ "js": [
27
+ "content-script.js"
28
+ ],
29
+ "css": [
30
+ "atlassian-theme.css"
31
+ ],
32
+ "run_at": "document_start"
33
+ }
34
+ ],
35
+ "manifest_version": 2
36
+ }
@@ -0,0 +1,10 @@
1
+ /* eslint-disable func-names */
2
+ /* eslint-disable no-undef */
3
+
4
+ document.querySelector('button').addEventListener('click', function () {
5
+ sendObjectToDevTools({ content: 'Changed by page' });
6
+ });
7
+ function sendObjectToDevTools(message) {
8
+ // The callback here can be used to execute something on receipt
9
+ chrome.extension.sendMessage(message, function () {});
10
+ }
@@ -0,0 +1,36 @@
1
+ /* eslint-disable no-param-reassign */
2
+ /* eslint-disable func-names */
3
+ /* eslint-disable no-undef */
4
+ /* eslint-disable no-unused-vars */
5
+
6
+ // This creates and maintains the communication channel between
7
+ // the inspectedPage and the dev tools panel.
8
+ //
9
+ // In this example, messages are JSON objects
10
+ // {
11
+ // action: ['code'|'script'|'message'], // What action to perform on the inspected page
12
+ // content: [String|Path to script|Object], // data to be passed through
13
+ // tabId: [Automatically added]
14
+ // }
15
+
16
+ (function createChannel() {
17
+ // Create a port with background page for continous message communication
18
+ const port = chrome.runtime.connect({
19
+ name: 'Theming Communication',
20
+ });
21
+
22
+ // Listen to messages from the background page
23
+ port.onMessage.addListener(function (message) {
24
+ // the theme value from local storage in the inspected page
25
+ const theme = message.theme || 'none';
26
+ // update the extension panel.html with the theme value
27
+ document.querySelector('#selected-theme').innerHTML = theme;
28
+ });
29
+ })();
30
+
31
+ // This sends an object to the background page
32
+ // where it can be relayed to the inspected page
33
+ function sendObjectToInspectedPage(message) {
34
+ message.tabId = chrome.devtools.inspectedWindow.tabId;
35
+ chrome.runtime.sendMessage(message);
36
+ }
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html style="background: white">
3
+ <head>
4
+ <style>
5
+ button {
6
+ margin: 1rem 0;
7
+ padding: 0.5rem 1rem;
8
+ }
9
+ p {
10
+ font-size: 1rem;
11
+ }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <div style="display: flex; flex-direction: column">
16
+ <h1>Settings</h1>
17
+ <p>Theme: <span id="selected-theme">none</span></p>
18
+ <button id="disable-theme">Disable theme</button>
19
+ <button id="enable-light-theme">Enable Atlassian light theme</button>
20
+ <button id="enable-dark-theme">Enable Atlassian dark theme</button>
21
+ </div>
22
+ <script src="messaging.js"></script>
23
+ <script src="panel.js"></script>
24
+ </body>
25
+ </html>