@salesforcedevs/dx-components 0.55.0 → 0.55.3-alpha-2

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 (33) hide show
  1. package/lwc.config.json +3 -0
  2. package/package.json +5 -3
  3. package/src/assets/svg/login-widget-bg.png +0 -0
  4. package/src/modules/dx/avatarButton/avatarButton.css +128 -0
  5. package/src/modules/dx/avatarButton/avatarButton.html +148 -0
  6. package/src/modules/dx/avatarButton/avatarButton.ts +99 -0
  7. package/src/modules/dx/breadcrumbs/breadcrumbs.ts +18 -15
  8. package/src/modules/dx/cardGridDocs/cardGridDocs.css +74 -0
  9. package/src/modules/dx/cardGridDocs/cardGridDocs.html +67 -0
  10. package/src/modules/dx/cardGridDocs/cardGridDocs.ts +86 -0
  11. package/src/modules/dx/dropdown/dropdown.ts +2 -2
  12. package/src/modules/dx/dropdownOption/dropdownOption.ts +2 -2
  13. package/src/modules/dx/featureGrid/featureGrid.html +3 -0
  14. package/src/modules/dx/featureGrid/featureGrid.ts +15 -0
  15. package/src/modules/dx/filterMenu/filterMenu.css +9 -3
  16. package/src/modules/dx/filterMenu/filterMenu.html +31 -28
  17. package/src/modules/dx/filterMenu/filterMenu.ts +14 -4
  18. package/src/modules/dx/footer/footer.ts +2 -2
  19. package/src/modules/dx/grid/grid.ts +3 -1
  20. package/src/modules/dx/header/header.html +1 -0
  21. package/src/modules/dx/header/header.ts +2 -2
  22. package/src/modules/dx/headerMobileNavMenu/headerMobileNavMenu.ts +4 -4
  23. package/src/modules/dx/headerNav/headerNav.ts +5 -5
  24. package/src/modules/dx/headerSearch/headerSearch.ts +2 -2
  25. package/src/modules/dx/logo/logo.ts +1 -1
  26. package/src/modules/dx/select/select.css +181 -8
  27. package/src/modules/dx/select/select.html +51 -54
  28. package/src/modules/dx/select/select.ts +128 -10
  29. package/src/modules/dx/sidebarSearch/sidebarSearch.ts +8 -2
  30. package/src/modules/dxBaseElements/headerBase/headerBase.ts +3 -3
  31. package/src/modules/dxHelpers/scrollbar/scrollbar.css +31 -0
  32. package/src/modules/dxUtils/options/options.ts +13 -9
  33. package/src/modules/dxHelpers/slds/slds.css +0 -191
package/lwc.config.json CHANGED
@@ -12,6 +12,7 @@
12
12
  "dx/cardDocs",
13
13
  "dx/cardEvent",
14
14
  "dx/cardExpanded",
15
+ "dx/cardGridDocs",
15
16
  "dx/cardMinimal",
16
17
  "dx/cardNews",
17
18
  "dx/cardPodcastEpisode",
@@ -26,6 +27,7 @@
26
27
  "dx/dropdown",
27
28
  "dx/emptyState",
28
29
  "dx/feature",
30
+ "dx/featureGrid",
29
31
  "dx/featuredContentHeader",
30
32
  "dx/featuresList",
31
33
  "dx/filterMenu",
@@ -75,6 +77,7 @@
75
77
  "dxHelpers/code",
76
78
  "dxHelpers/commonHeader",
77
79
  "dxHelpers/reset",
80
+ "dxHelpers/scrollbar",
78
81
  "dxHelpers/table",
79
82
  "dxHelpers/text",
80
83
  "dxUtils/analytics",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dx-components",
3
- "version": "0.55.0",
3
+ "version": "0.55.3-alpha-2",
4
4
  "description": "DX Lightning web components",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -16,13 +16,15 @@
16
16
  "@vimeo/player": "^2.16.4",
17
17
  "classnames": "^2.2.6",
18
18
  "debounce": "^1.2.0",
19
- "lightning-base-components": "1.12.3-alpha",
19
+ "js-cookie": "^3.0.1",
20
20
  "lodash.get": "^4.4.2",
21
- "microtip": "0.2.2"
21
+ "microtip": "0.2.2",
22
+ "salesforce-oauth2": "^0.2.0"
22
23
  },
23
24
  "devDependencies": {
24
25
  "@types/classnames": "^2.2.10",
25
26
  "@types/debounce": "^1.2.0",
27
+ "@types/js-cookie": "^3.0.2",
26
28
  "@types/lodash.get": "^4.4.6",
27
29
  "@types/vimeo__player": "^2.16.2"
28
30
  }
@@ -0,0 +1,128 @@
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
+ }
@@ -0,0 +1,148 @@
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
+ &nbsp;&nbsp;|&nbsp;&nbsp;
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!&nbsp;
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>
@@ -0,0 +1,99 @@
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
+ }
@@ -1,6 +1,6 @@
1
1
  import { LightningElement, api } from "lwc";
2
2
  import cx from "classnames";
3
- import { Breadcrumb, Option } from "typings/custom";
3
+ import { Breadcrumb, OptionWithNested } from "typings/custom";
4
4
  import { toJson } from "dxUtils/normalizers";
5
5
 
6
6
  type LabelMap = { [href: string]: string };
