@salesforcedevs/dx-components 1.3.66-alpha-032 → 1.3.70
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/LICENSE +12 -0
- package/lwc.config.json +0 -1
- package/package.json +3 -2
- package/src/modules/dx/codeBlock/codeBlock.ts +30 -10
- package/src/modules/dx/searchResults/coveo.css +1 -1
- package/src/modules/dx/searchResults/searchResults.css +0 -6
- package/src/modules/dx/searchResults/searchResults.ts +0 -13
- package/src/modules/dx/typeBadge/typeBadge.css +32 -1
- package/src/modules/dx/typeBadge/typeBadge.ts +75 -17
- package/src/modules/dxConstants/contentTypes/contentTypes.ts +0 -51
- package/src/modules/dxHelpers/typeBadge/typeBadge.css +0 -31
- package/src/modules/dxUtils/contentTypes/contentTypes.ts +0 -30
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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.
|
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.70",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -39,5 +39,6 @@
|
|
|
39
39
|
"@types/vimeo__player": "^2.16.2",
|
|
40
40
|
"eventsourcemock": "^2.0.0",
|
|
41
41
|
"luxon": "^3.1.0"
|
|
42
|
-
}
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "2a96eac5a76bea4ca124d6a3b0119e8312365f60"
|
|
43
44
|
}
|
|
@@ -108,23 +108,35 @@ export default class CodeBlock extends LightningElement {
|
|
|
108
108
|
formatCodeBlock() {
|
|
109
109
|
const divEl = this.template.querySelector("div.code-block-content");
|
|
110
110
|
const templateEl = document.createElement("template");
|
|
111
|
+
|
|
112
|
+
// Replace any <var> markup with a temporary nonsense sentinel (but one that is very
|
|
113
|
+
// unlikely to affect Prism's tokenization) so that Prism will not strip them but does
|
|
114
|
+
// still tokenize correctly. We want to italicize the "variables" ourselves after Prism
|
|
115
|
+
// does its own thing (W-11975205).
|
|
116
|
+
let cleanCodeBlock = this.codeBlock.replace(
|
|
117
|
+
/<var.*?>(.+?)<\/var>/g,
|
|
118
|
+
"vvvvv$1vvvvv"
|
|
119
|
+
);
|
|
120
|
+
|
|
111
121
|
if (
|
|
112
122
|
!this.isEncoded &&
|
|
113
123
|
this.markupLangs.includes(this.selectedLanguage.id || "")
|
|
114
124
|
) {
|
|
115
|
-
//
|
|
116
|
-
|
|
125
|
+
// Temporarily replace HTML comment characters, which Prism would also strip
|
|
126
|
+
cleanCodeBlock = `<!--${cleanCodeBlock.replace(
|
|
117
127
|
/<!--(.*?)-->/gs,
|
|
118
128
|
"@@$1##"
|
|
119
|
-
)}
|
|
129
|
+
)}-->`;
|
|
120
130
|
} else {
|
|
121
|
-
//
|
|
122
|
-
|
|
123
|
-
?
|
|
124
|
-
:
|
|
125
|
-
|
|
126
|
-
templateEl.innerHTML = `<pre class='codeblock'>${innerHtml}</pre>`;
|
|
131
|
+
// If this is a non-encoded markup language, encode angle brackets that Prism would strip
|
|
132
|
+
cleanCodeBlock = this.isEncoded
|
|
133
|
+
? cleanCodeBlock
|
|
134
|
+
: cleanCodeBlock.replace(/</g, "<").replace(/>/g, ">");
|
|
127
135
|
}
|
|
136
|
+
|
|
137
|
+
// eslint-disable-next-line
|
|
138
|
+
templateEl.innerHTML = `<pre class='codeblock'>${cleanCodeBlock}</pre>`;
|
|
139
|
+
|
|
128
140
|
const codeBlockEls = templateEl.content.querySelectorAll("pre");
|
|
129
141
|
codeBlockEls.forEach((codeBlockEl) => {
|
|
130
142
|
// eslint-disable-next-line
|
|
@@ -141,12 +153,19 @@ export default class CodeBlock extends LightningElement {
|
|
|
141
153
|
// for custom markup content, it is a workaround to be refactored later.
|
|
142
154
|
// eslint-disable-next-line
|
|
143
155
|
this.language !== "text"
|
|
144
|
-
?
|
|
156
|
+
? // eslint-disable-next-line
|
|
157
|
+
(codeEl.innerHTML = codeHTML)
|
|
145
158
|
: (codeEl.textContent = this._codeBlock.trim());
|
|
146
159
|
// eslint-disable-next-line
|
|
147
160
|
codeBlockEl.innerHTML = "";
|
|
148
161
|
codeBlockEl.appendChild(codeEl);
|
|
149
162
|
Prism.highlightAllUnder(codeBlockEl);
|
|
163
|
+
// Italicize anything marked as a "variable" by the docs team
|
|
164
|
+
// eslint-disable-next-line
|
|
165
|
+
codeBlockEl.innerHTML = codeBlockEl.innerHTML.replace(
|
|
166
|
+
/vvvvv(.+?)vvvvv/g,
|
|
167
|
+
"<span class='token italic'>$1</span>"
|
|
168
|
+
);
|
|
150
169
|
});
|
|
151
170
|
|
|
152
171
|
if (divEl) {
|
|
@@ -156,6 +175,7 @@ export default class CodeBlock extends LightningElement {
|
|
|
156
175
|
if (this.markupLangs.includes(this.selectedLanguage.id || "")) {
|
|
157
176
|
const res = this.template.querySelector(`code.language-markup`);
|
|
158
177
|
if (res) {
|
|
178
|
+
// Restore any temporarily replaced HTML comment characters
|
|
159
179
|
// eslint-disable-next-line
|
|
160
180
|
res.innerHTML = res.innerHTML.replace(
|
|
161
181
|
/@@(.*?)##/gs,
|
|
@@ -8057,7 +8057,7 @@ select.coveo-dropdown::-ms-expand {
|
|
|
8057
8057
|
|
|
8058
8058
|
@font-face {
|
|
8059
8059
|
font-family: 'Lato';
|
|
8060
|
-
src: url('https://static.cloud.coveo.com/searchui/v2.
|
|
8060
|
+
src: url('https://static.cloud.coveo.com/searchui/v2.10105/0/fonts/lato.woff2'), url('https://staticdev.cloud.coveo.com/searchui/v2.10105/0/fonts/lato.woff2'), url('../fonts/lato.woff2'), url('https://static.cloud.coveo.com/searchui/v2.10105/0/fonts/lato.woff'), url('https://staticdev.cloud.coveo.com/searchui/v2.10105/0/fonts/lato.woff'), url('../fonts/lato.woff');
|
|
8061
8061
|
font-weight: normal;
|
|
8062
8062
|
font-style: normal;
|
|
8063
8063
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
@import "dxHelpers/reset";
|
|
2
|
-
@import "dxHelpers/typeBadge";
|
|
3
2
|
@import "./coveo.css";
|
|
4
3
|
|
|
5
4
|
/* stylelint-disable selector-class-pattern */
|
|
@@ -386,8 +385,3 @@ a.CoveoResultLink,
|
|
|
386
385
|
margin: 0 auto;
|
|
387
386
|
width: fit-content;
|
|
388
387
|
}
|
|
389
|
-
|
|
390
|
-
.dx-badge {
|
|
391
|
-
display: block;
|
|
392
|
-
margin-bottom: var(--dx-g-spacing-smd);
|
|
393
|
-
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { LightningElement, api, track } from "lwc";
|
|
2
2
|
import type * as CoveoSDK from "coveo-search-ui";
|
|
3
3
|
import { track as trackGTM } from "dxUtils/analytics";
|
|
4
|
-
import { CONTENT_TYPE_LABELS } from "dxConstants/contentTypes";
|
|
5
|
-
import { getContentTypeColorVariables } from "dxUtils/contentTypes";
|
|
6
4
|
|
|
7
5
|
interface CoveoSearch {
|
|
8
6
|
state: typeof CoveoSDK.state;
|
|
@@ -40,7 +38,6 @@ const resultsTemplatesInnerHtml = `
|
|
|
40
38
|
data-field-publicurl=""
|
|
41
39
|
>
|
|
42
40
|
<div class="dx-result">
|
|
43
|
-
<span class="CoveoFieldValue" data-field="@content_type" data-helper="badge" data-html-value="true"></span>
|
|
44
41
|
<p class="dx-result-title">
|
|
45
42
|
<a
|
|
46
43
|
class="CoveoResultLink"
|
|
@@ -56,7 +53,6 @@ const resultsTemplatesInnerHtml = `
|
|
|
56
53
|
type="text/html"
|
|
57
54
|
>
|
|
58
55
|
<div class="dx-result">
|
|
59
|
-
<span class="CoveoFieldValue" data-field="@content_type" data-helper="badge" data-html-value="true"></span>
|
|
60
56
|
<p class="dx-result-title">
|
|
61
57
|
<a class="CoveoResultLink"></a>
|
|
62
58
|
</p>
|
|
@@ -175,15 +171,6 @@ export default class SearchResults extends LightningElement {
|
|
|
175
171
|
|
|
176
172
|
this.attachListeners(this.root);
|
|
177
173
|
|
|
178
|
-
Coveo.TemplateHelpers.registerTemplateHelper(
|
|
179
|
-
"badge",
|
|
180
|
-
(value: string) => {
|
|
181
|
-
const style = getContentTypeColorVariables(value);
|
|
182
|
-
const label = CONTENT_TYPE_LABELS[value];
|
|
183
|
-
return `<div style="${style}" class="dx-badge"><span>${label}</span></div>`;
|
|
184
|
-
}
|
|
185
|
-
);
|
|
186
|
-
|
|
187
174
|
Coveo.init(this.root);
|
|
188
175
|
}
|
|
189
176
|
|
|
@@ -1,2 +1,33 @@
|
|
|
1
1
|
@import "dxHelpers/reset";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
.badge {
|
|
4
|
+
--background: var(--sds-g-gray-3);
|
|
5
|
+
--border-radius: var(--dx-g-spacing-smd);
|
|
6
|
+
--color: var(--sds-g-gray-10);
|
|
7
|
+
--height: var(--dx-g-spacing-lg);
|
|
8
|
+
--horizontal-spacing: var(--dx-g-spacing-smd);
|
|
9
|
+
--vertical-spacing: var(--dx-g-spacing-xs);
|
|
10
|
+
|
|
11
|
+
color: var(--dx-c-type-badge-color, var(--color));
|
|
12
|
+
background: var(--dx-c-type-badge-background, var(--background));
|
|
13
|
+
border-radius: var(--border-radius);
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: center;
|
|
17
|
+
height: var(--height);
|
|
18
|
+
width: min-content;
|
|
19
|
+
text-align: center;
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
font-family: var(--dx-g-font-sans);
|
|
22
|
+
font-size: 10px;
|
|
23
|
+
font-weight: var(--dx-g-font-bold);
|
|
24
|
+
padding: var(--vertical-spacing) var(--horizontal-spacing);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.badge.size-small {
|
|
28
|
+
--height: var(--dx-g-spacing-mlg);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
dx-icon {
|
|
32
|
+
margin-right: var(--dx-g-spacing-sm);
|
|
33
|
+
}
|
|
@@ -5,20 +5,65 @@ import {
|
|
|
5
5
|
Color,
|
|
6
6
|
ContentType,
|
|
7
7
|
IconSprite,
|
|
8
|
-
IconData,
|
|
9
8
|
IconSymbol,
|
|
10
9
|
TypeBadgeSize
|
|
11
10
|
} from "typings/custom";
|
|
12
11
|
import { colorToDxColors, buildStyleColorVariables } from "dxUtils/css";
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
import { BRANDS } from "dxConstants/brands";
|
|
13
|
+
import { CONTENT_TYPES } from "dxConstants/contentTypes";
|
|
14
|
+
|
|
15
|
+
const contentTypeLabels = {
|
|
16
|
+
documentation: "Documentation",
|
|
17
|
+
trailhead: "Trailhead",
|
|
18
|
+
blog: "Blog",
|
|
19
|
+
forum: "Forum",
|
|
20
|
+
api: "API",
|
|
21
|
+
event: "Event",
|
|
22
|
+
website: "Website",
|
|
23
|
+
podcast: "Podcast"
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type IconData = {
|
|
27
|
+
iconSymbol: IconSymbol;
|
|
28
|
+
iconSprite: IconSprite;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const contentTypeIcons: {
|
|
32
|
+
[K in ContentType]: IconData;
|
|
33
|
+
} = {
|
|
34
|
+
documentation: {
|
|
35
|
+
iconSprite: "utility",
|
|
36
|
+
iconSymbol: "knowledge_base"
|
|
37
|
+
},
|
|
38
|
+
trailhead: {
|
|
39
|
+
iconSprite: "salesforcebrand",
|
|
40
|
+
iconSymbol: "learning"
|
|
41
|
+
},
|
|
42
|
+
blog: {
|
|
43
|
+
iconSprite: "utility",
|
|
44
|
+
iconSymbol: "comments"
|
|
45
|
+
},
|
|
46
|
+
forum: {
|
|
47
|
+
iconSprite: "general",
|
|
48
|
+
iconSymbol: "question-circle"
|
|
49
|
+
},
|
|
50
|
+
api: {
|
|
51
|
+
iconSprite: "utility",
|
|
52
|
+
iconSymbol: "settings"
|
|
53
|
+
},
|
|
54
|
+
event: {
|
|
55
|
+
iconSprite: "utility",
|
|
56
|
+
iconSymbol: "event"
|
|
57
|
+
},
|
|
58
|
+
website: {
|
|
59
|
+
iconSprite: "utility",
|
|
60
|
+
iconSymbol: "home"
|
|
61
|
+
},
|
|
62
|
+
podcast: {
|
|
63
|
+
iconSprite: "utility",
|
|
64
|
+
iconSymbol: "unmuted"
|
|
65
|
+
}
|
|
66
|
+
};
|
|
22
67
|
|
|
23
68
|
export default class TypeBadge extends LightningElement {
|
|
24
69
|
@api size: TypeBadgeSize = "default";
|
|
@@ -66,29 +111,39 @@ export default class TypeBadge extends LightningElement {
|
|
|
66
111
|
private _iconSymbol?: IconSymbol;
|
|
67
112
|
|
|
68
113
|
private get variantIconData(): IconData | null {
|
|
69
|
-
if (this.variant && this.variant in
|
|
70
|
-
return
|
|
114
|
+
if (this.variant && this.variant in contentTypeIcons) {
|
|
115
|
+
return contentTypeIcons[this.variant as ContentType];
|
|
71
116
|
}
|
|
72
117
|
return null;
|
|
73
118
|
}
|
|
74
119
|
|
|
75
120
|
private get variantLabel(): string | null {
|
|
76
121
|
if (this.isContentType) {
|
|
77
|
-
return
|
|
122
|
+
return contentTypeLabels[this.variant as ContentType];
|
|
78
123
|
}
|
|
79
124
|
return null;
|
|
80
125
|
}
|
|
81
126
|
|
|
82
127
|
private get variantColorScope(): string | null {
|
|
83
|
-
|
|
128
|
+
if (this.isContentType) {
|
|
129
|
+
return "content-type";
|
|
130
|
+
}
|
|
131
|
+
if (this.isBrand) {
|
|
132
|
+
return "brand";
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
84
135
|
}
|
|
85
136
|
|
|
86
137
|
private get isContentType(): boolean {
|
|
87
|
-
return
|
|
138
|
+
return CONTENT_TYPES.includes(this.variant as ContentType);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private get isBrand(): boolean {
|
|
142
|
+
return BRANDS.includes(this.variant as ContentType);
|
|
88
143
|
}
|
|
89
144
|
|
|
90
145
|
private get className(): string {
|
|
91
|
-
return cx("
|
|
146
|
+
return cx("badge", `size-${this.size}`);
|
|
92
147
|
}
|
|
93
148
|
|
|
94
149
|
private get style(): string {
|
|
@@ -99,7 +154,10 @@ export default class TypeBadge extends LightningElement {
|
|
|
99
154
|
});
|
|
100
155
|
}
|
|
101
156
|
if (this.variantColorScope) {
|
|
102
|
-
return
|
|
157
|
+
return buildStyleColorVariables({
|
|
158
|
+
background: `--dx-g-${this.variantColorScope}-${this.variant}-color-background`,
|
|
159
|
+
color: `--dx-g-${this.variantColorScope}-${this.variant}-color`
|
|
160
|
+
});
|
|
103
161
|
}
|
|
104
162
|
if (this.color) {
|
|
105
163
|
const variables = colorToDxColors(this.color as Color);
|
|
@@ -1,54 +1,3 @@
|
|
|
1
|
-
import { ContentType, IconData } from "typings/custom";
|
|
2
|
-
|
|
3
|
-
export const CONTENT_TYPE_LABELS = {
|
|
4
|
-
documentation: "Documentation",
|
|
5
|
-
trailhead: "Trailhead",
|
|
6
|
-
blog: "Blog",
|
|
7
|
-
forum: "Forum",
|
|
8
|
-
api: "API",
|
|
9
|
-
event: "Event",
|
|
10
|
-
website: "Website",
|
|
11
|
-
podcast: "Podcast"
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const CONTENT_TYPE_ICONS: {
|
|
15
|
-
[K in ContentType]: IconData;
|
|
16
|
-
} = {
|
|
17
|
-
documentation: {
|
|
18
|
-
iconSprite: "utility",
|
|
19
|
-
iconSymbol: "knowledge_base"
|
|
20
|
-
},
|
|
21
|
-
trailhead: {
|
|
22
|
-
iconSprite: "salesforcebrand",
|
|
23
|
-
iconSymbol: "learning"
|
|
24
|
-
},
|
|
25
|
-
blog: {
|
|
26
|
-
iconSprite: "utility",
|
|
27
|
-
iconSymbol: "comments"
|
|
28
|
-
},
|
|
29
|
-
forum: {
|
|
30
|
-
iconSprite: "general",
|
|
31
|
-
iconSymbol: "question-circle"
|
|
32
|
-
},
|
|
33
|
-
api: {
|
|
34
|
-
iconSprite: "utility",
|
|
35
|
-
iconSymbol: "settings"
|
|
36
|
-
},
|
|
37
|
-
event: {
|
|
38
|
-
iconSprite: "utility",
|
|
39
|
-
iconSymbol: "event"
|
|
40
|
-
},
|
|
41
|
-
website: {
|
|
42
|
-
iconSprite: "utility",
|
|
43
|
-
iconSymbol: "home"
|
|
44
|
-
},
|
|
45
|
-
podcast: {
|
|
46
|
-
iconSprite: "utility",
|
|
47
|
-
iconSymbol: "unmuted"
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
|
|
52
1
|
export const CONTENT_TYPES = [
|
|
53
2
|
"documentation",
|
|
54
3
|
"trailhead",
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
.dx-badge {
|
|
2
|
-
--background: var(--sds-g-gray-3);
|
|
3
|
-
--border-radius: var(--dx-g-spacing-smd);
|
|
4
|
-
--color: var(--sds-g-gray-10);
|
|
5
|
-
--height: var(--dx-g-spacing-lg);
|
|
6
|
-
--horizontal-spacing: var(--dx-g-spacing-smd);
|
|
7
|
-
--vertical-spacing: var(--dx-g-spacing-xs);
|
|
8
|
-
|
|
9
|
-
color: var(--dx-c-type-badge-color, var(--color));
|
|
10
|
-
background: var(--dx-c-type-badge-background, var(--background));
|
|
11
|
-
border-radius: var(--border-radius);
|
|
12
|
-
display: flex;
|
|
13
|
-
align-items: center;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
height: var(--height);
|
|
16
|
-
width: min-content;
|
|
17
|
-
text-align: center;
|
|
18
|
-
white-space: nowrap;
|
|
19
|
-
font-family: var(--dx-g-font-sans);
|
|
20
|
-
font-size: 10px;
|
|
21
|
-
font-weight: var(--dx-g-font-bold);
|
|
22
|
-
padding: var(--vertical-spacing) var(--horizontal-spacing);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.dx-badge.size-small {
|
|
26
|
-
--height: var(--dx-g-spacing-mlg);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
dx-icon {
|
|
30
|
-
margin-right: var(--dx-g-spacing-sm);
|
|
31
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { CONTENT_TYPES } from "dxConstants/contentTypes";
|
|
2
|
-
import { BRANDS } from "dxConstants/brands";
|
|
3
|
-
import { ContentType } from "typings/custom";
|
|
4
|
-
import { buildStyleColorVariables } from "dxUtils/css";
|
|
5
|
-
|
|
6
|
-
export const isBrand = (id: string): boolean => {
|
|
7
|
-
return BRANDS.includes(id as ContentType);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const isContentType = (id: string): boolean => {
|
|
11
|
-
return CONTENT_TYPES.includes(id as ContentType);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const getContentTypeColorScope = (id: string): string | null => {
|
|
15
|
-
if (isContentType(id)) {
|
|
16
|
-
return "content-type";
|
|
17
|
-
}
|
|
18
|
-
if (isBrand(id)) {
|
|
19
|
-
return "brand";
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const getContentTypeColorVariables = (id: string): string => {
|
|
25
|
-
const scope = getContentTypeColorScope(id);
|
|
26
|
-
return buildStyleColorVariables({
|
|
27
|
-
background: `--dx-g-${scope}-${id}-color-background`,
|
|
28
|
-
color: `--dx-g-${scope}-${id}-color`
|
|
29
|
-
});
|
|
30
|
-
}
|