@salesforcedevs/dx-components 0.55.3-alpha-2 → 0.55.7
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/LICENSE +12 -0
- package/package.json +4 -6
- package/src/modules/dx/header/header.html +0 -1
- package/src/modules/dx/logo/logo.ts +1 -1
- package/src/modules/dxUtils/normalizers/normalizers.ts +3 -2
- package/src/assets/svg/login-widget-bg.png +0 -0
- package/src/modules/dx/avatarButton/avatarButton.css +0 -128
- package/src/modules/dx/avatarButton/avatarButton.html +0 -148
- package/src/modules/dx/avatarButton/avatarButton.ts +0 -99
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
+
|
|
8
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
+
|
|
10
|
+
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
+
|
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "0.55.
|
|
3
|
+
"version": "0.55.7",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -16,16 +16,14 @@
|
|
|
16
16
|
"@vimeo/player": "^2.16.4",
|
|
17
17
|
"classnames": "^2.2.6",
|
|
18
18
|
"debounce": "^1.2.0",
|
|
19
|
-
"js-cookie": "^3.0.1",
|
|
20
19
|
"lodash.get": "^4.4.2",
|
|
21
|
-
"microtip": "0.2.2"
|
|
22
|
-
"salesforce-oauth2": "^0.2.0"
|
|
20
|
+
"microtip": "0.2.2"
|
|
23
21
|
},
|
|
24
22
|
"devDependencies": {
|
|
25
23
|
"@types/classnames": "^2.2.10",
|
|
26
24
|
"@types/debounce": "^1.2.0",
|
|
27
|
-
"@types/js-cookie": "^3.0.2",
|
|
28
25
|
"@types/lodash.get": "^4.4.6",
|
|
29
26
|
"@types/vimeo__player": "^2.16.2"
|
|
30
|
-
}
|
|
27
|
+
},
|
|
28
|
+
"gitHead": "91a0fb158be75ba597dc240fce61784cd0cb74af"
|
|
31
29
|
}
|
|
@@ -3,6 +3,6 @@ import { LightningElement, api } from "lwc";
|
|
|
3
3
|
export default class Logo extends LightningElement {
|
|
4
4
|
@api href: string = "/";
|
|
5
5
|
@api imgSrc: string = "/assets/svg/salesforce-cloud.svg";
|
|
6
|
-
@api imgAlt: string = "Salesforce
|
|
6
|
+
@api imgAlt: string = "Salesforce log";
|
|
7
7
|
@api label!: string;
|
|
8
8
|
}
|
|
@@ -67,8 +67,9 @@ export const normalizePost = ({
|
|
|
67
67
|
title
|
|
68
68
|
});
|
|
69
69
|
|
|
70
|
-
export const normalizeBoolean = (
|
|
71
|
-
|
|
70
|
+
export const normalizeBoolean = (
|
|
71
|
+
value: string | boolean | number | undefined
|
|
72
|
+
): boolean => (typeof value === "string" ? value === "true" : !!value);
|
|
72
73
|
|
|
73
74
|
/**
|
|
74
75
|
* Cleans characters that are invalid for DOM IDs
|
|
Binary file
|
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
}
|
|
9
|
-
|
|
10
|
-
.avatar {
|
|
11
|
-
border-radius: 100%;
|
|
12
|
-
border: 2px solid #0d9dda;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.avatar.avatar-small {
|
|
16
|
-
width: var(--dx-g-spacing-lg);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.avatar.avatar-medium {
|
|
20
|
-
margin-bottom: 14px;
|
|
21
|
-
width: var(--dx-g-spacing-2xl);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.login-control {
|
|
25
|
-
background: var(--dx-g-cloud-blue-vibrant-90);
|
|
26
|
-
border-color: var(--dx-g-cloud-blue-vibrant-90);
|
|
27
|
-
border-radius: 50%;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.login-container {
|
|
31
|
-
padding: 16px;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.login-container.logged-in {
|
|
35
|
-
padding-top: 68px;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.header-img {
|
|
39
|
-
left: 0;
|
|
40
|
-
position: absolute;
|
|
41
|
-
top: 0;
|
|
42
|
-
width: 100%;
|
|
43
|
-
z-index: -1;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.heading {
|
|
47
|
-
color: var(--dx-g-blue-vibrant-20);
|
|
48
|
-
display: block;
|
|
49
|
-
font-family: var(--dx-g-font-display);
|
|
50
|
-
font-size: var(--dx-g-text-lg);
|
|
51
|
-
line-height: 28px;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.sub-heading {
|
|
55
|
-
color: var(--dx-g-blue-vibrant-20);
|
|
56
|
-
display: block;
|
|
57
|
-
font-family: var(--dx-g-font-sans);
|
|
58
|
-
font-size: 12px;
|
|
59
|
-
line-height: 18px;
|
|
60
|
-
padding: 8px 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
ul {
|
|
64
|
-
list-style: none;
|
|
65
|
-
margin: 0;
|
|
66
|
-
padding: 0;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
.login-list-item {
|
|
70
|
-
padding-bottom: 10px;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.login-section ~ .login-section {
|
|
74
|
-
border-top: 1px solid var(--dx-g-gray-90);
|
|
75
|
-
margin-top: 12px;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.login-section-title {
|
|
79
|
-
color: var(--dx-g-gray-30);
|
|
80
|
-
display: inline-block;
|
|
81
|
-
font-family: var(--dx-g-font-sans);
|
|
82
|
-
font-size: 14px;
|
|
83
|
-
line-height: 20px;
|
|
84
|
-
padding: 20px 0 12px;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.login-link {
|
|
88
|
-
color: var(--dx-g-blue-vibrant-20);
|
|
89
|
-
display: block;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.login-link-label {
|
|
93
|
-
display: inline-block;
|
|
94
|
-
font-family: var(--dx-g-font-display);
|
|
95
|
-
font-size: 16px;
|
|
96
|
-
line-height: 24px;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.login-link-img {
|
|
100
|
-
display: inline-block;
|
|
101
|
-
height: 16px;
|
|
102
|
-
margin-left: 6px;
|
|
103
|
-
vertical-align: middle;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.login-link-icon {
|
|
107
|
-
display: inline-block;
|
|
108
|
-
margin-left: 6px;
|
|
109
|
-
vertical-align: baseline;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.login-link-blurb {
|
|
113
|
-
font-family: var(--dx-g-font-sans);
|
|
114
|
-
font-size: 14px;
|
|
115
|
-
line-height: 20px;
|
|
116
|
-
padding-top: 4px;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
.heading-links {
|
|
120
|
-
color: var(--dx-g-gray-90);
|
|
121
|
-
font-family: var(--dx-g-font-sans);
|
|
122
|
-
font-size: 14px;
|
|
123
|
-
line-height: 20px;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
a.inline-link {
|
|
127
|
-
color: var(--dx-g-blue-vibrant-50);
|
|
128
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div if:true={isLoggedIn}>
|
|
3
|
-
<dx-popover offset="small" width="320px" open-on-hover>
|
|
4
|
-
<img
|
|
5
|
-
slot="control"
|
|
6
|
-
src={userInfo.avatarImgSrc}
|
|
7
|
-
class="avatar avatar-small"
|
|
8
|
-
/>
|
|
9
|
-
<div slot="content">
|
|
10
|
-
<div class="login-container logged-in">
|
|
11
|
-
<img src="/assets/svg/login-widget-bg.png" class="header-img" />
|
|
12
|
-
<img
|
|
13
|
-
src={userInfo.avatarImgSrc}
|
|
14
|
-
class="avatar avatar-medium"
|
|
15
|
-
/>
|
|
16
|
-
<span class="heading">{userInfo.fullName}</span>
|
|
17
|
-
<span class="sub-heading">{userInfo.username}</span>
|
|
18
|
-
<div class="heading-links">
|
|
19
|
-
<!--
|
|
20
|
-
<a href="#" class="inline-link">Switch account</a>
|
|
21
|
-
|
|
|
22
|
-
-->
|
|
23
|
-
<a href={logoutUrl} class="inline-link">Logout</a>
|
|
24
|
-
</div>
|
|
25
|
-
<div class="login-section">
|
|
26
|
-
<span class="login-section-title">Trailblazer.me</span>
|
|
27
|
-
<ul>
|
|
28
|
-
<li class="login-list-item">
|
|
29
|
-
<a href={settingsUrl} class="login-link">
|
|
30
|
-
<span class="login-link-label">
|
|
31
|
-
Settings
|
|
32
|
-
</span>
|
|
33
|
-
<dx-icon
|
|
34
|
-
class="login-link-icon"
|
|
35
|
-
symbol="new_window"
|
|
36
|
-
size="xsmall"
|
|
37
|
-
></dx-icon>
|
|
38
|
-
</a>
|
|
39
|
-
</li>
|
|
40
|
-
<li class="login-list-item">
|
|
41
|
-
<a href={profileUrl} class="login-link">
|
|
42
|
-
<span class="login-link-label">
|
|
43
|
-
Profile
|
|
44
|
-
</span>
|
|
45
|
-
<dx-icon
|
|
46
|
-
class="login-link-icon"
|
|
47
|
-
symbol="new_window"
|
|
48
|
-
size="xsmall"
|
|
49
|
-
></dx-icon>
|
|
50
|
-
</a>
|
|
51
|
-
</li>
|
|
52
|
-
<li class="login-list-item">
|
|
53
|
-
<a href="#" class="login-link">
|
|
54
|
-
<span class="login-link-label">
|
|
55
|
-
Developer Forums
|
|
56
|
-
</span>
|
|
57
|
-
<dx-icon
|
|
58
|
-
class="login-link-icon"
|
|
59
|
-
symbol="new_window"
|
|
60
|
-
size="xsmall"
|
|
61
|
-
></dx-icon>
|
|
62
|
-
</a>
|
|
63
|
-
<div class="login-link-blurb">
|
|
64
|
-
Our Developer Forums have a new home!
|
|
65
|
-
<a href="#" class="inline-link">
|
|
66
|
-
Learn more
|
|
67
|
-
</a>
|
|
68
|
-
</div>
|
|
69
|
-
</li>
|
|
70
|
-
</ul>
|
|
71
|
-
</div>
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
</dx-popover>
|
|
75
|
-
</div>
|
|
76
|
-
<div if:false={isLoggedIn}>
|
|
77
|
-
<dx-popover offset="small" width="320px" open-on-hover>
|
|
78
|
-
<dx-button
|
|
79
|
-
slot="control"
|
|
80
|
-
class="login-control"
|
|
81
|
-
icon-symbol="user"
|
|
82
|
-
icon-position="left"
|
|
83
|
-
loading={isLoading}
|
|
84
|
-
variant="custom"
|
|
85
|
-
>
|
|
86
|
-
Login
|
|
87
|
-
</dx-button>
|
|
88
|
-
<div slot="content">
|
|
89
|
-
<div class="login-container">
|
|
90
|
-
<span class="heading">Login</span>
|
|
91
|
-
<div class="login-section">
|
|
92
|
-
<span class="login-section-title">Products</span>
|
|
93
|
-
<ul>
|
|
94
|
-
<li class="login-list-item">
|
|
95
|
-
<a href="#" class="login-link">
|
|
96
|
-
<span class="login-link-label">
|
|
97
|
-
Salesforce
|
|
98
|
-
</span>
|
|
99
|
-
<img
|
|
100
|
-
class="login-link-img"
|
|
101
|
-
src="/assets/svg/salesforce-cloud.svg"
|
|
102
|
-
alt="Salesforce logo"
|
|
103
|
-
/>
|
|
104
|
-
<dx-icon
|
|
105
|
-
class="login-link-icon"
|
|
106
|
-
symbol="new_window"
|
|
107
|
-
size="xsmall"
|
|
108
|
-
></dx-icon>
|
|
109
|
-
</a>
|
|
110
|
-
</li>
|
|
111
|
-
<li class="login-list-item">
|
|
112
|
-
<a href="#" class="login-link">
|
|
113
|
-
<span class="login-link-label">
|
|
114
|
-
Marketing Cloud
|
|
115
|
-
</span>
|
|
116
|
-
<dx-icon
|
|
117
|
-
class="login-link-icon"
|
|
118
|
-
symbol="new_window"
|
|
119
|
-
size="xsmall"
|
|
120
|
-
></dx-icon>
|
|
121
|
-
</a>
|
|
122
|
-
</li>
|
|
123
|
-
</ul>
|
|
124
|
-
</div>
|
|
125
|
-
<div class="login-section">
|
|
126
|
-
<span class="login-section-title">
|
|
127
|
-
Community & Resources
|
|
128
|
-
</span>
|
|
129
|
-
<ul>
|
|
130
|
-
<li class="login-list-item">
|
|
131
|
-
<a href={loginUrl} class="login-link">
|
|
132
|
-
<span class="login-link-label">
|
|
133
|
-
Trailblazer.me
|
|
134
|
-
</span>
|
|
135
|
-
</a>
|
|
136
|
-
<div class="login-link-blurb">
|
|
137
|
-
Login into access a rich community of
|
|
138
|
-
Salesforce Developers, get ideas, and find
|
|
139
|
-
solutions.
|
|
140
|
-
</div>
|
|
141
|
-
</li>
|
|
142
|
-
</ul>
|
|
143
|
-
</div>
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
146
|
-
</dx-popover>
|
|
147
|
-
</div>
|
|
148
|
-
</template>
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { api, LightningElement } from "lwc";
|
|
2
|
-
import Cookie from "js-cookie";
|
|
3
|
-
|
|
4
|
-
const TBID_BASE_URL = "https://dev1-trailblazer-identity.cs192.force.com";
|
|
5
|
-
const TBID_LOGIN_URL = "https://development.developer.salesforce.com/tbid/dologin";
|
|
6
|
-
const TBID_LOGOUT_URL = `${TBID_BASE_URL}/services/auth/idp/oidc/logout`;
|
|
7
|
-
const TBID_USERINFO_URL = `${TBID_BASE_URL}/services/oauth2/userinfo`;
|
|
8
|
-
|
|
9
|
-
export interface UserInfo {
|
|
10
|
-
avatarImgSrc?: string;
|
|
11
|
-
firstName?: string;
|
|
12
|
-
lastName?: string;
|
|
13
|
-
username?: string;
|
|
14
|
-
readonly fullName: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default class AvatarButton extends LightningElement {
|
|
18
|
-
@api size: "small" | "medium" | "large" = "medium";
|
|
19
|
-
|
|
20
|
-
private userInfo: UserInfo = {
|
|
21
|
-
get fullName() {
|
|
22
|
-
if (this.firstName && this.lastName) {
|
|
23
|
-
return `${this.firstName} ${this.lastName}`;
|
|
24
|
-
}
|
|
25
|
-
return this.firstName || this.lastName || "";
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
private isLoading = false;
|
|
29
|
-
private settingsUrl = `${TBID_BASE_URL}/settings`;
|
|
30
|
-
private profileUrl = `${TBID_BASE_URL}/id`;
|
|
31
|
-
private loginUrl = TBID_LOGIN_URL;
|
|
32
|
-
private logoutUrl = TBID_LOGOUT_URL;
|
|
33
|
-
|
|
34
|
-
// A user only counts as logged in for our purposes if they have an access token
|
|
35
|
-
// and we have successfully used it to get their info.
|
|
36
|
-
private get isLoggedIn() {
|
|
37
|
-
return Boolean(this._tbidAccessToken) && this._didReceiveUserInfo;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
private _didReceiveUserInfo = false;
|
|
41
|
-
private _tbidAccessToken: string | undefined;
|
|
42
|
-
|
|
43
|
-
connectedCallback() {
|
|
44
|
-
this._tbidAccessToken = Cookie.get("TBID");
|
|
45
|
-
|
|
46
|
-
if (this._tbidAccessToken) {
|
|
47
|
-
this.requestUserInfo(this._tbidAccessToken);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
private updateAvatarWithUserInfo(userInfo: any) {
|
|
52
|
-
if (!userInfo) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
this.userInfo.avatarImgSrc = userInfo.photos?.thumbnail;
|
|
57
|
-
this.userInfo.firstName = userInfo.given_name;
|
|
58
|
-
this.userInfo.lastName = userInfo.family_name;
|
|
59
|
-
this.userInfo.username = userInfo.preferred_username;
|
|
60
|
-
// TODO: Consider displaying initials if no photo. Is there always a photo?
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private async requestUserInfo(accessToken: string) {
|
|
64
|
-
this.isLoading = true;
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
// FIXME: The TBID userinfo currently only accepts the access token in the URL
|
|
68
|
-
// as a query parameter. This is bad, but they're aware of it, and when it is
|
|
69
|
-
// fixed, we should use a header or something instead.
|
|
70
|
-
const userInfoRes = await fetch(
|
|
71
|
-
TBID_USERINFO_URL +
|
|
72
|
-
"?access_token=" +
|
|
73
|
-
encodeURIComponent(accessToken)
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
if (userInfoRes.ok) {
|
|
77
|
-
const userInfo = await userInfoRes.json();
|
|
78
|
-
this.updateAvatarWithUserInfo(userInfo);
|
|
79
|
-
this._didReceiveUserInfo = true;
|
|
80
|
-
} else {
|
|
81
|
-
if (userInfoRes.status === 403) {
|
|
82
|
-
const refreshToken = Cookie.get('TBID_REFRESH');
|
|
83
|
-
if (refreshToken) {
|
|
84
|
-
console.log('Would use refresh token');
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// TODO: Do we want a "something went wrong" state here?
|
|
88
|
-
}
|
|
89
|
-
} catch (ex) {
|
|
90
|
-
// TODO: Something not directly related to auth went wrong. Unsure what to do here.
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
this.isLoading = false;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// private refreshAccessToken(refreshToken);
|
|
97
|
-
|
|
98
|
-
// private handleAuthFailure() {}
|
|
99
|
-
}
|