@@ -19,7 +19,7 @@ const toLabel = (val: string) => {
19
19
  export default class Breadcrumbs extends LightningElement {
20
20
  @api ariaLabel: string = "Navigation Breadcrumbs";
21
21
  @api baseHref: string = "/";
22
- @api navItems: Option[] = [];
22
+ @api navItems: OptionWithNested[] = [];
23
23
  @api pathname: string = window.location.pathname;
24
24
  @api title: string = "Salesforce";
25
25
  @api logo: boolean = false;
@@ -42,19 +42,22 @@ export default class Breadcrumbs extends LightningElement {
42
42
  private _breadcrumbs!: Breadcrumb[];
43
43
 
44
44
  private get labelMap(): LabelMap {
45
- const deepReducer = (options: Option[]) =>
46
- options.reduce((acc: LabelMap, item: Option): LabelMap => {
47
- if (item.options) {
48
- return { ...acc, ...deepReducer(item.options) };
49
- }
50
- if (!item.link) {
51
- return acc;
52
- }
53
- return {
54
- ...acc,
55
- [item.link.href]: item.label
56
- };
57
- }, {});
45
+ const deepReducer = (options: OptionWithNested[]) =>
46
+ options.reduce(
47
+ (acc: LabelMap, item: OptionWithNested): LabelMap => {
48
+ if (item.options) {
49
+ return { ...acc, ...deepReducer(item.options) };
50
+ }
51
+ if (!item.link) {
52
+ return acc;
53
+ }
54
+ return {
55
+ ...acc,
56
+ [item.link.href]: item.label
57
+ };
58
+ },
59
+ {}
60
+ );
58
61
  return this.navItems ? deepReducer(this.navItems) : {};
59
62
  }
60
63
 
@@ -0,0 +1,74 @@
1
+ .docs-action-bar {
2
+ display: flex;
3
+ justify-content: space-between;
4
+ align-items: flex-end;
5
+ padding: var(--dx-g-spacing-md) 0 var(--dx-g-spacing-lg);
6
+ }
7
+
8
+ .docs-action-bar > .records-container {
9
+ margin-right: auto;
10
+ }
11
+
12
+ .docs-action-bar .filters-container {
13
+ display: flex;
14
+ }
15
+
16
+ .docs-action-bar .filters-container > *:not(:first-child),
17
+ dx-input {
18
+ margin-left: var(--dx-g-spacing-sm);
19
+ }
20
+
21
+ dx-input {
22
+ --dx-c-input-width: 285px;
23
+ }
24
+
25
+ .pagination-container {
26
+ max-width: fit-content;
27
+ max-width: -moz-fit-content;
28
+ margin: var(--dx-g-spacing-lg) auto;
29
+ }
30
+
31
+ @media screen and (max-width: 1024px) {
32
+ dx-card-docs {
33
+ --dx-c-body-max-lines: 3;
34
+ }
35
+ }
36
+
37
+ @media screen and (max-width: 768px) {
38
+ .docs-action-bar {
39
+ flex-direction: column-reverse;
40
+ width: 100%;
41
+ padding: 0;
42
+ }
43
+
44
+ .records-container {
45
+ margin-bottom: var(--dx-g-spacing-md);
46
+ }
47
+
48
+ dx-input {
49
+ --dx-c-input-width: 100%;
50
+
51
+ width: 100%;
52
+ margin-bottom: var(--dx-g-spacing-md);
53
+ }
54
+ }
55
+
56
+ @media screen and (max-width: 600px) {
57
+ .pagination-container {
58
+ width: 100%;
59
+ overflow: hidden;
60
+ }
61
+
62
+ .pagination-container > * {
63
+ position: absolute;
64
+ left: 50%;
65
+ transform: translateX(-50%);
66
+ }
67
+ }
68
+
69
+ @media screen and (max-width: 460px) {
70
+ .docs-action-bar .records-container {
71
+ transform: initial;
72
+ padding: var(--dx-g-spacing-md) 0;
73
+ }
74
+ }
@@ -0,0 +1,67 @@
1
+ <template>
2
+ <div class="card-grid">
3
+ <div class="docs-action-bar">
4
+ <div class="records-container">
5
+ <span if:true={endingRecord}>
6
+ Showing { startingRecord } to { endingRecord } of {
7
+ cards.length }
8
+ </span>
9
+ </div>
10
+ <div class="filters-container">
11
+ <slot name="filters"></slot>
12
+ </div>
13
+ <dx-input
14
+ size="small"
15
+ placeholder="Search..."
16
+ icon-symbol="search"
17
+ shortcut-key="j"
18
+ class="docs-search-input"
19
+ onchange={onSearchChange}
20
+ value={value}
21
+ ></dx-input>
22
+ </div>
23
+ <dx-grid columns="four">
24
+ <template for:each={currentPageCards} for:item="card">
25
+ <dx-card-docs
26
+ key={card.title}
27
+ body={card.body}
28
+ href={card.href}
29
+ img-alt={card.imgAlt}
30
+ img-src={card.imgSrc}
31
+ label={card.label}
32
+ title={card.title}
33
+ target={card.target}
34
+ show-mobile-img={card.showMobileImg}
35
+ >
36
+ <template
37
+ if:true={card.links}
38
+ for:each={card.links}
39
+ for:item="link"
40
+ >
41
+ <dx-button
42
+ key={link.title}
43
+ href={link.href}
44
+ variant="inline"
45
+ >
46
+ { link.title }
47
+ </dx-button>
48
+ </template>
49
+ </dx-card-docs>
50
+ </template>
51
+ </dx-grid>
52
+ <div class="pagination-container" if:false={showEmptyState}>
53
+ <dx-pagination
54
+ current-page={page}
55
+ total-pages={totalPages}
56
+ pages-to-show="5"
57
+ onpagechange={goToPage}
58
+ if:false={hidePagination}
59
+ ></dx-pagination>
60
+ </div>
61
+ </div>
62
+ <dx-empty-state
63
+ title="Beep boop. That did not compute."
64
+ subtitle={emptyStateSubtitle}
65
+ if:true={showEmptyState}
66
+ ></dx-empty-state>
67
+ </template>