@salesforcedevs/docs-components 0.17.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 CHANGED
@@ -8,6 +8,7 @@
8
8
  "doc/contentMedia",
9
9
  "doc/content",
10
10
  "doc/header",
11
- "doc/headingAnchor"
11
+ "doc/headingAnchor",
12
+ "doc/phase"
12
13
  ]
13
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "0.17.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": "b7a26c9e46cee9298b3ebc7cbea85930320b83a0"
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
@@ -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
+ }