@salesforcedevs/docs-components 0.0.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.
Files changed (67) hide show
  1. package/LICENSE +12 -0
  2. package/lwc.config.json +20 -0
  3. package/package.json +28 -0
  4. package/src/modules/README.md +41 -0
  5. package/src/modules/doc/amfReference/amfReference.css +5 -0
  6. package/src/modules/doc/amfReference/amfReference.html +47 -0
  7. package/src/modules/doc/amfReference/amfReference.ts +1361 -0
  8. package/src/modules/doc/amfReference/constants.ts +76 -0
  9. package/src/modules/doc/amfReference/types.ts +133 -0
  10. package/src/modules/doc/amfReference/utils.ts +669 -0
  11. package/src/modules/doc/amfTopic/amfTopic.css +1 -0
  12. package/src/modules/doc/amfTopic/amfTopic.html +3 -0
  13. package/src/modules/doc/amfTopic/amfTopic.ts +94 -0
  14. package/src/modules/doc/amfTopic/types.ts +54 -0
  15. package/src/modules/doc/amfTopic/utils.ts +130 -0
  16. package/src/modules/doc/breadcrumbItem/breadcrumbItem.css +51 -0
  17. package/src/modules/doc/breadcrumbItem/breadcrumbItem.html +5 -0
  18. package/src/modules/doc/breadcrumbItem/breadcrumbItem.ts +64 -0
  19. package/src/modules/doc/breadcrumbs/breadcrumbs.css +27 -0
  20. package/src/modules/doc/breadcrumbs/breadcrumbs.html +60 -0
  21. package/src/modules/doc/breadcrumbs/breadcrumbs.ts +187 -0
  22. package/src/modules/doc/content/content.css +399 -0
  23. package/src/modules/doc/content/content.html +6 -0
  24. package/src/modules/doc/content/content.ts +378 -0
  25. package/src/modules/doc/contentCallout/contentCallout.css +56 -0
  26. package/src/modules/doc/contentCallout/contentCallout.html +15 -0
  27. package/src/modules/doc/contentCallout/contentCallout.ts +58 -0
  28. package/src/modules/doc/contentLayout/contentLayout.css +98 -0
  29. package/src/modules/doc/contentLayout/contentLayout.html +50 -0
  30. package/src/modules/doc/contentLayout/contentLayout.ts +322 -0
  31. package/src/modules/doc/contentMedia/contentMedia.css +49 -0
  32. package/src/modules/doc/contentMedia/contentMedia.html +23 -0
  33. package/src/modules/doc/contentMedia/contentMedia.ts +34 -0
  34. package/src/modules/doc/header/header.css +103 -0
  35. package/src/modules/doc/header/header.html +153 -0
  36. package/src/modules/doc/header/header.ts +142 -0
  37. package/src/modules/doc/heading/heading.css +54 -0
  38. package/src/modules/doc/heading/heading.html +14 -0
  39. package/src/modules/doc/heading/heading.ts +65 -0
  40. package/src/modules/doc/headingAnchor/headingAnchor.css +33 -0
  41. package/src/modules/doc/headingAnchor/headingAnchor.html +19 -0
  42. package/src/modules/doc/headingAnchor/headingAnchor.ts +43 -0
  43. package/src/modules/doc/headingContent/headingContent.css +53 -0
  44. package/src/modules/doc/headingContent/headingContent.html +13 -0
  45. package/src/modules/doc/headingContent/headingContent.ts +30 -0
  46. package/src/modules/doc/nav/nav.css +14 -0
  47. package/src/modules/doc/nav/nav.html +12 -0
  48. package/src/modules/doc/nav/nav.ts +39 -0
  49. package/src/modules/doc/phase/phase.css +55 -0
  50. package/src/modules/doc/phase/phase.html +28 -0
  51. package/src/modules/doc/phase/phase.ts +57 -0
  52. package/src/modules/doc/toc/toc.css +31 -0
  53. package/src/modules/doc/toc/toc.html +127 -0
  54. package/src/modules/doc/toc/toc.ts +27 -0
  55. package/src/modules/doc/toolbar/toolbar.css +8 -0
  56. package/src/modules/doc/toolbar/toolbar.html +34 -0
  57. package/src/modules/doc/toolbar/toolbar.ts +79 -0
  58. package/src/modules/doc/xmlContent/types.ts +114 -0
  59. package/src/modules/doc/xmlContent/utils.ts +161 -0
  60. package/src/modules/doc/xmlContent/xmlContent.css +32 -0
  61. package/src/modules/doc/xmlContent/xmlContent.html +40 -0
  62. package/src/modules/doc/xmlContent/xmlContent.ts +659 -0
  63. package/src/modules/docBaseElements/lightningElementWithState/lightningElementWithState.ts +93 -0
  64. package/src/modules/docHelpers/amfStyle/amfStyle.css +355 -0
  65. package/src/modules/docHelpers/phaseContentLayout/phaseContentLayout.css +39 -0
  66. package/src/modules/docHelpers/status/status.css +22 -0
  67. package/src/modules/docUtils/SearchSyncer/SearchSyncer.ts +85 -0
