@salesforcedevs/docs-components 0.26.3 → 0.28.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.
- package/lwc.config.json +1 -1
- package/package.json +2 -2
- package/src/modules/doc/heading/heading.css +54 -0
- package/src/modules/doc/heading/heading.html +14 -0
- package/src/modules/doc/heading/heading.ts +65 -0
- package/src/modules/doc/headingAnchor/headingAnchor.css +39 -17
- package/src/modules/doc/headingAnchor/headingAnchor.html +17 -17
- package/src/modules/doc/headingAnchor/headingAnchor.ts +20 -21
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.28.0",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "e7bf549e93170dd173ff7419b302674d0faa0b7a"
|
|
14
14
|
}
|
|
@@ -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-anchor {
|
|
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-anchor {
|
|
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-anchor {
|
|
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-anchor {
|
|
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-anchor title={title} hash={hash}></doc-heading-anchor>
|
|
4
|
+
</h1>
|
|
5
|
+
<h2 class={className} if:true={isAriaLevelTwo}>
|
|
6
|
+
<doc-heading-anchor title={title} hash={hash}></doc-heading-anchor>
|
|
7
|
+
</h2>
|
|
8
|
+
<h3 class={className} if:true={isAriaLevelThree}>
|
|
9
|
+
<doc-heading-anchor title={title} hash={hash}></doc-heading-anchor>
|
|
10
|
+
</h3>
|
|
11
|
+
<h4 class={className} if:true={isAriaLevelFour}>
|
|
12
|
+
<doc-heading-anchor title={title} hash={hash}></doc-heading-anchor>
|
|
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
|
+
}
|
|
@@ -1,33 +1,55 @@
|
|
|
1
1
|
@import "helpers/reset";
|
|
2
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
|
+
}
|
|
12
|
+
|
|
13
|
+
.button-container {
|
|
14
|
+
height: 100%;
|
|
15
|
+
margin-right: calc(var(--dx-g-spacing-xl) - 4px);
|
|
16
|
+
position: relative;
|
|
17
|
+
}
|
|
18
|
+
|
|
3
19
|
button {
|
|
20
|
+
position: absolute;
|
|
21
|
+
bottom: var(--doc-c-heading-anchor-button-bottom);
|
|
22
|
+
left: 0;
|
|
4
23
|
opacity: 0;
|
|
5
24
|
color: rgb(11, 92, 171);
|
|
25
|
+
display: flex;
|
|
26
|
+
justify-content: center;
|
|
27
|
+
align-items: center;
|
|
28
|
+
height: var(--button-size);
|
|
29
|
+
width: var(--button-size);
|
|
30
|
+
border-radius: 4px;
|
|
6
31
|
}
|
|
7
32
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
outline: none;
|
|
33
|
+
dx-icon {
|
|
34
|
+
--dx-c-icon-size: var(--doc-c-heading-anchor-icon-size);
|
|
11
35
|
}
|
|
12
36
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
outline: none;
|
|
37
|
+
span:last-of-type {
|
|
38
|
+
padding-right: var(--dx-g-spacing-xs);
|
|
16
39
|
}
|
|
17
40
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
border: 2px solid rgb(11, 92, 171);
|
|
41
|
+
.nowrap {
|
|
42
|
+
white-space: nowrap;
|
|
21
43
|
}
|
|
22
44
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
width: 32px;
|
|
26
|
-
display: flex;
|
|
27
|
-
justify-content: center;
|
|
28
|
-
align-items: center;
|
|
45
|
+
button:focus {
|
|
46
|
+
box-shadow: 0 0 0 2px rgb(11 92 171);
|
|
29
47
|
}
|
|
30
48
|
|
|
31
|
-
|
|
32
|
-
|
|
49
|
+
button:focus,
|
|
50
|
+
button:hover,
|
|
51
|
+
span:hover dx-tooltip button,
|
|
52
|
+
span:hover ~ span dx-tooltip button {
|
|
53
|
+
opacity: 1;
|
|
54
|
+
outline: none;
|
|
33
55
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
>
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
</
|
|
17
|
-
</
|
|
18
|
-
</
|
|
2
|
+
<template if:false={hash}>{title}</template>
|
|
3
|
+
<template if:true={hash}>
|
|
4
|
+
<template if:true={needsSpace}>
|
|
5
|
+
<span>{titleToWrap}</span>
|
|
6
|
+
<span> </span>
|
|
7
|
+
</template>
|
|
8
|
+
<span class="nowrap">
|
|
9
|
+
{titleNoWrap}
|
|
10
|
+
<dx-tooltip placement="top" label={label}>
|
|
11
|
+
<span class="button-container">
|
|
12
|
+
<button onclick={copy} aria-label="copy">
|
|
13
|
+
<dx-icon size="override" symbol="link"></dx-icon>
|
|
14
|
+
</button>
|
|
15
|
+
</span>
|
|
16
|
+
</dx-tooltip>
|
|
17
|
+
</span>
|
|
18
|
+
</template>
|
|
19
19
|
</template>
|
|
@@ -1,43 +1,42 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
|
-
import { IconSprite, IconSize, IconSymbol } from "typings/custom";
|
|
3
2
|
|
|
4
3
|
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
4
|
@api title: string = "";
|
|
10
|
-
@api
|
|
5
|
+
@api hash: string | null = null;
|
|
11
6
|
|
|
12
7
|
label: string = "Copy link to clipboard";
|
|
8
|
+
timeout: number | null = null;
|
|
13
9
|
|
|
14
|
-
private
|
|
15
|
-
|
|
10
|
+
private get titleToWrap() {
|
|
11
|
+
return this.title.substring(0, this.title.lastIndexOf(" "));
|
|
16
12
|
}
|
|
17
13
|
|
|
18
|
-
private
|
|
14
|
+
private get needsSpace() {
|
|
15
|
+
return this.titleToWrap.length > 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private get titleNoWrap() {
|
|
19
|
+
return this.title.substring(this.title.lastIndexOf(" ") + 1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private async copy() {
|
|
23
|
+
if (this.timeout) {
|
|
24
|
+
window.clearTimeout(this.timeout);
|
|
25
|
+
}
|
|
26
|
+
|
|
19
27
|
this.label = "Copied";
|
|
20
|
-
setTimeout(() => {
|
|
28
|
+
this.timeout = window.setTimeout(() => {
|
|
21
29
|
this.label = "Copy link to clipboard";
|
|
22
30
|
}, 2000);
|
|
23
31
|
|
|
24
32
|
try {
|
|
25
|
-
if (this.title && this.
|
|
33
|
+
if (this.title && this.hash) {
|
|
26
34
|
const [hostUrl] = window.location.href.split("#");
|
|
27
|
-
const url = `${hostUrl}#${this.
|
|
35
|
+
const url = `${hostUrl}#${this.hash}`;
|
|
28
36
|
await navigator.clipboard.writeText(url);
|
|
29
37
|
}
|
|
30
38
|
} catch (error) {
|
|
31
39
|
console.error(error);
|
|
32
40
|
}
|
|
33
41
|
}
|
|
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
42
|
}
|