@salesforcedevs/dw-components 1.2.4 → 1.2.5-canary.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 -0
- package/package.json +2 -3
- package/src/modules/dw/avatarButton/avatarButton.css +119 -0
- package/src/modules/dw/avatarButton/avatarButton.html +150 -0
- package/src/modules/dw/avatarButton/avatarButton.ts +159 -0
- package/src/modules/dw/searchResults/coveo.css +18989 -0
- package/LICENSE +0 -12
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dw-components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5-canary.0",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -21,6 +21,5 @@
|
|
|
21
21
|
"@types/lodash.clonedeep": "^4.5.7",
|
|
22
22
|
"@types/lodash.orderby": "^4.6.7",
|
|
23
23
|
"@types/lodash.uniqby": "^4.7.7"
|
|
24
|
-
}
|
|
25
|
-
"gitHead": "66a0421aca28936a5556a9311aa14b8f175fb02c"
|
|
24
|
+
}
|
|
26
25
|
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
--dx-c-button-custom-color: var(--dx-g-blue-vibrant-50);
|
|
3
|
+
--dx-c-button-custom-background: transparent;
|
|
4
|
+
--dx-c-button-custom-border: 1px solid transparent;
|
|
5
|
+
--dx-c-button-custom-color-hover: var(--dx-g-blue-vibrant-50);
|
|
6
|
+
--dx-c-button-custom-background-hover: var(--dx-g-cloud-blue-vibrant-90);
|
|
7
|
+
--dx-c-button-custom-border-hover: var(--dx-g-cloud-blue-vibrant-90);
|
|
8
|
+
--dx-c-slot-empty-width: max-content;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.avatar {
|
|
12
|
+
border-radius: 100%;
|
|
13
|
+
border: 2px solid #0d9dda;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.avatar.avatar-medium {
|
|
17
|
+
margin-bottom: 14px;
|
|
18
|
+
width: var(--dx-g-spacing-2xl);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.login-container {
|
|
22
|
+
padding: 16px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.login-container.logged-in {
|
|
26
|
+
padding-top: 68px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.header-img {
|
|
30
|
+
left: 0;
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: 0;
|
|
33
|
+
width: 100%;
|
|
34
|
+
z-index: -1;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.heading {
|
|
38
|
+
color: var(--dx-g-blue-vibrant-20);
|
|
39
|
+
display: block;
|
|
40
|
+
font-family: var(--dx-g-font-display);
|
|
41
|
+
font-size: var(--dx-g-text-lg);
|
|
42
|
+
line-height: 28px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.sub-heading {
|
|
46
|
+
color: var(--dx-g-blue-vibrant-20);
|
|
47
|
+
display: block;
|
|
48
|
+
font-family: var(--dx-g-font-sans);
|
|
49
|
+
font-size: 12px;
|
|
50
|
+
line-height: 18px;
|
|
51
|
+
padding: 8px 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ul {
|
|
55
|
+
list-style: none;
|
|
56
|
+
margin: 0;
|
|
57
|
+
padding: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.login-list-item {
|
|
61
|
+
padding-bottom: 10px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.login-section ~ .login-section {
|
|
65
|
+
border-top: 1px solid var(--dx-g-gray-90);
|
|
66
|
+
margin-top: 12px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.login-section-title {
|
|
70
|
+
color: var(--dx-g-gray-30);
|
|
71
|
+
display: inline-block;
|
|
72
|
+
font-family: var(--dx-g-font-sans);
|
|
73
|
+
font-size: 14px;
|
|
74
|
+
line-height: 20px;
|
|
75
|
+
padding: 20px 0 12px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.login-link {
|
|
79
|
+
color: var(--dx-g-blue-vibrant-20);
|
|
80
|
+
display: block;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.login-link-label {
|
|
84
|
+
display: inline-block;
|
|
85
|
+
font-family: var(--dx-g-font-display);
|
|
86
|
+
font-size: 16px;
|
|
87
|
+
line-height: 24px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.login-link-img {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
height: 16px;
|
|
93
|
+
margin-left: 6px;
|
|
94
|
+
vertical-align: middle;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.login-link-icon {
|
|
98
|
+
display: inline-block;
|
|
99
|
+
margin-left: 6px;
|
|
100
|
+
vertical-align: baseline;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.login-link-blurb {
|
|
104
|
+
font-family: var(--dx-g-font-sans);
|
|
105
|
+
font-size: 14px;
|
|
106
|
+
line-height: 20px;
|
|
107
|
+
padding-top: 4px;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.heading-links {
|
|
111
|
+
color: var(--dx-g-gray-90);
|
|
112
|
+
font-family: var(--dx-g-font-sans);
|
|
113
|
+
font-size: 14px;
|
|
114
|
+
line-height: 20px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
a.inline-link {
|
|
118
|
+
color: var(--dx-g-blue-vibrant-50);
|
|
119
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<dx-tbid-avatar-button
|
|
3
|
+
tbid-base-url={tbidBaseUrl}
|
|
4
|
+
tbid-api-base-url={tbidApiBaseUrl}
|
|
5
|
+
ontbiduserinfo={handleTbidUserInfo}
|
|
6
|
+
ontbidloginsuccess={handleTbidLoginSuccess}
|
|
7
|
+
ontbidlogoutsuccess={handleTbidLogoutSuccess}
|
|
8
|
+
>
|
|
9
|
+
<div slot="popover-content">
|
|
10
|
+
<div if:true={isLoggedIn}>
|
|
11
|
+
<div class="login-container logged-in">
|
|
12
|
+
<img
|
|
13
|
+
src="/assets/svg/login-widget-bg.png"
|
|
14
|
+
class="header-img"
|
|
15
|
+
/>
|
|
16
|
+
<img
|
|
17
|
+
src={userInfo.avatarImgSrc}
|
|
18
|
+
class="avatar avatar-medium"
|
|
19
|
+
/>
|
|
20
|
+
<span class="heading">{userInfo.fullName}</span>
|
|
21
|
+
<span class="sub-heading">{userInfo.username}</span>
|
|
22
|
+
<div class="heading-links">
|
|
23
|
+
<a
|
|
24
|
+
href="#"
|
|
25
|
+
onclick={handleComponentLogoutClick}
|
|
26
|
+
class="inline-link"
|
|
27
|
+
>
|
|
28
|
+
Logout
|
|
29
|
+
</a>
|
|
30
|
+
</div>
|
|
31
|
+
<div class="login-section">
|
|
32
|
+
<span class="login-section-title">Trailblazer.me</span>
|
|
33
|
+
<ul>
|
|
34
|
+
<li class="login-list-item">
|
|
35
|
+
<a href={settingsUrl} class="login-link" target="_blank" onclick={trackLoggedInMenuClick}>
|
|
36
|
+
<span class="login-link-label">
|
|
37
|
+
Settings
|
|
38
|
+
</span>
|
|
39
|
+
<dx-icon
|
|
40
|
+
class="login-link-icon"
|
|
41
|
+
symbol="new_window"
|
|
42
|
+
size="xsmall"
|
|
43
|
+
></dx-icon>
|
|
44
|
+
</a>
|
|
45
|
+
</li>
|
|
46
|
+
<li class="login-list-item">
|
|
47
|
+
<a href={profileUrl} class="login-link" target="_blank" onclick={trackLoggedInMenuClick}>
|
|
48
|
+
<span class="login-link-label">
|
|
49
|
+
Profile
|
|
50
|
+
</span>
|
|
51
|
+
<dx-icon
|
|
52
|
+
class="login-link-icon"
|
|
53
|
+
symbol="new_window"
|
|
54
|
+
size="xsmall"
|
|
55
|
+
></dx-icon>
|
|
56
|
+
</a>
|
|
57
|
+
</li>
|
|
58
|
+
<li class="login-list-item">
|
|
59
|
+
<a href="https://trailhead.salesforce.com/trailblazer-community/groups/0F93A000000DJbJSAW" class="login-link" target="_blank" onclick={trackLoggedInMenuClick}>
|
|
60
|
+
<span class="login-link-label">
|
|
61
|
+
Developer Community
|
|
62
|
+
</span>
|
|
63
|
+
<dx-icon
|
|
64
|
+
class="login-link-icon"
|
|
65
|
+
symbol="new_window"
|
|
66
|
+
size="xsmall"
|
|
67
|
+
></dx-icon>
|
|
68
|
+
</a>
|
|
69
|
+
<div class="login-link-blurb">
|
|
70
|
+
Collaborate, network, build connections
|
|
71
|
+
and learn Salesforce development.
|
|
72
|
+
</div>
|
|
73
|
+
</li>
|
|
74
|
+
</ul>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
<div if:false={isLoggedIn}>
|
|
79
|
+
<div class="login-container">
|
|
80
|
+
<span class="heading">Login</span>
|
|
81
|
+
<div class="login-section">
|
|
82
|
+
<span class="login-section-title">Products</span>
|
|
83
|
+
<ul>
|
|
84
|
+
<li class="login-list-item">
|
|
85
|
+
<a href="https://www.salesforce.com" class="login-link" target="_blank" onclick={trackLoginMenuClick}>
|
|
86
|
+
<span class="login-link-label">
|
|
87
|
+
Salesforce
|
|
88
|
+
</span>
|
|
89
|
+
<img
|
|
90
|
+
class="login-link-img"
|
|
91
|
+
src="/assets/svg/salesforce-cloud.svg"
|
|
92
|
+
alt="Salesforce logo"
|
|
93
|
+
/>
|
|
94
|
+
<dx-icon
|
|
95
|
+
class="login-link-icon"
|
|
96
|
+
symbol="new_window"
|
|
97
|
+
size="xsmall"
|
|
98
|
+
></dx-icon>
|
|
99
|
+
</a>
|
|
100
|
+
</li>
|
|
101
|
+
<li class="login-list-item">
|
|
102
|
+
<a href={marketingCloudUrl} class="login-link" target="_blank" onclick={trackLoginMenuClick}>
|
|
103
|
+
<span class="login-link-label">
|
|
104
|
+
Marketing Cloud
|
|
105
|
+
</span>
|
|
106
|
+
<dx-icon
|
|
107
|
+
class="login-link-icon"
|
|
108
|
+
symbol="new_window"
|
|
109
|
+
size="xsmall"
|
|
110
|
+
></dx-icon>
|
|
111
|
+
</a>
|
|
112
|
+
</li>
|
|
113
|
+
</ul>
|
|
114
|
+
</div>
|
|
115
|
+
<div class="login-section">
|
|
116
|
+
<span class="login-section-title">
|
|
117
|
+
Salesforce Developers
|
|
118
|
+
</span>
|
|
119
|
+
<ul>
|
|
120
|
+
<li class="login-list-item">
|
|
121
|
+
<a href={loginUrl} class="login-link" onclick={handleComponentLoginClick}>
|
|
122
|
+
<span class="login-link-label">
|
|
123
|
+
Trailblazer.me
|
|
124
|
+
</span>
|
|
125
|
+
</a>
|
|
126
|
+
<div class="login-link-blurb">
|
|
127
|
+
Login into access a rich community of
|
|
128
|
+
Salesforce Developers, get ideas, and find
|
|
129
|
+
solutions.
|
|
130
|
+
</div>
|
|
131
|
+
</li>
|
|
132
|
+
<li class="login-list-item">
|
|
133
|
+
<a href="https://developer.salesforce.com/forums" class="login-link" target="_blank" onclick={trackLoginMenuClick}>
|
|
134
|
+
<span class="login-link-label">
|
|
135
|
+
Developer Forums
|
|
136
|
+
</span>
|
|
137
|
+
<dx-icon
|
|
138
|
+
class="login-link-icon"
|
|
139
|
+
symbol="new_window"
|
|
140
|
+
size="xsmall"
|
|
141
|
+
></dx-icon>
|
|
142
|
+
</a>
|
|
143
|
+
</li>
|
|
144
|
+
</ul>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
</div>
|
|
149
|
+
</dx-tbid-avatar-button>
|
|
150
|
+
</template>
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { LightningElement } from "lwc";
|
|
2
|
+
import { track } from "dxUtils/analytics";
|
|
3
|
+
|
|
4
|
+
const DSC_BASE_URL = process.env.BASE_URL || "https://developer.salesforce.com";
|
|
5
|
+
|
|
6
|
+
interface UserInfo {
|
|
7
|
+
avatarImgSrc?: string;
|
|
8
|
+
company?: string;
|
|
9
|
+
firstName?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
lastName?: string;
|
|
12
|
+
orgId?: string;
|
|
13
|
+
relationship?: string;
|
|
14
|
+
role?: string;
|
|
15
|
+
username?: string;
|
|
16
|
+
fullName?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const trackableUserInfo = new Set([
|
|
20
|
+
"company",
|
|
21
|
+
"id",
|
|
22
|
+
"orgId",
|
|
23
|
+
"relationship",
|
|
24
|
+
"role"
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
export default class AvatarButton extends LightningElement {
|
|
28
|
+
// URLs:
|
|
29
|
+
// TODO: change these urls when the environment is correct
|
|
30
|
+
private tbidBaseUrl = "https://dev1-trailblazer-identity.cs192.force.com";
|
|
31
|
+
private tbidApiBaseUrl =
|
|
32
|
+
"https://development.developer.salesforce.com/tbid";
|
|
33
|
+
private settingsUrl = `${this.tbidBaseUrl}/settings`;
|
|
34
|
+
private profileUrl = `${this.tbidBaseUrl}/id`;
|
|
35
|
+
private logoutUrl = `${this.tbidApiBaseUrl}/logout`;
|
|
36
|
+
private get marketingCloudUrl() {
|
|
37
|
+
return `${DSC_BASE_URL}/developer-centers/marketing-cloud`;
|
|
38
|
+
}
|
|
39
|
+
private get loginUrl() {
|
|
40
|
+
return `${this.tbidApiBaseUrl}/dologin?startURL=${encodeURIComponent(
|
|
41
|
+
window.location.href
|
|
42
|
+
)}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private isLoggedIn = false;
|
|
46
|
+
private userInfo: UserInfo = {};
|
|
47
|
+
|
|
48
|
+
private handleComponentLogoutClick = () => {
|
|
49
|
+
this.trackLogoutClick();
|
|
50
|
+
this.dispatchComponentLogout();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
private handleComponentLoginClick = () => {
|
|
54
|
+
this.trackLoginClick();
|
|
55
|
+
this.dispatchComponentLogin();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
private handleTbidLoginSuccess = (event: CustomEvent) => {
|
|
59
|
+
event.stopPropagation();
|
|
60
|
+
this.isLoggedIn = true;
|
|
61
|
+
|
|
62
|
+
// Special tracking for this event only
|
|
63
|
+
track(document, "custEv_userLogin", {
|
|
64
|
+
authenticationMethod: "tbid",
|
|
65
|
+
id: {
|
|
66
|
+
tb: Object.entries(this.userInfo)
|
|
67
|
+
.filter(([key]) => trackableUserInfo.has(key))
|
|
68
|
+
.reduce(
|
|
69
|
+
(infoToTrack, [key, value]) => ({
|
|
70
|
+
...infoToTrack,
|
|
71
|
+
[key]: value
|
|
72
|
+
}),
|
|
73
|
+
{} as Record<string, string>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
private handleTbidLogoutSuccess = (event: CustomEvent) => {
|
|
80
|
+
event.stopPropagation();
|
|
81
|
+
this.isLoggedIn = false;
|
|
82
|
+
this.userInfo = {};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
private handleTbidUserInfo = (event: CustomEvent) => {
|
|
86
|
+
event.stopPropagation();
|
|
87
|
+
const { detail } = event;
|
|
88
|
+
if (detail && detail.userInfo) {
|
|
89
|
+
this.userInfo = detail.userInfo;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
private dispatchComponentLogin = () => {
|
|
94
|
+
this.dispatchEvent(new CustomEvent('avatarbuttonloginclick', {
|
|
95
|
+
bubbles: true,
|
|
96
|
+
}));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
private dispatchComponentLogout = () => {
|
|
100
|
+
this.dispatchEvent(new CustomEvent('avatarbuttonlogoutclick', {
|
|
101
|
+
bubbles: true,
|
|
102
|
+
}));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
private trackLoginClick = () => {
|
|
106
|
+
track(document, "custEv_userLogin", {
|
|
107
|
+
clickText: "Trailblazer.me",
|
|
108
|
+
clickUrl: this.loginUrl,
|
|
109
|
+
itemTitle: "TBID Login Link",
|
|
110
|
+
elementType: "link"
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
private trackLogoutClick = () => {
|
|
115
|
+
track(document, "custEv_userLogout", {
|
|
116
|
+
clickText: "Logout",
|
|
117
|
+
clickUrl: this.logoutUrl,
|
|
118
|
+
itemTitle: "TBID Logout Link",
|
|
119
|
+
elementType: "link"
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// Shared utility for tracking link clicks.
|
|
124
|
+
private trackMenuClick = (
|
|
125
|
+
target: HTMLAnchorElement | null,
|
|
126
|
+
eventName: string,
|
|
127
|
+
navItemPrefix: string
|
|
128
|
+
) => {
|
|
129
|
+
const trackingPayload: any = {
|
|
130
|
+
nav_level: "utility",
|
|
131
|
+
nav_type: "global",
|
|
132
|
+
elementType: "link"
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
if (target) {
|
|
136
|
+
trackingPayload.clickText = target.textContent?.trim() || "";
|
|
137
|
+
trackingPayload.clickUrl = target.href;
|
|
138
|
+
const [
|
|
139
|
+
firstWord,
|
|
140
|
+
...remainingText
|
|
141
|
+
] = trackingPayload.clickText.split(" ");
|
|
142
|
+
trackingPayload.nav_item = `${navItemPrefix}${firstWord.toLowerCase()}${remainingText.join()}`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
track(target || document, eventName, trackingPayload);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// Track link clicks on the "logged out" version of the dropdown.
|
|
149
|
+
private trackLoginMenuClick = (event: Event) => {
|
|
150
|
+
const target = event.currentTarget as HTMLAnchorElement | null;
|
|
151
|
+
this.trackMenuClick(target, "custEv_userLogin", "login:salesforce:");
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// Track link clicks on the "logged in" version of the dropdown.
|
|
155
|
+
private trackLoggedInMenuClick = (event: Event) => {
|
|
156
|
+
const target = event.currentTarget as HTMLAnchorElement | null;
|
|
157
|
+
this.trackMenuClick(target, "custEv_loginMenuClick", "login:tbid:");
|
|
158
|
+
};
|
|
159
|
+
}
|