@salesforcedevs/docs-components 0.15.0-alpha.0 → 0.17.1
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/lwc.config.json +2 -1
- package/package.json +2 -2
- package/src/modules/doc/contentCallout/contentCallout.css +2 -16
- package/src/modules/doc/contentCallout/contentCallout.html +2 -2
- package/src/modules/doc/contentCallout/contentCallout.ts +2 -1
- package/src/modules/doc/header/__tests__/header.test.ts +51 -40
- package/src/modules/doc/header/__tests__/mockProps.ts +3 -0
- package/src/modules/doc/header/header.html +4 -1
- package/src/modules/doc/header/header.stories.ts +30 -0
- package/src/modules/doc/header/header.ts +3 -1
- package/src/modules/doc/phase/__tests__/mockProps.ts +13 -0
- package/src/modules/doc/phase/__tests__/phase.test.ts +60 -0
- package/src/modules/doc/phase/phase.css +55 -0
- package/src/modules/doc/phase/phase.html +26 -0
- package/src/modules/doc/phase/phase.stories.ts +12 -0
- package/src/modules/doc/phase/phase.ts +57 -0
- package/src/modules/helpers/status/status.css +22 -0
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -14,5 +14,5 @@
|
|
|
14
14
|
"publishConfig": {
|
|
15
15
|
"access": "public"
|
|
16
16
|
},
|
|
17
|
-
"gitHead": "
|
|
17
|
+
"gitHead": "53a3b2f6fa7d61fee0305c6bfd272f4806a662fa"
|
|
18
18
|
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
@import "helpers/reset";
|
|
2
2
|
@import "helpers/text";
|
|
3
|
+
@import "helpers/status";
|
|
3
4
|
|
|
4
5
|
.dx-callout {
|
|
5
6
|
border-radius: 4px;
|
|
6
|
-
border-left: 4px solid;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.dx-callout-icon {
|
|
10
|
-
padding-right: var(--dx-g-spacing-md);
|
|
11
7
|
}
|
|
12
8
|
|
|
13
9
|
.dx-callout-base {
|
|
@@ -25,11 +21,6 @@
|
|
|
25
21
|
border-color: var(--dx-g-green-vibrant-60);
|
|
26
22
|
}
|
|
27
23
|
|
|
28
|
-
.dx-callout-warning {
|
|
29
|
-
background-color: rgb(254, 243, 217);
|
|
30
|
-
border-color: var(--dx-g-yellow-vibrant-80);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
24
|
.dx-callout-caution {
|
|
34
25
|
background-color: var(--dx-g-red-natural-95);
|
|
35
26
|
border-color: var(--dx-g-red-vibrant-50);
|
|
@@ -37,7 +28,6 @@
|
|
|
37
28
|
|
|
38
29
|
.dx-callout-base_section {
|
|
39
30
|
width: 100%;
|
|
40
|
-
padding: var(--dx-g-spacing-md);
|
|
41
31
|
}
|
|
42
32
|
|
|
43
33
|
.dx-callout-base_section-large {
|
|
@@ -58,8 +48,4 @@
|
|
|
58
48
|
|
|
59
49
|
.dx-callout-base_column > dx-type-badge-group {
|
|
60
50
|
margin-bottom: var(--dx-g-spacing-sm);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
.dx-callout-title {
|
|
64
|
-
font-weight: bold;
|
|
65
|
-
}
|
|
51
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class={className}>
|
|
3
|
-
<div class="dx-callout-icon">
|
|
3
|
+
<div class="doc-status-icon dx-callout-icon">
|
|
4
4
|
<dx-icon symbol={iconName} size="large" color={iconColor}></dx-icon>
|
|
5
5
|
</div>
|
|
6
6
|
<div class="dx-callout-content">
|
|
7
|
-
<p class="dx-callout-title dx-text-body-3">{title}</p>
|
|
7
|
+
<p class="doc-status-title dx-callout-title dx-text-body-3">{title}</p>
|
|
8
8
|
<span class="dx-callout-body dx-text-body-3">
|
|
9
9
|
<slot onslotchange={onSlotChange}></slot>
|
|
10
10
|
</span>
|
|
@@ -17,7 +17,7 @@ export default class ContentCallout extends LightningElement {
|
|
|
17
17
|
this.iconName = "success";
|
|
18
18
|
break;
|
|
19
19
|
case "warning":
|
|
20
|
-
this.cardVariant = "dx-callout-warning";
|
|
20
|
+
this.cardVariant = "doc-status-container dx-callout-warning";
|
|
21
21
|
this.iconColor = "gray-10";
|
|
22
22
|
this.iconName = "warning";
|
|
23
23
|
break;
|
|
@@ -37,6 +37,7 @@ export default class ContentCallout extends LightningElement {
|
|
|
37
37
|
get className() {
|
|
38
38
|
return cx(
|
|
39
39
|
"dx-callout",
|
|
40
|
+
"doc-status-base",
|
|
40
41
|
"dx-callout-base_section",
|
|
41
42
|
"dx-callout-base_column",
|
|
42
43
|
this.cardVariant
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
import Dropdown from "dx/dropdown";
|
|
13
13
|
import { Option } from "typings/custom";
|
|
14
14
|
import { track } from "dx/instrumentation";
|
|
15
|
+
import { ANALYTICS_INFO } from "utils/headerBase";
|
|
15
16
|
|
|
16
17
|
const EXPECTED_QUERY_TABLET = "(max-width: 980px)";
|
|
17
18
|
const EXPECTED_QUERY_MOBILE = "(max-width: 880px)";
|
|
@@ -22,9 +23,6 @@ jest.mock("dx/instrumentation");
|
|
|
22
23
|
const TAG = "doc-header";
|
|
23
24
|
const render = createRenderComponent(TAG, Header);
|
|
24
25
|
|
|
25
|
-
const GTM_EVENT_NAME = "custEv_signupStart";
|
|
26
|
-
const SIGN_UP_LABEL = "Sign Up";
|
|
27
|
-
|
|
28
26
|
const assertMediaMatchCalls = () => {
|
|
29
27
|
expect(window.matchMedia).toBeCalledTimes(3);
|
|
30
28
|
expect(window.matchMedia).toHaveBeenNthCalledWith(1, EXPECTED_QUERY_MOBILE);
|
|
@@ -98,13 +96,12 @@ describe(TAG, () => {
|
|
|
98
96
|
const element = render();
|
|
99
97
|
expect(element.headerHref).toBe("/");
|
|
100
98
|
|
|
101
|
-
const headerEl: HTMLElement =
|
|
102
|
-
"header"
|
|
103
|
-
);
|
|
99
|
+
const headerEl: HTMLElement =
|
|
100
|
+
element.shadowRoot.querySelector("header");
|
|
104
101
|
expect(headerEl).not.toBeNull();
|
|
105
102
|
expect(headerEl.classList).toHaveLength(0);
|
|
106
103
|
|
|
107
|
-
expect(headerEl.querySelector("dx-
|
|
104
|
+
expect(headerEl.querySelector("dx-banner")).not.toBeNull();
|
|
108
105
|
|
|
109
106
|
const logo = element.shadowRoot.querySelector("dx-logo");
|
|
110
107
|
expect(logo).not.toBeNull();
|
|
@@ -122,9 +119,8 @@ describe(TAG, () => {
|
|
|
122
119
|
element.shadowRoot.querySelector("dx-header-mobile-nav-menu")
|
|
123
120
|
).toBeNull();
|
|
124
121
|
|
|
125
|
-
const homeLink: HTMLAnchorElement =
|
|
126
|
-
".home-link"
|
|
127
|
-
);
|
|
122
|
+
const homeLink: HTMLAnchorElement =
|
|
123
|
+
element.shadowRoot.querySelector(".home-link");
|
|
128
124
|
expect(homeLink).not.toBeNull();
|
|
129
125
|
expect(homeLink.href).toMatch(/\/$/);
|
|
130
126
|
expect(homeLink.querySelector("dx-icon")).toBeNull();
|
|
@@ -150,9 +146,8 @@ describe(TAG, () => {
|
|
|
150
146
|
);
|
|
151
147
|
expect(signUp).not.toBeNull();
|
|
152
148
|
|
|
153
|
-
const headerNavs: Array<HeaderNav> =
|
|
154
|
-
"dx-header-nav"
|
|
155
|
-
);
|
|
149
|
+
const headerNavs: Array<HeaderNav> =
|
|
150
|
+
element.shadowRoot.querySelectorAll("dx-header-nav");
|
|
156
151
|
expect(headerNavs).toHaveLength(1);
|
|
157
152
|
const [globalNav] = headerNavs;
|
|
158
153
|
expect(globalNav.ariaLabel).toBe("Global Navigation Bar");
|
|
@@ -181,9 +176,8 @@ describe(TAG, () => {
|
|
|
181
176
|
it("renders with scoped nav items", () => {
|
|
182
177
|
const element = render(mockPropsEmployees);
|
|
183
178
|
|
|
184
|
-
const headerNavs: Array<HeaderNav> =
|
|
185
|
-
"dx-header-nav"
|
|
186
|
-
);
|
|
179
|
+
const headerNavs: Array<HeaderNav> =
|
|
180
|
+
element.shadowRoot.querySelectorAll("dx-header-nav");
|
|
187
181
|
expect(headerNavs).toHaveLength(2);
|
|
188
182
|
const [globalNav, scopedNav] = headerNavs;
|
|
189
183
|
expect(globalNav.ariaLabel).toBe("Global Navigation Bar");
|
|
@@ -207,9 +201,8 @@ describe(TAG, () => {
|
|
|
207
201
|
it("renders the brand icon when a brand has an icon associated", () => {
|
|
208
202
|
const element = render(mockPropsEmployees);
|
|
209
203
|
|
|
210
|
-
const brandIcon: Icon =
|
|
211
|
-
".brand-icon"
|
|
212
|
-
);
|
|
204
|
+
const brandIcon: Icon =
|
|
205
|
+
element.shadowRoot.querySelector(".brand-icon");
|
|
213
206
|
expect(brandIcon).not.toBeNull();
|
|
214
207
|
expect(brandIcon.symbol).toBe(mockPropsEmployees.brand);
|
|
215
208
|
});
|
|
@@ -220,9 +213,8 @@ describe(TAG, () => {
|
|
|
220
213
|
brand: undefined
|
|
221
214
|
});
|
|
222
215
|
|
|
223
|
-
const brandIcon: Icon =
|
|
224
|
-
".brand-icon"
|
|
225
|
-
);
|
|
216
|
+
const brandIcon: Icon =
|
|
217
|
+
element.shadowRoot.querySelector(".brand-icon");
|
|
226
218
|
expect(brandIcon).toBeNull();
|
|
227
219
|
});
|
|
228
220
|
|
|
@@ -271,9 +263,8 @@ describe(TAG, () => {
|
|
|
271
263
|
bailLabel: "test",
|
|
272
264
|
signupLink: "/"
|
|
273
265
|
});
|
|
274
|
-
const buttons: Array<Button> =
|
|
275
|
-
"dx-button"
|
|
276
|
-
);
|
|
266
|
+
const buttons: Array<Button> =
|
|
267
|
+
element.shadowRoot.querySelectorAll("dx-button");
|
|
277
268
|
|
|
278
269
|
expect(buttons[0].href).toEqual("/");
|
|
279
270
|
expect(buttons[1].href).toEqual("test");
|
|
@@ -285,28 +276,50 @@ describe(TAG, () => {
|
|
|
285
276
|
subtitle: mockPropsDevelopers.subtitle,
|
|
286
277
|
navItems: mockPropsDevelopers.navItems
|
|
287
278
|
});
|
|
288
|
-
const headerSearch =
|
|
289
|
-
"dx-header-search"
|
|
290
|
-
);
|
|
279
|
+
const headerSearch =
|
|
280
|
+
element.shadowRoot.querySelector("dx-header-search");
|
|
291
281
|
|
|
292
282
|
expect(headerSearch).toBeNull();
|
|
293
283
|
return expect(element).toBeAccessible();
|
|
294
284
|
});
|
|
295
285
|
|
|
296
|
-
it("signup button track is
|
|
286
|
+
it("signup button track is being called", () => {
|
|
297
287
|
const element = render(mockPropsDevelopers);
|
|
298
288
|
|
|
299
|
-
const button: HTMLElement =
|
|
300
|
-
"dx-button"
|
|
301
|
-
);
|
|
289
|
+
const button: HTMLElement =
|
|
290
|
+
element.shadowRoot.querySelector("dx-button");
|
|
302
291
|
|
|
303
292
|
button.click();
|
|
304
293
|
|
|
305
294
|
expect(track).toBeCalledTimes(1);
|
|
306
|
-
expect(track).toBeCalledWith(button,
|
|
307
|
-
|
|
295
|
+
expect(track).toBeCalledWith(button, "custEv_signupStart", {
|
|
296
|
+
...ANALYTICS_INFO,
|
|
297
|
+
clickUrl: "/sign-up"
|
|
308
298
|
});
|
|
309
299
|
});
|
|
300
|
+
|
|
301
|
+
it("hides signup button when signupLink property is empty", () => {
|
|
302
|
+
const updatedMockPropsDevelopers = {
|
|
303
|
+
...mockPropsDevelopers,
|
|
304
|
+
signupLink: ""
|
|
305
|
+
};
|
|
306
|
+
const element = render(updatedMockPropsDevelopers);
|
|
307
|
+
const signupButtonContainer: HTMLElement =
|
|
308
|
+
element.shadowRoot.querySelector(".header-login-signup");
|
|
309
|
+
expect(signupButtonContainer).toBeNull();
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it("hides banner when banner markup is empty", () => {
|
|
313
|
+
const bannerMarkup = "";
|
|
314
|
+
const updatedMockPropsDevelopers = {
|
|
315
|
+
...mockPropsDevelopers,
|
|
316
|
+
bannerMarkup
|
|
317
|
+
};
|
|
318
|
+
const element = render(updatedMockPropsDevelopers);
|
|
319
|
+
const bannerElement: HTMLElement =
|
|
320
|
+
element.shadowRoot.querySelector("dx-banner");
|
|
321
|
+
expect(bannerElement).toBeNull();
|
|
322
|
+
});
|
|
310
323
|
});
|
|
311
324
|
|
|
312
325
|
describe("tablet", () => {
|
|
@@ -322,9 +335,8 @@ describe(TAG, () => {
|
|
|
322
335
|
);
|
|
323
336
|
expect(button).toBeNull();
|
|
324
337
|
|
|
325
|
-
const headerSearch =
|
|
326
|
-
"dx-header-search"
|
|
327
|
-
);
|
|
338
|
+
const headerSearch =
|
|
339
|
+
element.shadowRoot.querySelector("dx-header-search");
|
|
328
340
|
expect(headerSearch).not.toBeNull();
|
|
329
341
|
expect(headerSearch.mobile).toBe(true);
|
|
330
342
|
|
|
@@ -360,9 +372,8 @@ describe(TAG, () => {
|
|
|
360
372
|
);
|
|
361
373
|
expect(button).not.toBeNull();
|
|
362
374
|
|
|
363
|
-
const headerSearch =
|
|
364
|
-
"dx-header-search"
|
|
365
|
-
);
|
|
375
|
+
const headerSearch =
|
|
376
|
+
element.shadowRoot.querySelector("dx-header-search");
|
|
366
377
|
|
|
367
378
|
expect(
|
|
368
379
|
element.shadowRoot.querySelector(
|
|
@@ -32,6 +32,9 @@ export const mockPropsDevelopers = {
|
|
|
32
32
|
title: "Salesforce Developers",
|
|
33
33
|
subtitle: "Apex Developer Guides",
|
|
34
34
|
languages,
|
|
35
|
+
signupLink: "/sign-up",
|
|
36
|
+
bannerMarkup:
|
|
37
|
+
'<span><a href="https://forms.gle/TdSyKFPHXoBx7seM9" target="blank">Share your feedback</a>about our new site.</span>',
|
|
35
38
|
...coveoConfig
|
|
36
39
|
};
|
|
37
40
|
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<dx-brand-theme-provider brand={brand}>
|
|
3
3
|
<header class={className}>
|
|
4
|
-
<dx-
|
|
4
|
+
<dx-banner
|
|
5
|
+
if:true={bannerMarkup}
|
|
6
|
+
banner-markup={bannerMarkup}
|
|
7
|
+
></dx-banner>
|
|
5
8
|
<div class="header_l1">
|
|
6
9
|
<div if:true={showMenuButton} class="nav_menu-ctas">
|
|
7
10
|
<dx-button
|
|
@@ -101,6 +101,8 @@ const headerStoryGenerator = (
|
|
|
101
101
|
bail-label="${args.bailLabel}"
|
|
102
102
|
brand="${brand}"
|
|
103
103
|
onclick="headerClick(event)"
|
|
104
|
+
signup-link="${mockProps.signupLink}"
|
|
105
|
+
banner-markup="${mockProps.bannerMarkup}"
|
|
104
106
|
></doc-header>`;
|
|
105
107
|
|
|
106
108
|
export const Base = (args: any) => html`
|
|
@@ -158,3 +160,31 @@ export const Service = (args: any) =>
|
|
|
158
160
|
|
|
159
161
|
export const Analytics = (args: any) =>
|
|
160
162
|
headerStoryGenerator(mockPropsAnalytics, "analytics", args);
|
|
163
|
+
|
|
164
|
+
export const AnalyticsWithoutSignup = (args: any) =>
|
|
165
|
+
headerStoryGenerator(
|
|
166
|
+
{ ...mockPropsAnalytics, signupLink:"" },
|
|
167
|
+
"analytics",
|
|
168
|
+
args
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
export const AnalyticsWithCustomBannerText = (args: any) =>
|
|
172
|
+
headerStoryGenerator(
|
|
173
|
+
{
|
|
174
|
+
...mockPropsMarketing,
|
|
175
|
+
bannerMarkup:
|
|
176
|
+
'Salesforce Subscription Management API ("the API") is available as a developer preview. The API is not generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. All components of the API including request names, parameters, objects, and fields are subject to change or deprecation at any time, with or without notice. Do not use the API with real data or in a production environment.'
|
|
177
|
+
},
|
|
178
|
+
"analytics",
|
|
179
|
+
args
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
export const AnalyticsWithoutBanner = (args: any) =>
|
|
183
|
+
headerStoryGenerator(
|
|
184
|
+
{
|
|
185
|
+
...mockPropsMarketing,
|
|
186
|
+
bannerMarkup: ""
|
|
187
|
+
},
|
|
188
|
+
"analytics",
|
|
189
|
+
args
|
|
190
|
+
);
|
|
@@ -63,7 +63,9 @@ export default class Header extends HeaderBase {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
private get showSignup(): boolean {
|
|
66
|
-
return
|
|
66
|
+
return this.signupLink
|
|
67
|
+
? (this.tablet && !this.isSearchOpen) || !this.tablet
|
|
68
|
+
: false;
|
|
67
69
|
}
|
|
68
70
|
|
|
69
71
|
private get hasLanguages(): boolean {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
phase: "dev-preview",
|
|
3
|
+
title: "Developer Preview",
|
|
4
|
+
body: `This feature is not generally available and is being piloted with
|
|
5
|
+
certain Customers subject to additional terms and conditions. It
|
|
6
|
+
is not part of your purchased Services. This feature is subject to
|
|
7
|
+
change, may be discontinued with no notice at any time in SFDC’s
|
|
8
|
+
available. Make your purchase decisions only on the basis of
|
|
9
|
+
generally available products and features. This feature is made
|
|
10
|
+
available on an AS IS basis and use of this feature is at your
|
|
11
|
+
sole risk. Check <a href="https://developer.salesforce.com/">
|
|
12
|
+
Developers Website</a> for more information.`
|
|
13
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import DocPhase from "doc/phase";
|
|
2
|
+
import { createRenderComponent } from "utils/tests";
|
|
3
|
+
import mockProps from "./mockProps";
|
|
4
|
+
|
|
5
|
+
const TAG = "doc-phase";
|
|
6
|
+
const render = createRenderComponent(TAG, DocPhase);
|
|
7
|
+
|
|
8
|
+
describe(TAG, () => {
|
|
9
|
+
let element: any;
|
|
10
|
+
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
element = render({
|
|
13
|
+
docPhaseInfo: mockProps
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("renders the icon, title & body with the default phase", async () => {
|
|
18
|
+
const els = [
|
|
19
|
+
".doc-phase-container",
|
|
20
|
+
".doc-phase-icon",
|
|
21
|
+
".doc-phase-title",
|
|
22
|
+
".doc-phase-body"
|
|
23
|
+
].map((query) => element.shadowRoot.querySelector(query));
|
|
24
|
+
|
|
25
|
+
expect(els).not.toContain(null);
|
|
26
|
+
|
|
27
|
+
await expect(element).toBeAccessible();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("hides the body when clicking button on expand state", async () => {
|
|
31
|
+
|
|
32
|
+
const showOrHideButton = element.shadowRoot.querySelector("dx-button");
|
|
33
|
+
|
|
34
|
+
const docPhaseBody: HTMLSpanElement =
|
|
35
|
+
element.shadowRoot.querySelector(".doc-phase-body");
|
|
36
|
+
|
|
37
|
+
showOrHideButton.click();
|
|
38
|
+
|
|
39
|
+
return Promise.resolve().then(() => {
|
|
40
|
+
expect(docPhaseBody.classList).toContain("doc-phase-body-hidden");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("shows the body when clicking button on collapse state", async () => {
|
|
45
|
+
|
|
46
|
+
const showOrHideButton = element.shadowRoot.querySelector("dx-button");
|
|
47
|
+
|
|
48
|
+
const docPhaseBody: HTMLSpanElement =
|
|
49
|
+
element.shadowRoot.querySelector(".doc-phase-body");
|
|
50
|
+
|
|
51
|
+
showOrHideButton.click();
|
|
52
|
+
showOrHideButton.click();
|
|
53
|
+
|
|
54
|
+
return Promise.resolve().then(() => {
|
|
55
|
+
expect(docPhaseBody.classList).not.toContain(
|
|
56
|
+
"doc-phase-body-hidden"
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
@import "helpers/reset";
|
|
2
|
+
@import "helpers/text";
|
|
3
|
+
@import "helpers/status";
|
|
4
|
+
|
|
5
|
+
.doc-phase-container {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
padding-left: var(--dx-g-spacing-3xl);
|
|
9
|
+
padding-right: var(--dx-g-spacing-3xl);
|
|
10
|
+
width: 100%;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.doc-phase-title-container {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: row;
|
|
16
|
+
align-items: center;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
dx-button {
|
|
20
|
+
margin-left: auto;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
NOTE: Here we are assuming that indicator height won't go beyond 1000px.
|
|
25
|
+
|
|
26
|
+
It's one of the suggested way to achieve the expand/collapse animation
|
|
27
|
+
Ref: https://stackoverflow.com/a/41164095
|
|
28
|
+
|
|
29
|
+
Otherwise we need to change the height when user clicks on button
|
|
30
|
+
Ref: https://stackoverflow.com/a/11837673
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
.doc-phase-body {
|
|
34
|
+
max-height: 1000px;
|
|
35
|
+
overflow: hidden;
|
|
36
|
+
padding-top: var(--dx-g-spacing-smd);
|
|
37
|
+
transition: max-height 0.25s ease, padding 0.25s ease;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.doc-phase-body-hidden {
|
|
41
|
+
max-height: 0;
|
|
42
|
+
padding-top: 0;
|
|
43
|
+
transition: max-height 0.1s ease-out, padding 0.25s ease-out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.doc-phase-body a {
|
|
47
|
+
color: var(--dx-g-blue-vibrant-50);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Small Devices */
|
|
51
|
+
@media screen and (max-width: 480px) {
|
|
52
|
+
.doc-phase-container {
|
|
53
|
+
padding: var(--doc-status-vertical-padding);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class={className} part="container">
|
|
3
|
+
<div class="doc-phase-title-container">
|
|
4
|
+
<dx-icon
|
|
5
|
+
class="doc-status-icon doc-phase-icon"
|
|
6
|
+
symbol="recipe"
|
|
7
|
+
size="large"
|
|
8
|
+
color="status-icon-color"
|
|
9
|
+
></dx-icon>
|
|
10
|
+
<p class="doc-status-title doc-phase-title dx-text-body-3">{docPhaseTitle}</p>
|
|
11
|
+
<dx-button
|
|
12
|
+
variant="inline"
|
|
13
|
+
onclick={onButtonClick}
|
|
14
|
+
aria-label={hideBodyText}
|
|
15
|
+
>
|
|
16
|
+
{hideBodyText}
|
|
17
|
+
</dx-button>
|
|
18
|
+
</div>
|
|
19
|
+
<!--
|
|
20
|
+
NOTE: Here we are rendering mark up using lwc:dom & innerHTML
|
|
21
|
+
option instead of slots because the html markup will come as a
|
|
22
|
+
property to the component from a configuration
|
|
23
|
+
-->
|
|
24
|
+
<span lwc:dom="manual" class={bodyClassName}></span>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import mockProps from "./__tests__/mockProps";
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
title: "docs/doc-phase",
|
|
5
|
+
component: "doc-phase"
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
const docPhaseInfo = JSON.stringify(mockProps);
|
|
9
|
+
|
|
10
|
+
export const Default = () => `
|
|
11
|
+
<doc-phase doc-phase-info='${docPhaseInfo}'></doc-phase>
|
|
12
|
+
`;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { LightningElement, api } from "lwc";
|
|
2
|
+
import cx from "classnames";
|
|
3
|
+
|
|
4
|
+
import { DocPhaseInfo } from "typings/custom";
|
|
5
|
+
import { toJson } from "utils/normalizers";
|
|
6
|
+
|
|
7
|
+
export default class Phase extends LightningElement {
|
|
8
|
+
_docPhaseInfo!: DocPhaseInfo;
|
|
9
|
+
|
|
10
|
+
isBodyHidden = false;
|
|
11
|
+
|
|
12
|
+
get docPhaseTitle() {
|
|
13
|
+
return this.docPhaseInfo.title;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@api
|
|
17
|
+
get docPhaseInfo(): DocPhaseInfo {
|
|
18
|
+
return this._docPhaseInfo;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
set docPhaseInfo(value) {
|
|
22
|
+
this._docPhaseInfo = toJson(value);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
get hideBodyText() {
|
|
26
|
+
return this.isBodyHidden ? "Show" : "Hide"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get className() {
|
|
30
|
+
return cx(
|
|
31
|
+
"doc-status-base",
|
|
32
|
+
"doc-status-container",
|
|
33
|
+
"doc-phase-container"
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get bodyClassName() {
|
|
38
|
+
return cx(
|
|
39
|
+
"doc-phase-body",
|
|
40
|
+
"dx-text-body-3",
|
|
41
|
+
this.isBodyHidden && "doc-phase-body-hidden"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
renderedCallback() {
|
|
46
|
+
const phaseBodyContainer =
|
|
47
|
+
this.template.querySelector(".doc-phase-body");
|
|
48
|
+
if (phaseBodyContainer) {
|
|
49
|
+
// eslint-disable-next-line @lwc/lwc/no-inner-html
|
|
50
|
+
phaseBodyContainer.innerHTML = this.docPhaseInfo.body;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
onButtonClick() {
|
|
55
|
+
this.isBodyHidden = !this.isBodyHidden;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--dx-status-icon-color: var(--dx-g-gray-10);
|
|
3
|
+
--doc-status-vertical-padding: var(--dx-g-spacing-md);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.doc-status-base {
|
|
7
|
+
border-left: 4px solid;
|
|
8
|
+
padding: var(--doc-status-vertical-padding);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.doc-status-container {
|
|
12
|
+
background-color: rgb(254, 243, 217);
|
|
13
|
+
border-color: var(--dx-g-yellow-vibrant-80);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.doc-status-title {
|
|
17
|
+
font-weight: var(--dx-g-font-bold);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.doc-status-icon {
|
|
21
|
+
margin-right: var(--dx-g-spacing-md);
|
|
22
|
+
}
|