@brightspace-ui/core 2.29.4 → 2.29.5

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.
package/helpers/prism.js CHANGED
@@ -28,6 +28,7 @@ codeLanguages.set('plain', 'Plain Text');
28
28
  codeLanguages.set('python', 'Python');
29
29
  codeLanguages.set('r', 'R');
30
30
  codeLanguages.set('racket', 'Racket');
31
+ codeLanguages.set('regex', 'Regex');
31
32
  codeLanguages.set('sql', 'SQL');
32
33
  codeLanguages.set('wolfram', 'Wolfram');
33
34
 
@@ -37,77 +38,78 @@ export const colorModes = {
37
38
  };
38
39
 
39
40
  const darkColors = Object.freeze({
40
- background: '#2d2d2d',
41
- language: '#6e7376',
42
- lineNumbers: '#ffffff',
43
- lineNumbersSeparator: '#999999',
44
- tokenDefault: '#cccccc',
45
- tokenComment: '#808080',
46
- tokenPunctuation: '#d4d4d4',
47
- tokenNumber: '#d4d4d4',
48
- tokenUrl: '#d4d4d4',
49
- tokenOperator: '#d4d4d4',
50
- tokenInterpolation: '#9cdcfe',
51
- tokenAttributeName: '#9cdcfe',
52
- tokenConstant: '#9cdcfe',
53
- tokenProperty: '#9cdcfe',
54
- tokenTag: '#569cd6',
55
- tokenBoolean: '#569cd6',
56
- tokenEntity: '#569cd6',
57
- tokenInterpolationPunctuation: '#569cd6',
58
- tokenFunction: '#dcdcaa',
59
- tokenClassName: '#4ec9b0',
60
- tokenSymbol: '#4ec9b0',
61
- tokenBuiltin: '#c586c0',
62
- tokenKeyword: '#c586c0',
63
- tokenAtRule: '#c586c0',
64
- tokenSelector: '#d7ba7d',
65
- tokenImportant: '#d16969',
66
- tokenRegex: '#d16969',
67
- tokenString: '#ce9178',
68
- tokenChar: '#ce9178',
69
- tokenAttributeValue: '#ce9178'
41
+ background: '#202122',
42
+ language: '#90989d',
43
+ lineNumbers: '#9ea5a9',
44
+ lineNumbersBackground: '#6e747733', // galena 20%
45
+ tokenDefault: '#cdd5dc',
46
+ tokenComment: '#81898d',
47
+ tokenPunctuation: '#cdd5dc',
48
+ tokenNumber: '#cdd5dc',
49
+ tokenUrl: '#cdd5dc',
50
+ tokenOperator: '#cdd5dc',
51
+ tokenInterpolation: '#92d1ff',
52
+ tokenAttributeName: '#92d1ff',
53
+ tokenConstant: '#00d2ed',
54
+ tokenProperty: '#92d1ff',
55
+ tokenTag: '#2899e9',
56
+ tokenBoolean: '#2896e4',
57
+ tokenEntity: '#29a6ff',
58
+ tokenInterpolationPunctuation: '#29a6ff',
59
+ tokenFunction: '#fff9d6',
60
+ tokenClassName: '#2ccfb0',
61
+ tokenSymbol: '#2de2c0',
62
+ tokenBuiltin: '#fd4e9d',
63
+ tokenKeyword: '#e94a92',
64
+ tokenAtRule: '#fd4e9d',
65
+ tokenSelector: '#fff9d6',
66
+ tokenImportant: '#ff575a',
67
+ tokenRegex: '#29A6FF',
68
+ tokenString: '#e9ba79',
69
+ tokenChar: '#e9ba79',
70
+ tokenAttributeValue: '#e9ba79'
70
71
  });
71
72
 
