@salesforcedevs/dx-components 1.3.382 → 1.3.384-alpha
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/package-lock.json +7980 -0
- package/package.json +2 -3
- package/src/modules/dx/codeBlock/codeBlock.css +0 -10
- package/src/modules/dx/codeBlock/codeBlock.ts +20 -12
- package/src/modules/dx/featureFlag/featureFlag.ts +14 -2
- package/src/modules/dx/featuredContentHeader/featuredContentHeader.css +1 -1
- package/src/modules/dx/featuredContentHeader/featuredContentHeader.html +2 -2
- package/LICENSE +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.384-alpha",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -45,6 +45,5 @@
|
|
|
45
45
|
},
|
|
46
46
|
"volta": {
|
|
47
47
|
"node": "18.18.0"
|
|
48
|
-
}
|
|
49
|
-
"gitHead": "f0e4ba75f394f5f423187aee45026c53e41ede87"
|
|
48
|
+
}
|
|
50
49
|
}
|
|
@@ -31,11 +31,6 @@ pre {
|
|
|
31
31
|
background-color: var(--dx-g-gray-90);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
div.dx-theme-dark {
|
|
35
|
-
border: var(--dx-g-dark-mode-toggle-button-border);
|
|
36
|
-
border-radius: var(--dx-code-block-toolbar-border-radius, 0.3em);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
34
|
.dx-theme-dark .toolbar {
|
|
40
35
|
background-color: var(--dx-g-blue-natural-20);
|
|
41
36
|
}
|
|
@@ -45,7 +40,6 @@ div.dx-theme-dark {
|
|
|
45
40
|
border-left-width: 1px;
|
|
46
41
|
height: var(--dx-g-spacing-md);
|
|
47
42
|
margin-right: var(--dx-g-spacing-xs);
|
|
48
|
-
margin-top: 6px;
|
|
49
43
|
width: 0;
|
|
50
44
|
}
|
|
51
45
|
|
|
@@ -133,7 +127,3 @@ pre[class*="language-"].line-numbers {
|
|
|
133
127
|
display: none;
|
|
134
128
|
}
|
|
135
129
|
}
|
|
136
|
-
|
|
137
|
-
dx-button {
|
|
138
|
-
--dx-g-button-icon-color: var(--dx-g-cloud-blue-vibrant-50);
|
|
139
|
-
}
|
|
@@ -4,6 +4,13 @@ import cx from "classnames";
|
|
|
4
4
|
import { track as gtmTrack } from "dxUtils/analytics";
|
|
5
5
|
import prism from "dxUtils/prismjs";
|
|
6
6
|
import { ampscript, sqlDocsTemplate } from "./customLanguages";
|
|
7
|
+
import {
|
|
8
|
+
DARK_MODE_THEMES,
|
|
9
|
+
DARKMODE_TOGGLE_EVENT_NAME,
|
|
10
|
+
dispatchDarkModeToggleEvent,
|
|
11
|
+
getLocalStorageDarkModeSetting,
|
|
12
|
+
setLocalStorageDarkModeSetting
|
|
13
|
+
} from "dx/darkModeManager";
|
|
7
14
|
|
|
8
15
|
/*
|
|
9
16
|
Here we create custom syntax highlighting rules for proprietary languages
|
|
@@ -37,8 +44,6 @@ const preTagRegexp: RegExp = /^<pre.*?>(.*)<\/pre>$/is;
|
|
|
37
44
|
|
|
38
45
|
export const LIGHT = "light";
|
|
39
46
|
export const DARK = "dark";
|
|
40
|
-
export const EVENT_NAME = "dx-codeblock-theme";
|
|
41
|
-
const THEMES = [LIGHT, DARK];
|
|
42
47
|
|
|
43
48
|
export default class CodeBlock extends LightningElement {
|
|
44
49
|
@api defaultTheme: CodeBlockTheme = LIGHT;
|
|
@@ -94,18 +99,18 @@ export default class CodeBlock extends LightningElement {
|
|
|
94
99
|
];
|
|
95
100
|
|
|
96
101
|
private initializeDarkMode() {
|
|
97
|
-
window.addEventListener(
|
|
98
|
-
const darkModeSetting =
|
|
99
|
-
|
|
100
|
-
)
|
|
101
|
-
if (THEMES.includes(darkModeSetting)) {
|
|
102
|
+
window.addEventListener(DARKMODE_TOGGLE_EVENT_NAME, this.toggleTheme);
|
|
103
|
+
const darkModeSetting =
|
|
104
|
+
getLocalStorageDarkModeSetting() as CodeBlockTheme;
|
|
105
|
+
if (DARK_MODE_THEMES.includes(darkModeSetting)) {
|
|
102
106
|
this.theme = darkModeSetting;
|
|
103
|
-
} else {
|
|
104
|
-
this.theme = this.defaultTheme;
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
|
|
108
110
|
connectedCallback() {
|
|
111
|
+
if (!this.theme) {
|
|
112
|
+
this.theme = this.defaultTheme;
|
|
113
|
+
}
|
|
109
114
|
this.initializeDarkMode();
|
|
110
115
|
}
|
|
111
116
|
|
|
@@ -273,12 +278,12 @@ export default class CodeBlock extends LightningElement {
|
|
|
273
278
|
element_title: this.updateThemeBtnText,
|
|
274
279
|
content_category: "code block"
|
|
275
280
|
});
|
|
276
|
-
|
|
281
|
+
dispatchDarkModeToggleEvent();
|
|
277
282
|
}
|
|
278
283
|
|
|
279
284
|
private toggleTheme = () => {
|
|
280
285
|
this.theme = this.theme === DARK ? LIGHT : DARK;
|
|
281
|
-
|
|
286
|
+
setLocalStorageDarkModeSetting(this.theme);
|
|
282
287
|
};
|
|
283
288
|
|
|
284
289
|
renderedCallback() {
|
|
@@ -296,6 +301,9 @@ export default class CodeBlock extends LightningElement {
|
|
|
296
301
|
}
|
|
297
302
|
|
|
298
303
|
disconnectedCallback(): void {
|
|
299
|
-
window.removeEventListener(
|
|
304
|
+
window.removeEventListener(
|
|
305
|
+
DARKMODE_TOGGLE_EVENT_NAME,
|
|
306
|
+
this.toggleTheme
|
|
307
|
+
);
|
|
300
308
|
}
|
|
301
309
|
}
|
|
@@ -3,7 +3,8 @@ import optimizelySdk from "@optimizely/optimizely-sdk";
|
|
|
3
3
|
|
|
4
4
|
// This is needed to specify user context (such as logged in, admin, ...etc).
|
|
5
5
|
// leave this as hard-coded for now until we create audiences in Optimizely.
|
|
6
|
-
const userId = "
|
|
6
|
+
const userId = "salesforce-sf";
|
|
7
|
+
const LOCAL_ENVIRONMENT_SDK_KEY = "Nnshyv1nTg7DWexu5rEeT";
|
|
7
8
|
|
|
8
9
|
export default class FeatureFlag extends LightningElement {
|
|
9
10
|
@api flag!: string;
|
|
@@ -15,8 +16,19 @@ export default class FeatureFlag extends LightningElement {
|
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
connectedCallback(): void {
|
|
19
|
+
const sdkKey = process.env.OPTIMIZELY_SDK_KEY;
|
|
20
|
+
const datafileAccessToken =
|
|
21
|
+
process.env.OPTIMIZELY_DATAFILE_ACCESS_TOKEN;
|
|
22
|
+
const datafileOptions =
|
|
23
|
+
sdkKey && datafileAccessToken
|
|
24
|
+
? {
|
|
25
|
+
urlTemplate: `https://config.optimizely.com/datafiles/auth/${sdkKey}.json`,
|
|
26
|
+
datafileAccessToken: datafileAccessToken
|
|
27
|
+
}
|
|
28
|
+
: undefined;
|
|
18
29
|
this.optimizelyInstance = optimizelySdk.createInstance({
|
|
19
|
-
sdkKey: process.env.OPTIMIZELY_SDK_KEY
|
|
30
|
+
sdkKey: process.env.OPTIMIZELY_SDK_KEY || LOCAL_ENVIRONMENT_SDK_KEY,
|
|
31
|
+
datafileOptions
|
|
20
32
|
});
|
|
21
33
|
}
|
|
22
34
|
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
<div>
|
|
14
14
|
<slot name="language-selector"></slot>
|
|
15
15
|
</div>
|
|
16
|
-
<
|
|
16
|
+
<dx-feature-flag flag="dark-mode">
|
|
17
17
|
<div
|
|
18
18
|
class="dark-mode-button"
|
|
19
19
|
onclick={onDarkModeButtonClick}
|
|
20
20
|
>
|
|
21
21
|
<div class="dark-mode-icon"></div>
|
|
22
22
|
</div>
|
|
23
|
-
</
|
|
23
|
+
</dx-feature-flag>
|
|
24
24
|
</div>
|
|
25
25
|
</div>
|
|
26
26
|
<div class="container-layout">
|
package/LICENSE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
-
|
|
6
|
-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
-
|
|
8
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
-
|
|
10
|
-
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
-
|
|
12
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|