@brightspace-ui/core 2.26.3 → 2.28.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.
- package/components/alert/README.md +0 -4
- package/components/breadcrumbs/README.md +0 -12
- package/components/button/README.md +0 -12
- package/components/button/floating-buttons.md +0 -4
- package/components/calendar/README.md +0 -4
- package/components/card/README.md +0 -4
- package/components/colors/README.md +0 -12
- package/components/count-badge/README.md +0 -9
- package/components/dialog/README.md +0 -12
- package/components/dropdown/README.md +0 -29
- package/components/expand-collapse/README.md +0 -8
- package/components/filter/README.md +0 -15
- package/components/form/docs/form-element-nesting.md +0 -4
- package/components/form/docs/form.md +0 -4
- package/components/html-block/demo/html-block-code.html +47 -0
- package/components/html-block/html-block.js +4 -2
- package/components/inputs/README.md +0 -4
- package/components/inputs/docs/input-checkbox.md +0 -8
- package/components/inputs/docs/input-date-time.md +0 -24
- package/components/inputs/docs/input-numeric.md +0 -8
- package/components/inputs/docs/input-radio.md +0 -4
- package/components/inputs/docs/input-search.md +0 -4
- package/components/inputs/docs/input-select-styles.md +0 -4
- package/components/inputs/docs/input-text.md +0 -12
- package/components/link/README.md +0 -6
- package/components/list/README.md +0 -24
- package/components/loading-spinner/README.md +0 -3
- package/components/menu/README.md +0 -20
- package/components/meter/README.md +0 -19
- package/components/overflow-group/README.md +0 -4
- package/components/scroll-wrapper/README.md +0 -4
- package/components/selection/README.md +0 -6
- package/components/skeleton/README.md +1 -11
- package/components/status-indicator/README.md +0 -4
- package/components/switch/README.md +0 -7
- package/components/table/README.md +0 -16
- package/components/tabs/README.md +0 -8
- package/components/tooltip/README.md +0 -8
- package/components/typography/README.md +0 -10
- package/components/typography/demo/typography.html +6 -0
- package/components/typography/styles.js +38 -0
- package/components/typography/typography.js +39 -0
- package/directives/animate/README.md +1 -5
- package/helpers/demo/prism.html +417 -0
- package/helpers/prism.js +430 -0
- package/package.json +1 -2
- package/templates/primary-secondary/README.md +0 -4
- package/components/alert/screenshots/alert.png +0 -0
- package/components/breadcrumbs/screenshots/basic.png +0 -0
- package/components/breadcrumbs/screenshots/compact.png +0 -0
- package/components/breadcrumbs/screenshots/limited-width.png +0 -0
- package/components/button/screenshots/button-icon.png +0 -0
- package/components/button/screenshots/button-subtle.png +0 -0
- package/components/button/screenshots/button.png +0 -0
- package/components/button/screenshots/floating-buttons.png +0 -0
- package/components/calendar/screenshots/calendar.png +0 -0
- package/components/card/screenshots/card.png +0 -0
- package/components/colors/screenshots/basic-greys.png +0 -0
- package/components/colors/screenshots/feedback.png +0 -0
- package/components/colors/screenshots/primary-accents.png +0 -0
- package/components/count-badge/screenshots/count-badge-count-large.png +0 -0
- package/components/count-badge/screenshots/count-badge-icon.png +0 -0
- package/components/count-badge/screenshots/count-badge-notification-small.png +0 -0
- package/components/dialog/screenshots/dialog-confirm.png +0 -0
- package/components/dialog/screenshots/dialog-fullscreen.png +0 -0
- package/components/dialog/screenshots/dialog.png +0 -0
- package/components/dropdown/screenshots/dropdown-button-subtle.png +0 -0
- package/components/dropdown/screenshots/dropdown-button.png +0 -0
- package/components/dropdown/screenshots/dropdown-content-mobile-tray.png +0 -0
- package/components/dropdown/screenshots/dropdown-content.png +0 -0
- package/components/dropdown/screenshots/dropdown-context-menu.png +0 -0
- package/components/dropdown/screenshots/dropdown-menu.png +0 -0
- package/components/dropdown/screenshots/dropdown-more.png +0 -0
- package/components/dropdown/screenshots/dropdown-tabs.png +0 -0
- package/components/expand-collapse/screenshots/expand-collapse-content.gif +0 -0
- package/components/expand-collapse/screenshots/more-less.png +0 -0
- package/components/filter/screenshots/filter-mobile.png +0 -0
- package/components/filter/screenshots/filter-multi-dim.png +0 -0
- package/components/filter/screenshots/filter.png +0 -0
- package/components/form/screenshots/form-native.gif +0 -0
- package/components/form/screenshots/nesting-invalid-styling.png +0 -0
- package/components/form/screenshots/nesting-tooltip-conflict.png +0 -0
- package/components/inputs/screenshots/checkbox.gif +0 -0
- package/components/inputs/screenshots/date-range.gif +0 -0
- package/components/inputs/screenshots/date-time-range.gif +0 -0
- package/components/inputs/screenshots/date-time.gif +0 -0
- package/components/inputs/screenshots/date.gif +0 -0
- package/components/inputs/screenshots/label-required.png +0 -0
- package/components/inputs/screenshots/label.png +0 -0
- package/components/inputs/screenshots/number.png +0 -0
- package/components/inputs/screenshots/percent.png +0 -0
- package/components/inputs/screenshots/radio.gif +0 -0
- package/components/inputs/screenshots/search.gif +0 -0
- package/components/inputs/screenshots/select.gif +0 -0
- package/components/inputs/screenshots/text.gif +0 -0
- package/components/inputs/screenshots/textarea-styles.gif +0 -0
- package/components/inputs/screenshots/textarea.gif +0 -0
- package/components/inputs/screenshots/time-range.gif +0 -0
- package/components/inputs/screenshots/time.gif +0 -0
- package/components/link/screenshots/main.png +0 -0
- package/components/link/screenshots/small.png +0 -0
- package/components/link/screenshots/standard.png +0 -0
- package/components/list/screenshots/drag-and-drop.gif +0 -0
- package/components/list/screenshots/list-item-content.png +0 -0
- package/components/list/screenshots/list-item.png +0 -0
- package/components/list/screenshots/list-selection.png +0 -0
- package/components/list/screenshots/list.png +0 -0
- package/components/loading-spinner/screenshots/loading-spinner.gif +0 -0
- package/components/menu/screenshots/checkbox-menu.png +0 -0
- package/components/menu/screenshots/menu-items.png +0 -0
- package/components/menu/screenshots/menu.png +0 -0
- package/components/menu/screenshots/nested-menu.png +0 -0
- package/components/menu/screenshots/radio-menu.png +0 -0
- package/components/meter/screenshots/d2l-meter-circle-completed.png +0 -0
- package/components/meter/screenshots/d2l-meter-circle-has-progress.png +0 -0
- package/components/meter/screenshots/d2l-meter-circle-no-progress.png +0 -0
- package/components/meter/screenshots/d2l-meter-linear-completed.png +0 -0
- package/components/meter/screenshots/d2l-meter-linear-has-progress.png +0 -0
- package/components/meter/screenshots/d2l-meter-linear-no-progress.png +0 -0
- package/components/meter/screenshots/d2l-meter-radial-completed.png +0 -0
- package/components/meter/screenshots/d2l-meter-radial-has-progress.png +0 -0
- package/components/meter/screenshots/d2l-meter-radial-no-progress.png +0 -0
- package/components/meter/screenshots/d2l-meter-radial-with-text.png +0 -0
- package/components/overflow-group/screenshots/overflow-group.png +0 -0
- package/components/scroll-wrapper/screenshots/scroll-wrapper.gif +0 -0
- package/components/selection/screenshots/selection-multiple.png +0 -0
- package/components/selection/screenshots/selection-single.png +0 -0
- package/components/skeleton/screenshots/container.png +0 -0
- package/components/skeleton/screenshots/overview.png +0 -0
- package/components/skeleton/screenshots/paragraph.png +0 -0
- package/components/skeleton/screenshots/text-input.png +0 -0
- package/components/status-indicator/screenshots/bold-indicators.png +0 -0
- package/components/status-indicator/screenshots/default-indicator.png +0 -0
- package/components/status-indicator/screenshots/subtle-indicators.png +0 -0
- package/components/switch/screenshots/switch-visibility.png +0 -0
- package/components/switch/screenshots/switch.png +0 -0
- package/components/table/screenshots/default.png +0 -0
- package/components/table/screenshots/light.png +0 -0
- package/components/table/screenshots/selection.gif +0 -0
- package/components/table/screenshots/sorting.gif +0 -0
- package/components/table/screenshots/sticky.gif +0 -0
- package/components/tabs/screenshots/tabs.png +0 -0
- package/components/tooltip/screenshots/tooltip-boundary.png +0 -0
- package/components/tooltip/screenshots/tooltip-error.png +0 -0
- package/components/typography/screenshots/body-compact.png +0 -0
- package/components/typography/screenshots/body-small.png +0 -0
- package/components/typography/screenshots/body-standard.png +0 -0
- package/components/typography/screenshots/headings.png +0 -0
- package/components/typography/screenshots/labels.png +0 -0
- package/directives/animate/screenshots/focus.gif +0 -0
- package/directives/animate/screenshots/show-hide.gif +0 -0
- package/templates/primary-secondary/screenshots/primary-secondary.gif +0 -0
package/helpers/prism.js
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import { css, unsafeCSS } from 'lit-element/lit-element.js';
|
|
2
|
+
|
|
3
|
+
window.Prism = window.Prism || {};
|
|
4
|
+
Prism.manual = true;
|
|
5
|
+
|
|
6
|
+
const prismLocation = 'https://s.brightspace.com/lib/prismjs/1.28.0';
|
|
7
|
+
//const prismLocation = '/node_modules/prismjs'; // for local debugging
|
|
8
|
+
|
|
9
|
+
// If adding a language, check its Prism dependencies and modify languageDependencies below if necessary
|
|
10
|
+
export const codeLanguages = new Map();
|
|
11
|
+
codeLanguages.set('arduino', 'Arduino');
|
|
12
|
+
codeLanguages.set('armasm', 'ARM Assembly');
|
|
13
|
+
codeLanguages.set('bash', 'Bash');
|
|
14
|
+
codeLanguages.set('c', 'C');
|
|
15
|
+
codeLanguages.set('clike', 'C-like');
|
|
16
|
+
codeLanguages.set('cpp', 'C++');
|
|
17
|
+
codeLanguages.set('csharp', 'C#');
|
|
18
|
+
codeLanguages.set('css', 'CSS');
|
|
19
|
+
codeLanguages.set('haskell', 'Haskell');
|
|
20
|
+
codeLanguages.set('java', 'Java');
|
|
21
|
+
codeLanguages.set('javascript', 'JavaScript');
|
|
22
|
+
codeLanguages.set('json', 'JSON');
|
|
23
|
+
codeLanguages.set('kotlin', 'Kotlin');
|
|
24
|
+
codeLanguages.set('latex', 'LaTeX');
|
|
25
|
+
codeLanguages.set('markup', 'Markup');
|
|
26
|
+
codeLanguages.set('matlab', 'MATLAB');
|
|
27
|
+
codeLanguages.set('plain', 'Plain Text');
|
|
28
|
+
codeLanguages.set('python', 'Python');
|
|
29
|
+
codeLanguages.set('r', 'R');
|
|
30
|
+
codeLanguages.set('racket', 'Racket');
|
|
31
|
+
codeLanguages.set('sql', 'SQL');
|
|
32
|
+
codeLanguages.set('wolfram', 'Wolfram');
|
|
33
|
+
|
|
34
|
+
export const colorModes = {
|
|
35
|
+
LIGHT: 'light',
|
|
36
|
+
DARK: 'dark'
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
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'
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
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'
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
export const getCodeColors = mode => {
|
|
106
|
+
return mode === colorModes.DARK ? darkColors : lightColors;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const generateColorVariables = mode => {
|
|
110
|
+
const colors = getCodeColors(mode);
|
|
111
|
+
const keySelector = mode === colorModes.DARK ? '.d2l-code-dark' : '.d2l-code';
|
|
112
|
+
return `
|
|
113
|
+
pre[class*="language-"]${keySelector},
|
|
114
|
+
code[class*="language-"]${keySelector} {
|
|
115
|
+
--d2l-code-background: ${colors.background};
|
|
116
|
+
--d2l-code-language: ${colors.language};
|
|
117
|
+
--d2l-code-line-numbers: ${colors.lineNumbers};
|
|
118
|
+
--d2l-code-line-numbers-separator: ${colors.lineNumbersSeparator};
|
|
119
|
+
--d2l-code-token-atrule: ${colors.tokenAtRule};
|
|
120
|
+
--d2l-code-token-attribute-name: ${colors.tokenAttributeName};
|
|
121
|
+
--d2l-code-token-attribute-value: ${colors.tokenAttributeValue};
|
|
122
|
+
--d2l-code-token-boolean: ${colors.tokenBoolean};
|
|
123
|
+
--d2l-code-token-builtin: ${colors.tokenBuiltin};
|
|
124
|
+
--d2l-code-token-char: ${colors.tokenChar};
|
|
125
|
+
--d2l-code-token-class-name: ${colors.tokenClassName};
|
|
126
|
+
--d2l-code-token-comment: ${colors.tokenComment};
|
|
127
|
+
--d2l-code-token-constant: ${colors.tokenConstant};
|
|
128
|
+
--d2l-code-token-default: ${colors.tokenDefault};
|
|
129
|
+
--d2l-code-token-entity: ${colors.tokenEntity};
|
|
130
|
+
--d2l-code-token-function: ${colors.tokenFunction};
|
|
131
|
+
--d2l-code-token-important: ${colors.tokenImportant};
|
|
132
|
+
--d2l-code-token-interpolation: ${colors.tokenInterpolation};
|
|
133
|
+
--d2l-code-token-interpolation-punctuation: ${colors.tokenInterpolationPunctuation};
|
|
134
|
+
--d2l-code-token-keyword: ${colors.tokenKeyword};
|
|
135
|
+
--d2l-code-token-number: ${colors.tokenNumber};
|
|
136
|
+
--d2l-code-token-operator: ${colors.tokenOperator};
|
|
137
|
+
--d2l-code-token-property: ${colors.tokenProperty};
|
|
138
|
+
--d2l-code-token-punctuation: ${colors.tokenPunctuation};
|
|
139
|
+
--d2l-code-token-regex: ${colors.tokenRegex};
|
|
140
|
+
--d2l-code-token-selector: ${colors.tokenSelector};
|
|
141
|
+
--d2l-code-token-string: ${colors.tokenString};
|
|
142
|
+
--d2l-code-token-symbol: ${colors.tokenSymbol};
|
|
143
|
+
--d2l-code-token-tag: ${colors.tokenTag};
|
|
144
|
+
--d2l-code-token-url: ${colors.tokenUrl};
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const codeStyles = css`
|
|
150
|
+
|
|
151
|
+
${unsafeCSS(generateColorVariables(colorModes.LIGHT))}
|
|
152
|
+
|
|
153
|
+
${unsafeCSS(generateColorVariables(colorModes.DARK))}
|
|
154
|
+
|
|
155
|
+
pre[class*="language-"].d2l-code,
|
|
156
|
+
pre[class*="language-"].d2l-code > code[class*="language-"],
|
|
157
|
+
code[class*="language-"].d2l-code {
|
|
158
|
+
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
159
|
+
line-height: 1.5;
|
|
160
|
+
text-shadow: none;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
pre[class*="language-"].d2l-code > code[class*="language-"],
|
|
164
|
+
code[class*="language-"].d2l-code {
|
|
165
|
+
color: var(--d2l-code-token-default);
|
|
166
|
+
-webkit-hyphens: none;
|
|
167
|
+
-moz-hyphens: none;
|
|
168
|
+
-ms-hyphens: none;
|
|
169
|
+
hyphens: none;
|
|
170
|
+
white-space: pre;
|
|
171
|
+
word-break: normal;
|
|
172
|
+
word-spacing: normal;
|
|
173
|
+
word-wrap: normal;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
pre[class*="language-"].d2l-code {
|
|
177
|
+
background-color: var(--d2l-code-background);
|
|
178
|
+
border-radius: 6px;
|
|
179
|
+
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
|
|
180
|
+
font-size: 14px;
|
|
181
|
+
margin: 0.5em 0;
|
|
182
|
+
overflow: auto;
|
|
183
|
+
padding: 1em;
|
|
184
|
+
position: relative;
|
|
185
|
+
-moz-tab-size: 4;
|
|
186
|
+
-o-tab-size: 4;
|
|
187
|
+
tab-size: 4;
|
|
188
|
+
text-align: left;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
pre[class*="language-"].d2l-code::before {
|
|
192
|
+
color: var(--d2l-code-language);
|
|
193
|
+
content: attr(data-language);
|
|
194
|
+
font-family: 'Lato', 'Lucida Sans Unicode', 'Lucida Grande', sans-serif;
|
|
195
|
+
margin: 0.1rem 0.4rem;
|
|
196
|
+
position: absolute;
|
|
197
|
+
right: 0;
|
|
198
|
+
top: 0;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
code[class*="language-"].d2l-code {
|
|
202
|
+
background-color: var(--d2l-code-background);
|
|
203
|
+
border-radius: 6px;
|
|
204
|
+
padding: 0.1em;
|
|
205
|
+
white-space: normal;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.token.comment,
|
|
209
|
+
.token.block-comment,
|
|
210
|
+
.token.prolog,
|
|
211
|
+
.token.doctype,
|
|
212
|
+
.token.cdata {
|
|
213
|
+
color: var(--d2l-code-token-comment);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.token.punctuation { color: var(--d2l-code-token-punctuation); }
|
|
217
|
+
.token.number { color: var(--d2l-code-token-number); }
|
|
218
|
+
.token.operator { color: var(--d2l-code-token-operator); }
|
|
219
|
+
|
|
220
|
+
.token.interpolation { color: var(--d2l-code-token-interpolation); }
|
|
221
|
+
.token.attr-name { color: var(--d2l-code-token-attribute-name); }
|
|
222
|
+
.token.constant { color: var(--d2l-code-token-constant); }
|
|
223
|
+
.token.property { color: var(--d2l-code-token-property); }
|
|
224
|
+
|
|
225
|
+
.token.tag { color: var(--d2l-code-token-tag); }
|
|
226
|
+
.token.boolean { color: var(--d2l-code-token-boolean); }
|
|
227
|
+
.token.entity { color: var(--d2l-code-token-entity); }
|
|
228
|
+
.token.interpolation-punctuation { color: var(--d2l-code-token-interpolation-punctuation); }
|
|
229
|
+
|
|
230
|
+
.token.function { color: var(--d2l-code-token-function); }
|
|
231
|
+
|
|
232
|
+
.token.class-name { color: var(--d2l-code-token-class-name); }
|
|
233
|
+
.token.symbol { color: var(--d2l-code-token-symbol); }
|
|
234
|
+
|
|
235
|
+
.token.builtin { color: var(--d2l-code-token-builtin); }
|
|
236
|
+
.token.keyword { color: var(--d2l-code-token-keyword); }
|
|
237
|
+
.token.atrule { color: var(--d2l-code-token-atrule); }
|
|
238
|
+
|
|
239
|
+
.token.selector { color: var(--d2l-code-token-selector); }
|
|
240
|
+
|
|
241
|
+
.token.important { color: var(--d2l-code-token-important); }
|
|
242
|
+
.token.regex { color: var(--d2l-code-token-regex); }
|
|
243
|
+
|
|
244
|
+
.token.string { color: var(--d2l-code-token-string); }
|
|
245
|
+
.token.char { color: var(--d2l-code-token-char); }
|
|
246
|
+
.token.attr-value { color: var(--d2l-code-token-attribute-value); }
|
|
247
|
+
|
|
248
|
+
.token.url { color: var(--d2l-code-token-url); }
|
|
249
|
+
|
|
250
|
+
.language-css .token.string,
|
|
251
|
+
.style .token.string,
|
|
252
|
+
.token.entity,
|
|
253
|
+
.token.operator,
|
|
254
|
+
.token.url {
|
|
255
|
+
background-color: transparent;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
pre[class*="language-"].line-numbers {
|
|
259
|
+
counter-reset: linenumber;
|
|
260
|
+
padding-left: 3.8em;
|
|
261
|
+
position: relative;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
pre[class*="language-"].line-numbers > code {
|
|
265
|
+
position: relative;
|
|
266
|
+
white-space: inherit;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.line-numbers .line-numbers-rows {
|
|
270
|
+
border-right: 1px solid var(--d2l-code-line-numbers-separator);
|
|
271
|
+
font-size: 100%;
|
|
272
|
+
left: -3.8em;
|
|
273
|
+
letter-spacing: -1px;
|
|
274
|
+
pointer-events: none;
|
|
275
|
+
position: absolute;
|
|
276
|
+
top: 0;
|
|
277
|
+
-webkit-user-select: none;
|
|
278
|
+
-moz-user-select: none;
|
|
279
|
+
-ms-user-select: none;
|
|
280
|
+
user-select: none;
|
|
281
|
+
width: 3em; /* works for line-numbers below 1000 lines */
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.line-numbers-rows > span {
|
|
285
|
+
counter-increment: linenumber;
|
|
286
|
+
display: block;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.line-numbers-rows > span::before {
|
|
290
|
+
color: var(--d2l-code-line-numbers);
|
|
291
|
+
content: counter(linenumber);
|
|
292
|
+
display: block;
|
|
293
|
+
padding-right: 0.8em;
|
|
294
|
+
text-align: right;
|
|
295
|
+
}
|
|
296
|
+
`;
|
|
297
|
+
|
|
298
|
+
const getLanguageInfo = elem => {
|
|
299
|
+
const classes = elem.classList;
|
|
300
|
+
for (let i = 0; i < classes.length; i++) {
|
|
301
|
+
if (classes[i].startsWith('language-')) {
|
|
302
|
+
const key = classes[i].substring(9);
|
|
303
|
+
const desc = codeLanguages.get(key);
|
|
304
|
+
if (desc) return { key: key, desc: desc };
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
return { key: 'plain', desc: codeLanguages.get('plain') };
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const languageDependencies = {
|
|
311
|
+
arduino: [ 'cpp' ],
|
|
312
|
+
cpp: [ 'c' ],
|
|
313
|
+
racket: [ 'scheme' ]
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const languagesLoaded = {
|
|
317
|
+
clike: Promise.resolve(),
|
|
318
|
+
css: Promise.resolve(),
|
|
319
|
+
javascript: Promise.resolve(),
|
|
320
|
+
markup: Promise.resolve(),
|
|
321
|
+
plain: Promise.resolve()
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
const loadLanguage = async key => {
|
|
325
|
+
if (languagesLoaded[key]) return languagesLoaded[key];
|
|
326
|
+
|
|
327
|
+
// Prism languages can extend other anguages and must be loaded in order
|
|
328
|
+
|
|
329
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
330
|
+
languagesLoaded[key] = new Promise(async resolve => {
|
|
331
|
+
if (languageDependencies[key]) {
|
|
332
|
+
await Promise.all(languageDependencies[key].map(dependencyKey => loadLanguage(dependencyKey)));
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const script = document.createElement('script');
|
|
336
|
+
script.async = 'async';
|
|
337
|
+
script.onload = resolve;
|
|
338
|
+
script.src = `${prismLocation}/components/prism-${key}.min.js`;
|
|
339
|
+
document.head.appendChild(script);
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
return languagesLoaded[key];
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
const pluginsLoaded = {};
|
|
346
|
+
|
|
347
|
+
const loadPlugin = async plugin => {
|
|
348
|
+
if (pluginsLoaded[plugin]) return pluginsLoaded[plugin];
|
|
349
|
+
|
|
350
|
+
pluginsLoaded[plugin] = new Promise(resolve => {
|
|
351
|
+
const script = document.createElement('script');
|
|
352
|
+
script.async = 'async';
|
|
353
|
+
script.onload = resolve;
|
|
354
|
+
script.src = `${prismLocation}/plugins/${plugin}/prism-${plugin}.min.js`;
|
|
355
|
+
document.head.appendChild(script);
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
return pluginsLoaded[plugin];
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
let prismLoaded;
|
|
362
|
+
|
|
363
|
+
const loadPrism = () => {
|
|
364
|
+
if (prismLoaded) return prismLoaded;
|
|
365
|
+
|
|
366
|
+
prismLoaded = Promise.all([
|
|
367
|
+
new Promise(resolve => {
|
|
368
|
+
const script = document.createElement('script');
|
|
369
|
+
script.async = 'async';
|
|
370
|
+
script.onload = resolve;
|
|
371
|
+
script.src = `${prismLocation}/prism.js`;
|
|
372
|
+
document.head.appendChild(script);
|
|
373
|
+
}),
|
|
374
|
+
new Promise(resolve => {
|
|
375
|
+
const style = document.createElement('style');
|
|
376
|
+
style.textContent = codeStyles.cssText;
|
|
377
|
+
style.onload = resolve;
|
|
378
|
+
document.head.appendChild(style);
|
|
379
|
+
})
|
|
380
|
+
]);
|
|
381
|
+
|
|
382
|
+
return prismLoaded;
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
const getCodeElement = elem => {
|
|
386
|
+
if (!elem) return;
|
|
387
|
+
if (elem.tagName === 'CODE') return elem;
|
|
388
|
+
if (elem.tagName !== 'PRE') return;
|
|
389
|
+
return elem.querySelector('code');
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
export async function formatCodeElement(elem) {
|
|
393
|
+
const code = getCodeElement(elem);
|
|
394
|
+
|
|
395
|
+
if (code.className.indexOf('language-') === -1) return;
|
|
396
|
+
|
|
397
|
+
const languageInfo = getLanguageInfo(code);
|
|
398
|
+
const lineNumbers = elem.classList.contains('line-numbers') || code.classList.contains('line-numbers');
|
|
399
|
+
|
|
400
|
+
await loadPrism(); // must be loaded before loading plugins or languages
|
|
401
|
+
await Promise.all([
|
|
402
|
+
loadLanguage(languageInfo.key),
|
|
403
|
+
lineNumbers ? loadPlugin('line-numbers') : null
|
|
404
|
+
]);
|
|
405
|
+
|
|
406
|
+
if (!elem.dataset.language && languageInfo.key !== 'plain') elem.dataset.language = languageInfo.desc;
|
|
407
|
+
Prism.highlightElement(code);
|
|
408
|
+
|
|
409
|
+
return elem;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
export class HtmlBlockCodeRenderer {
|
|
413
|
+
|
|
414
|
+
get canRenderInline() {
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
async render(elem) {
|
|
419
|
+
const codeElements = [...elem.querySelectorAll('.d2l-code')];
|
|
420
|
+
if (codeElements.length === 0) return elem;
|
|
421
|
+
|
|
422
|
+
// wait; formatting is not synchronous due to lazy loading of Prism, languages, plugins
|
|
423
|
+
await Promise.all(codeElements.map(codeElement => {
|
|
424
|
+
return formatCodeElement(codeElement);
|
|
425
|
+
}));
|
|
426
|
+
|
|
427
|
+
return elem;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.28.0",
|
|
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",
|
|
@@ -35,7 +35,6 @@
|
|
|
35
35
|
"/templates",
|
|
36
36
|
"/tools",
|
|
37
37
|
"!demo",
|
|
38
|
-
"!screenshots",
|
|
39
38
|
"!test",
|
|
40
39
|
"/components/demo",
|
|
41
40
|
"!/components/demo/demo"
|
|
@@ -16,10 +16,6 @@ If no nodes are assigned to the `footer` slot, the footer is hidden.
|
|
|
16
16
|
|
|
17
17
|
Note: this template automatically includes `<header>`, `<main>`, `<aside>` and `<footer>` elements, so there's no need to include them inside the various slots.
|
|
18
18
|
|
|
19
|
-
<!-- docs: start hidden content -->
|
|
20
|
-

|
|
21
|
-
<!-- docs: end hidden content -->
|
|
22
|
-
|
|
23
19
|
<!-- docs: demo live name:d2l-template-primary-secondary autoSize:false size:large -->
|
|
24
20
|
```html
|
|
25
21
|
<script type="module">
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|