72
73
  const lightColors = Object.freeze({
73
- background: '#f2f1f1',
74
- language: '#1b1b1b',
75
- lineNumbers: '#1b1b1b',
76
- lineNumbersSeparator: '#1b1b1b',
77
- tokenDefault: '#1b1b1b',
78
- tokenComment: '#9e9e9e',
79
- tokenPunctuation: '#9e9e9e',
80
- tokenNumber: '#007936',
81
- tokenUrl: '#9e9e9e',
82
- tokenOperator: '#9e9e9e',
83
- tokenInterpolation: '#872bff',
84
- tokenAttributeName: '#d30038',
85
- tokenConstant: '#007936',
86
- tokenProperty: '#d30038',
87
- tokenTag: '#007936',
88
- tokenBoolean: '#007936',
89
- tokenEntity: 'inherit',
90
- tokenInterpolationPunctuation: '#872bff',
91
- tokenFunction: '#d30038',
92
- tokenClassName: '#d30038',
93
- tokenSymbol: '#007936',
94
- tokenBuiltin: '#872bff',
95
- tokenKeyword: '#0069c2',
96
- tokenAtRule: '#007936',
97
- tokenSelector: '#872bff',
98
- tokenImportant: 'inherit',
99
- tokenRegex: 'inherit',
100
- tokenString: '#007936',
101
- tokenChar: '#007936',
102
- tokenAttributeValue: '#007936'
74
+ background: '#f9fbff',
75
+ language: '#6e7477',
76
+ lineNumbers: '#6e7477',
77
+ lineNumbersBackground: '#f1f5fb',
78
+ tokenDefault: '#202122',
79
+ tokenComment: '#90989d',
80
+ tokenPunctuation: '#494c4e',
81
+ tokenNumber: '#494c4e',
82
+ tokenUrl: '#494c4e',
83
+ tokenOperator: '#006fbf',
84
+ tokenInterpolation: '#006fbf',
85
+ tokenAttributeName: '#006fbf',
86
+ tokenConstant: '#035670',
87
+ tokenProperty: '#008eab',
88
+ tokenTag: '#006fbf',
89
+ tokenBoolean: '#004489',
90
+ tokenEntity: '#004489',
91
+ tokenInterpolationPunctuation: '#004489',
92
+ tokenFunction: '#006fbf',
93
+ tokenClassName: '#00635e',
94
+ tokenSymbol: '#00635e',
95
+ tokenBuiltin: '#d40067',
96
+ tokenKeyword: '#d40067',
97
+ tokenAtRule: '#d40067',
98
+ tokenSelector: '#006fbf',
99
+ tokenImportant: '#cd2026',
100
+ tokenRegex: '#006fbf',
101
+ tokenString: '#c74c00',
102
+ tokenChar: '#c74c00',
103
+ tokenAttributeValue: '#c74c00',
104
+ tokenCombinator: '#202122'
103
105
  });
104
106
 
105
107
  export const getCodeColors = mode => {
106
108
  return mode === colorModes.DARK ? darkColors : lightColors;
107
109
  };
108
110
 