@@ -0,0 +1,142 @@
1
+ import { api } from "lwc";
2
+ import cx from "classnames";
3
+ import type { OptionWithNested, OptionWithLink } from "typings/custom";
4
+ import { HeaderBase } from "dxBaseElements/headerBase";
5
+ import { toJson } from "dxUtils/normalizers";
6
+ import get from "lodash.get";
7
+
8
+ const TABLET_MATCH = "980px";
9
+ const MOBILE_MATCH = "880px";
10
+ const SMALL_MOBILE_MATCH = "740px";
11
+
12
+ export default class Header extends HeaderBase {
13
+ @api langValuePath: string = "id"; // allows to override how language property is interpreted, follows valuePath dropdown api.
14
+ @api headerHref: string = "/";
15
+
16
+ @api
17
+ get scopedNavItems() {
18
+ return this._scopedNavItems;
19
+ }
20
+
21
+ set scopedNavItems(value) {
22
+ this._scopedNavItems = toJson(value);
23
+ }
24
+
25
+ @api
26
+ get languages() {
27
+ return this._languages;
28
+ }
29
+
30
+ set languages(value) {
31
+ this._languages = toJson(value);
32
+ }
33
+
34
+ @api
35
+ get language() {
36
+ return this._language;
37
+ }
38
+
39
+ set language(value) {
40
+ if (this._language !== value) {
41
+ this._language = value;
42
+ }
43
+ }
44
+
45
+ private _language: string | null = null;
46
+ private _languages!: OptionWithLink[];
47
+ private _scopedNavItems!: OptionWithNested[];
48
+ private smallMobile = false;
49
+ private smallMobileMatchMedia!: MediaQueryList;
50
+ private tablet = false;
51
+ private tabletMatchMedia!: MediaQueryList;
52
+
53
+ protected mobileBreakpoint(): string {
54
+ return MOBILE_MATCH;
55
+ }
56
+
57
+ private get hasScopedNavItems(): boolean {
58
+ return this.scopedNavItems && this.scopedNavItems.length > 0;
59
+ }
60
+
61
+ private get showDesktopNavItems(): boolean {
62
+ return !this.mobile && this.hasNavItems;
63
+ }
64
+
65
+ private get showSignup(): boolean {
66
+ return this.signupLink
67
+ ? (this.tablet && !this.isSearchOpen) || !this.tablet
68
+ : false;
69
+ }
70
+
71
+ private get hasLanguages(): boolean {
72
+ return !!(this.languages && this.languages.length);
73
+ }
74
+
75
+ private get showMobileLanguages(): boolean {
76
+ return this.smallMobile && this.hasLanguages;
77
+ }
78
+
79
+ private get languageLabel(): string {
80
+ return (
81
+ (this.language &&
82
+ this.languages.find(
83
+ (lang) => get(lang, this.langValuePath) === this.language
84
+ )?.label) ||
85
+ this.languages[0].label
86
+ );
87
+ }
88
+
89
+ private get showMenuButton(): boolean {
90
+ return this.mobile && this.hasNavItems;
91
+ }
92
+
93
+ connectedCallback(): void {
94
+ super.connectedCallback();
95
+ this.tabletMatchMedia = window.matchMedia(
96
+ `(max-width: ${TABLET_MATCH})`
97
+ );
98
+ this.onTabletChange(this.tabletMatchMedia);
99
+ this.tabletMatchMedia.addEventListener("change", this.onTabletChange);
100
+
101
+ this.smallMobileMatchMedia = window.matchMedia(
102
+ `(max-width: ${SMALL_MOBILE_MATCH})`
103
+ );
104
+ this.onSmallMobileChange(this.smallMobileMatchMedia);
105
+ this.smallMobileMatchMedia.addEventListener(
106
+ "change",
107
+ this.onSmallMobileChange
108
+ );
109
+ }
110
+
111
+ disconnectedCallback(): void {
112
+ super.disconnectedCallback();
113
+ this.tabletMatchMedia.removeEventListener(
114
+ "change",
115
+ this.onTabletChange
116
+ );
117
+
118
+ this.smallMobileMatchMedia.removeEventListener(
119
+ "change",
120
+ this.onSmallMobileChange
121
+ );
122
+ }
123
+
124
+ private onTabletChange = (e: MediaQueryListEvent | MediaQueryList) =>
125
+ (this.tablet = e.matches);
126
+
127
+ private onSmallMobileChange = (e: MediaQueryListEvent | MediaQueryList) =>
128
+ (this.smallMobile = e.matches);
129
+
130
+ protected additionalClasses(): string {
131
+ return cx(
132
+ this.brand && "has-brand",
133
+ this.hasScopedNavItems && "has-scoped-nav-items"
134
+ );
135
+ }
136
+
137
+ private onLangChange(event: CustomEvent<string>): void {
138
+ const { detail } = event;
139
+ this._language = detail;
140
+ this.dispatchEvent(new CustomEvent("langchange", { detail }));
141
+ }
142
+ }
@@ -0,0 +1,54 @@
1
+ h1,
2
+ h2,
3
+ h3,
4
+ h4,
5
+ h5,
6
+ h6 {
7
+ color: var(--dx-g-blue-vibrant-20);
8
+ font-family: var(--dx-g-font-display);
9
+ font-weight: var(--dx-g-font-demi);
10
+ }
11
+
12
+ .display-3 {
13
+ margin: 0 0 24px 0;
14
+ font-size: var(--dx-g-text-3xl);
15
+ letter-spacing: -0.85px;
16
+ line-height: var(--dx-g-text-4xl);
17
+ }
18
+
19
+ .display-3 doc-heading-content {
20
+ --doc-c-heading-anchor-button-bottom: 8px;
21
+ }
22
+
23
+ .display-4 {
24
+ margin: var(--dx-g-spacing-xl) 0 var(--dx-g-spacing-md) 0;
25
+ font-size: var(--dx-g-text-xl);
26
+ letter-spacing: -0.1px;
27
+ line-height: var(--dx-g-spacing-lg);
28
+ }
29
+
30
+ .display-4 doc-heading-content {
31
+ --doc-c-heading-anchor-button-bottom: -3px;
32
+ }
33
+
34
+ .display-5 {
35
+ margin: var(--dx-g-spacing-lg) 0 var(--dx-g-spacing-md) 0;
36
+ font-size: var(--dx-g-text-lg);
37
+ letter-spacing: -0.1px;
38
+ line-height: var(--dx-g-spacing-lg);
39
+ }
40
+
41
+ .display-5 doc-heading-content {
42
+ --doc-c-heading-anchor-button-bottom: -4px;
43
+ }
44
+
45
+ .display-6 {
46
+ margin: var(--dx-g-spacing-md) 0 var(--dx-g-spacing-sm) 0;
47
+ font-size: var(--dx-g-text-base);
48
+ letter-spacing: 0;
49
+ line-height: var(--dx-g-spacing-mlg);
50
+ }
51
+
52
+ .display-6 doc-heading-content {
53
+ --doc-c-heading-anchor-button-bottom: -6px;
54
+ }
@@ -0,0 +1,14 @@
1
+ <template>
2
+ <h1 class={className} if:true={isAriaLevelOne}>
3
+ <doc-heading-content title={title} hash={hash}></doc-heading-content>
4
+ </h1>
5
+ <h2 class={className} if:true={isAriaLevelTwo}>
6
+ <doc-heading-content title={title} hash={hash}></doc-heading-content>
7
+ </h2>
8
+ <h3 class={className} if:true={isAriaLevelThree}>
9
+ <doc-heading-content title={title} hash={hash}></doc-heading-content>
10
+ </h3>
11
+ <h4 class={className} if:true={isAriaLevelFour}>
12
+ <doc-heading-content title={title} hash={hash}></doc-heading-content>
13
+ </h4>
14
+ </template>
@@ -0,0 +1,65 @@
1
+ import { LightningElement, api } from "lwc";
2
+
3
+ export const displayLevels = ["3", "4", "5", "6"];
4
+
5
+ export const ariaLevels = ["1", "2", "3", "4"];
6
+
7
+ export const ariaDisplayLevels: { [key: string]: string } = {
8
+ "1": "3",
9
+ "2": "4",
10
+ "3": "5",
11
+ "4": "6"
12
+ };
13
+
14
+ export default class Heading extends LightningElement {
15
+ @api title: string = "";
16
+ @api hash: string | null = null;
17
+
18
+ @api
19
+ private get ariaLevel(): string {
20
+ return this._ariaLevel || "2";
21
+ }
22
+ private set ariaLevel(value: string | null) {
23
+ if (value && !ariaLevels.includes(value)) {
24
+ console.error(`Invalid aria-level: "${value}"`);
25
+ return;
26
+ }
27
+ if (value) {
28
+ this._ariaLevel = value;
29
+ }
30
+ }
31
+
32
+ @api
33
+ private get displayLevel(): string {
34
+ return this._displayLevel || ariaDisplayLevels[this.ariaLevel];
35
+ }
36
+ private set displayLevel(value: string | null) {
37
+ if (value && !displayLevels.includes(value)) {
38
+ console.error(`Invalid display-level: "${value}"`);
39
+ value = null;
40
+ }
41
+ if (value) {
42
+ this._displayLevel = value;
43
+ }
44
+ }
45
+
46
+ private _ariaLevel: string | null = null;
47
+ private _displayLevel: string | null = null;
48
+
49
+ private get isAriaLevelOne(): boolean {
50
+ return this.ariaLevel === "1";
51
+ }
52
+ private get isAriaLevelTwo(): boolean {
53
+ return this.ariaLevel === "2";
54
+ }
55
+ private get isAriaLevelThree(): boolean {
56
+ return this.ariaLevel === "3";
57
+ }
58
+ private get isAriaLevelFour(): boolean {
59
+ return this.ariaLevel === "4";
60
+ }
61
+
62
+ private get className(): string {
63
+ return `display-${this.displayLevel}`;
64
+ }
65
+ }
@@ -0,0 +1,33 @@
1
+ @import "dxHelpers/reset";
2
+
3
+ button {
4
+ opacity: 0;
5
+ color: rgb(11, 92, 171);
6
+ }
7
+
8
+ button:hover {
9
+ opacity: 1;
10
+ outline: none;
11
+ }
12
+
13
+ button:focus {
14
+ opacity: 1;
15
+ outline: none;
16
+ }
17
+
18
+ button:focus-visible {
19
+ border-radius: 4px;
20
+ border: 2px solid rgb(11, 92, 171);
21
+ }
22
+
23
+ .icon-wrapper {
24
+ height: 32px;
25
+ width: 32px;
26
+ display: flex;
27
+ justify-content: center;
28
+ align-items: center;
29
+ }
30
+
31
+ .icon-container {
32
+ --dx-c-icon-size: 18px;
33
+ }
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <dx-tooltip placement="top" label={label}>
3
+ <button
4
+ onclick={onIconClick}
5
+ aria-label={ariaLabel}
6
+ onkeydown={onKeyDown}
7
+ part="headingAnchorIcon"
8
+ >
9
+ <div class="icon-wrapper">
10
+ <dx-icon
11
+ sprite={iconSprite}
12
+ size={iconSize}
13
+ symbol={iconSymbol}
14
+ class="icon-container"
15
+ ></dx-icon>
16
+ </div>
17
+ </button>
18
+ </dx-tooltip>
19
+ </template>
@@ -0,0 +1,43 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import { IconSprite, IconSize, IconSymbol } from "typings/custom";
3
+
4
+ export default class HeadingAnchor extends LightningElement {
5
+ @api ariaLabel: string = "copy";
6
+ @api iconSize?: IconSize = "override";
7
+ @api iconSprite?: IconSprite = "utility";
8
+ @api iconSymbol?: IconSymbol;
9
+ @api title: string = "";
10
+ @api urlText: string = "";
11
+
12
+ label: string = "Copy link to clipboard";
13
+
14
+ private async onIconClick() {
15
+ await this.iconClickHandler();
16
+ }
17
+
18
+ private async iconClickHandler() {
19
+ this.label = "Copied";
20
+ setTimeout(() => {
21
+ this.label = "Copy link to clipboard";
22
+ }, 2000);
23
+
24
+ try {
25
+ if (this.title && this.urlText) {
26
+ const [hostUrl] = window.location.href.split("#");
27
+ const url = `${hostUrl}#${this.urlText}`;
28
+ await navigator.clipboard.writeText(url);
29
+ }
30
+ } catch (error) {
31
+ console.error(error);
32
+ }
33
+ }
34
+
35
+ private async onKeyDown(e: KeyboardEvent) {
36
+ switch (e.key) {
37
+ case "Enter":
38
+ await this.iconClickHandler();
39
+ break;
40
+ default:
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,53 @@
1
+ @import "dxHelpers/reset";
2
+
3
+ :host {
4
+ --doc-c-heading-anchor-button-bottom: 0;
5
+ --doc-c-heading-anchor-icon-size: 18px;
6
+ --button-size: var(--dx-g-spacing-xl);
7
+ }
8
+
9
+ dx-tooltip {
10
+ line-height: var(--button-size);
11
+ padding-right: var(--dx-g-spacing-xs);
12
+ }
13
+
14
+ .button-container {
15
+ height: 100%;
16
+ margin-right: calc(var(--dx-g-spacing-xl) - 4px);
17
+ position: relative;
18
+ padding-right: var(--dx-g-spacing-xs);
19
+ }
20
+
21
+ button {
22
+ position: absolute;
23
+ bottom: var(--doc-c-heading-anchor-button-bottom);
24
+ left: 0;
25
+ opacity: 0;
26
+ color: rgb(11, 92, 171);
27
+ display: flex;
28
+ justify-content: center;
29
+ align-items: center;
30
+ height: var(--button-size);
31
+ width: var(--button-size);
32
+ border-radius: 4px;
33
+ }
34
+
35
+ dx-icon {
36
+ --dx-c-icon-size: var(--doc-c-heading-anchor-icon-size);
37
+ }
38
+
39
+ .title {
40
+ word-break: break-word;
41
+ }
42
+
43
+ button:focus {
44
+ box-shadow: 0 0 0 2px rgb(11 92 171);
45
+ }
46
+
47
+ button:focus,
48
+ button:hover,
49
+ span:hover dx-tooltip button,
50
+ span:hover ~ dx-tooltip button {
51
+ opacity: 1;
52
+ outline: none;
53
+ }
@@ -0,0 +1,13 @@
1
+ <template>
2
+ <template if:false={hash}>{title}</template>
3
+ <template if:true={hash}>
4
+ <span class="title">{title}&nbsp;</span>
5
+ <dx-tooltip placement="top" label={label}>
6
+ <span class="button-container">
7
+ <button onclick={copy} aria-label="copy">
8
+ <dx-icon size="override" symbol="link"></dx-icon>
9
+ </button>
10
+ </span>
11
+ </dx-tooltip>
12
+ </template>
13
+ </template>
@@ -0,0 +1,30 @@
1
+ import { LightningElement, api } from "lwc";
2
+
3
+ export default class HeadingContent extends LightningElement {
4
+ @api title: string = "";
5
+ @api hash: string | null = null;
6
+
7
+ label: string = "Copy link to clipboard";
8
+ timeout: number | null = null;
9
+
10
+ private async copy() {
11
+ if (this.timeout) {
12
+ window.clearTimeout(this.timeout);
13
+ }
14
+
15
+ this.label = "Copied";
16
+ this.timeout = window.setTimeout(() => {
17
+ this.label = "Copy link to clipboard";
18
+ }, 2000);
19
+
20
+ try {
21
+ if (this.title && this.hash) {
22
+ const [hostUrl] = window.location.href.split("#");
23
+ const url = `${hostUrl}#${this.hash}`;
24
+ await navigator.clipboard.writeText(url);
25
+ }
26
+ } catch (error) {
27
+ console.error(error);
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,14 @@
1
+ :host {
2
+ display: flex;
3
+ flex-direction: column;
4
+ }
5
+
6
+ .doc-navigation {
7
+ width: 100%;
8
+ }
9
+
10
+ dx-sidebar {
11
+ --dx-c-sidebar-width: unset;
12
+
13
+ display: block;
14
+ }
@@ -0,0 +1,12 @@
1
+ <template>
2
+ <div class="doc-navigation">
3
+ <template if:true={toc}>
4
+ <dx-sidebar
5
+ header="Pages"
6
+ trees={toc}
7
+ onselect={handleSelected}
8
+ value={selectedNavigationItem}
9
+ ></dx-sidebar>
10
+ </template>
11
+ </div>
12
+ </template>
@@ -0,0 +1,39 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import {
3
+ AvailableLanguages,
4
+ AvailableVersions,
5
+ DocToc,
6
+ PageReference,
7
+ PdfUrl,
8
+ SelectedNavigationItem,
9
+ SelectedLanguage,
10
+ SelectedVersion
11
+ } from "typings/custom";
12
+
13
+ export default class Nav extends LightningElement {
14
+ @api availableLanguages!: AvailableLanguages;
15
+ @api selectedLanguage!: SelectedLanguage;
16
+ @api availableVersions!: AvailableVersions;
17
+ @api selectedVersion!: SelectedVersion;
18
+ @api selectedNavigationItem!: SelectedNavigationItem;
19
+ @api pdfUrl!: PdfUrl;
20
+ @api toc!: DocToc;
21
+ @api pageReference!: PageReference;
22
+
23
+ handleSelected(event: CustomEvent) {
24
+ event.stopPropagation();
25
+ const newPageReference = { ...this.pageReference };
26
+ const target = event.detail.name.split("-");
27
+ newPageReference.contentDocumentId = target[0] + ".htm";
28
+ newPageReference.hash = target[1];
29
+ this.dispatchEvent(
30
+ new CustomEvent("navclick", {
31
+ detail: {
32
+ pageReference: newPageReference
33
+ },
34
+ bubbles: true,
35
+ composed: true
36
+ })
37
+ );
38
+ }
39
+ }
@@ -0,0 +1,55 @@
1
+ @import "dxHelpers/reset";
2
+ @import "dxHelpers/text";
3
+ @import "docHelpers/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,28 @@
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">
11
+ {docPhaseTitle}
12
+ </p>
13
+ <dx-button
14
+ variant="inline"
15
+ onclick={onButtonClick}
16
+ aria-label={hideBodyText}
17
+ >
18
+ {hideBodyText}
19
+ </dx-button>
20
+ </div>
21
+ <!--
22
+ NOTE: Here we are rendering mark up using lwc:dom & innerHTML
23
+ option instead of slots because the html markup will come as a
24
+ property to the component from a configuration
25
+ -->
26
+ <span lwc:dom="manual" class={bodyClassName}></span>
27
+ </div>
28
+ </template>
@@ -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 "dxUtils/normalizers";
6
+
7
+ export default class Phase extends LightningElement {
8
+ _docPhaseInfo: DocPhaseInfo | null = null;
9
+
10
+ isBodyHidden = false;
11
+
12
+ get docPhaseTitle() {
13
+ return this.docPhaseInfo?.title;
14
+ }
15
+
16
+ @api
17
+ get docPhaseInfo(): DocPhaseInfo | null {
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 && this.docPhaseInfo) {
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
+ }