109
- const generateColorVariables = mode => {
110
- const colors = getCodeColors(mode);
111
+ const generateColorVariables = (mode, theme) => {
112
+ const colors = getCodeColors(mode, theme);
111
113
  const keySelector = mode === colorModes.DARK ? '.d2l-code-dark' : '.d2l-code';
112
114
  return `
113
115
  pre[class*="language-"]${keySelector},
@@ -115,7 +117,7 @@ const generateColorVariables = mode => {
115
117
  --d2l-code-background: ${colors.background};
116
118
  --d2l-code-language: ${colors.language};
117
119
  --d2l-code-line-numbers: ${colors.lineNumbers};
118
- --d2l-code-line-numbers-separator: ${colors.lineNumbersSeparator};
120
+ --d2l-code-line-numbers-background: ${colors.lineNumbersBackground};
119
121
  --d2l-code-token-atrule: ${colors.tokenAtRule};
120
122
  --d2l-code-token-attribute-name: ${colors.tokenAttributeName};
121
123
  --d2l-code-token-attribute-value: ${colors.tokenAttributeValue};
@@ -149,7 +151,6 @@ const generateColorVariables = mode => {
149
151
  export const codeStyles = css`
150
152
 
151
153
  ${unsafeCSS(generateColorVariables(colorModes.LIGHT))}
152
-
153
154
  ${unsafeCSS(generateColorVariables(colorModes.DARK))}
154
155
 
155
156
  pre[class*="language-"].d2l-code,
@@ -255,19 +256,21 @@ export const codeStyles = css`
255
256
  background-color: transparent;
256
257
  }
257
258
 
258
- pre[class*="language-"].line-numbers {
259
+ pre[class*="language-"].d2l-code.line-numbers {
259
260
  counter-reset: linenumber;
260
261
  padding-left: 3.8em;
261
262
  position: relative;
262
263
  }
263
264
 
264
- pre[class*="language-"].line-numbers > code {
265
+ pre[class*="language-"].d2l-code.line-numbers > code {
265
266
  position: relative;
266
267
  white-space: inherit;
267
268
  }
268
269
 
269
- .line-numbers .line-numbers-rows {
270
- border-right: 1px solid var(--d2l-code-line-numbers-separator);
270
+ .d2l-code.line-numbers > code > .line-numbers-rows {
271
+ background-color: var(--d2l-code-line-numbers-background);
272
+ border-bottom-right-radius: 6px;
273
+ border-top-right-radius: 6px;
271
274
  font-size: 100%;
272
275
  left: -3.8em;
273
276
  letter-spacing: -1px;
@@ -293,6 +296,35 @@ export const codeStyles = css`
293
296
  padding-right: 0.8em;
294
297
  text-align: right;
295
298
  }
299
+
300
+ span.inline-color-wrapper {
301
+ /*
302
+ * <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 2 2">
303
+ * <path fill="gray" d="M0 0h2v2H0z"/>
304
+ * <path fill="white" d="M0 0h1v1H0zM1 1h1v1H1z"/>
305
+ * </svg>
306
+ */
307
+ background: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyIDIiPjxwYXRoIGZpbGw9ImdyYXkiIGQ9Ik0wIDBoMnYySDB6Ii8+PHBhdGggZmlsbD0id2hpdGUiIGQ9Ik0wIDBoMXYxSDB6TTEgMWgxdjFIMXoiLz48L3N2Zz4=");
308
+ /* Prevent visual glitches where one pixel from the repeating pattern could be seen */
309
+ background-position: center;
310
+ background-size: 110%;
311
+ border: 1px solid white;
312
+ border-radius: 2px;
313
+ box-sizing: border-box;
314
+ display: inline-block;
315
+ height: 1.333ch;
316
+ margin: 0 0.333ch;
317
+ outline: 1px solid rgba(0, 0, 0, 0.5);
318
+ overflow: hidden;
319
+ width: 1.333ch;
320
+ }
321
+
322
+ span.inline-color {
323
+ display: block;
324
+ /* Prevent visual glitches again */
325
+ height: 120%;
326
+ width: 120%;
327
+ }
296
328
  `;
297
329
 
298
330
  const getLanguageInfo = elem => {
@@ -358,6 +390,18 @@ const loadPlugin = async plugin => {
358
390
  return pluginsLoaded[plugin];
359
391
  };
360
392
 
393
+ const languageAddons = {
394
+ css: [{ key: 'css-extras', type: 'lang' }, { key: 'inline-color', type: 'plugin' }]
395
+ };
396
+
397
+ const loadLanguageAddons = async key => {
398
+ if (!languageAddons[key]) return;
399
+ return Promise.all(languageAddons[key].map(addon => {
400
+ if (addon.type === 'lang') return loadLanguage(addon.key);
401
+ else return loadPlugin(addon.key);
402
+ }));
403
+ };
404
+
361
405
  let prismLoaded;
362
406
 
363
407
  const loadPrism = () => {
@@ -400,6 +444,7 @@ export async function formatCodeElement(elem) {
400
444
  await loadPrism(); // must be loaded before loading plugins or languages
401
445
  await Promise.all([
402
446
  loadLanguage(languageInfo.key),
447
+ loadLanguageAddons(languageInfo.key),
403
448
  lineNumbers ? loadPlugin('line-numbers') : null
404
449
  ]);
405
450
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.29.4",
3
+ "version": "2.29.5",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",