@salesforcedevs/dw-components 1.3.124-alpha.0 → 1.3.124-j2s

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
@@ -14,6 +14,8 @@
14
14
  "dw/docsGrid",
15
15
  "dw/eventsList",
16
16
  "dw/instrumentation",
17
+ "dw/j2sCardSequence",
18
+ "dw/j2sForm",
17
19
  "dw/newsletterForm",
18
20
  "dw/podcastSubscription",
19
21
  "dw/podcastsGrid",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dw-components",
3
- "version": "1.3.124-alpha.0",
3
+ "version": "1.3.124-j2s",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -23,7 +23,7 @@ dx-section.events-action-bar::part(container) {
23
23
 
24
24
  dx-section.upcoming-events::part(container)::before {
25
25
  content: "";
26
- background-image: url(https://a.sfdcstatic.com/developer-website/images/events-cloud1.svg);
26
+ background-image: url(/assets/images/events-cloud1.svg);
27
27
  width: 146px;
28
28
  height: 106px;
29
29
  position: absolute;
@@ -34,7 +34,7 @@ dx-section.upcoming-events::part(container)::before {
34
34
 
35
35
  dx-section.upcoming-events::part(container)::after {
36
36
  content: "";
37
- background-image: url(https://a.sfdcstatic.com/developer-website/images/events-cloud2.svg);
37
+ background-image: url(/assets/images/events-cloud2.svg);
38
38
  width: 152px;
39
39
  height: 111px;
40
40
  position: absolute;
@@ -45,7 +45,7 @@ dx-section.upcoming-events::part(container)::after {
45
45
 
46
46
  dx-section.past-events::part(container)::before {
47
47
  content: "";
48
- background-image: url(https://a.sfdcstatic.com/developer-website/images/events-gradient-elipse.svg);
48
+ background-image: url(/assets/images/events-gradient-elipse.svg);
49
49
  width: 2991px;
50
50
  height: 839px;
51
51
  position: absolute;
@@ -56,7 +56,7 @@ dx-section.past-events::part(container)::before {
56
56
 
57
57
  dx-section:not(:nth-child(2)).past-events::part(container)::after {
58
58
  content: "";
59
- background-image: url(https://a.sfdcstatic.com/developer-website/images/events-cloud3.svg);
59
+ background-image: url(/assets/images/events-cloud3.svg);
60
60
  width: 655px;
61
61
  height: 270px;
62
62
  position: absolute;
@@ -0,0 +1,53 @@
1
+ @import "dxHelpers/reset";
2
+ @import "dxHelpers/text";
3
+ @import "dxHelpers/card";
4
+
5
+ :host {
6
+ --dx-c-button-custom-color: var(--dx-g-blue-vibrant-50);
7
+ --dx-c-button-custom-background: white;
8
+ --dx-c-button-custom-border: var(--dx-g-blue-vibrant-50);
9
+ --dx-c-button-custom-color-hover: var(--dx-g-blue-vibrant-50);
10
+ --dx-c-button-custom-background-hover: var(--dx-g-cloud-blue-vibrant-90);
11
+ --dx-c-button-custom-border-hover: var(--dx-g-cloud-blue-vibrant-50);
12
+ }
13
+
14
+ dx-step-sequence {
15
+ scroll-margin-top: var(--dx-g-global-header-height);
16
+ }
17
+
18
+ dx-step-sequence-step:last-child dx-card-step::part(footer-container) {
19
+ background-color: var(--dx-g-indigo-vibrant-95);
20
+ border-radius: 8px;
21
+ margin: 0 30px 30px 30px;
22
+ }
23
+
24
+ [slot="secondary-action-section"] {
25
+ color: var(--dx-g-red-vibrant-50);
26
+ position: relative;
27
+ font-size: var(--dx-g-text-xs, 12px);
28
+ font-family: var(--dx-g-font-sans);
29
+ line-height: 18px;
30
+ text-align: left;
31
+ }
32
+
33
+ .body-container li {
34
+ line-height: var(--dx-g-text-2xl);
35
+ }
36
+
37
+ .body-container p:not(:last-child) {
38
+ padding-bottom: 20px;
39
+ }
40
+
41
+ .body-markup {
42
+ display: block;
43
+ padding-bottom: var(--dx-g-spacing-md);
44
+ }
45
+
46
+ .referral-email-field {
47
+ --dx-c-input-width: 100%;
48
+ }
49
+
50
+ .spinner-container {
51
+ min-height: 200px;
52
+ position: relative;
53
+ }
@@ -0,0 +1,69 @@
1
+ <template>
2
+ <dx-step-sequence
3
+ animate-transitions={animateTransitions}
4
+ communicate-step-changes="true"
5
+ initial-step-index={initialStepIndex}
6
+ onstepsequencechange={handleStepSequenceChange}
7
+ session-storage-id={sessionStorageId}
8
+ use-history={useHistory}
9
+ >
10
+ <template for:each={stepsData} for:item="stepDatum" for:index="index">
11
+ <dx-step-sequence-step key={stepDatum.id}>
12
+ <dx-card-step
13
+ header-icon-symbol={stepDatum.headerData.iconSymbol}
14
+ header-icon-sprite={stepDatum.headerData.iconSprite}
15
+ header-icon-color={stepDatum.headerData.iconColor}
16
+ header-background-color={stepDatum.headerData.backgroundColor}
17
+ header-text-color={stepDatum.headerData.textColor}
18
+ show-step-number={stepDatum.showStepNumber}
19
+ step-count={stepsData.length}
20
+ step-index={index}
21
+ step-title={stepDatum.stepTitle}
22
+ >
23
+ <div slot="card-body" class="body-container">
24
+ <template if:true={isLoading}>
25
+ <div class="spinner-container">
26
+ <dx-spinner
27
+ size="large"
28
+ variant="brand"
29
+ ></dx-spinner>
30
+ </div>
31
+ </template>
32
+ <template if:false={isLoading}>
33
+ <span lwc:dom="manual" class="body-markup"></span>
34
+ <template if:true={stepDatum.formData}>
35
+ <dw-j2s-form
36
+ id={stepDatum.formData.formId}
37
+ countries={countries}
38
+ form-metadata={stepDatum.formMetadata}
39
+ incoming-user-info={formIncomingUserInfo}
40
+ onformvaliditychange={handleFormValidityChange}
41
+ ></dw-j2s-form>
42
+ </template>
43
+ </template>
44
+ </div>
45
+ <div slot="secondary-action-section">
46
+ <span
47
+ lwc:dom="manual"
48
+ class="secondary-action-markup"
49
+ ></span>
50
+ </div>
51
+ <div slot="primary-action-section">
52
+ <dx-button
53
+ class="primary-action"
54
+ disabled={isJ2sFormInvalid}
55
+ icon-sprite={stepDatum.primaryAction.iconSprite}
56
+ icon-symbol={stepDatum.primaryAction.iconSymbol}
57
+ loading={isLoading}
58
+ onclick={primaryActionHandler}
59
+ size="large"
60
+ variant={primaryActionVariant}
61
+ >
62
+ {stepDatum.primaryAction.text}
63
+ </dx-button>
64
+ </div>
65
+ </dx-card-step>
66
+ </dx-step-sequence-step>
67
+ </template>
68
+ </dx-step-sequence>
69
+ </template>
@@ -0,0 +1,275 @@
1
+ import { api, LightningElement } from "lwc";
2
+ import StepSequence from "dx/stepSequence";
3
+ import { getListWithUuids } from "dxUtils/list";
4
+ import { toJson } from "dxUtils/normalizers";
5
+ import Button from "dx/button";
6
+
7
+ export type StepDatum = {
8
+ bodyHtml?: string;
9
+ formData?: {
10
+ countriesWithReferralInput?: string[];
11
+ countriesWithRequiredJobRole?: string[];
12
+ formId?: string;
13
+ j2sTerms?: string;
14
+ notAvailableAlertInfo?: {
15
+ title: string;
16
+ body: string;
17
+ };
18
+ participatingCountryCodes?: string[];
19
+ };
20
+ headerData?: {
21
+ backgroundColor?: string;
22
+ iconColor?: string;
23
+ iconSprite?: string;
24
+ iconSymbol?: string;
25
+ textColor?: string;
26
+ };
27
+ primaryAction: {
28
+ text: string;
29
+ variant?: string;
30
+ iconSprite?: string;
31
+ iconSymbol?: string;
32
+ },
33
+ secondaryActionHtml?: string;
34
+ showStepNumber?: boolean;
35
+ stepTitle: string;
36
+ };
37
+
38
+ export default class J2sCardSequence extends LightningElement {
39
+ _isDrmLoading = false;
40
+ _isJ2sFormInvalid = false;
41
+ _isTbidLoading = false;
42
+ _stepsData: StepDatum[] = [];
43
+ @api animateTransitions = false;
44
+ @api drmDomain: string = "https://drm.my.salesforce-sites.com";
45
+ @api tbidApiBaseUrl: string | undefined;
46
+ @api useHistory: boolean = false;
47
+
48
+ @api
49
+ get stepsData() {
50
+ return this._stepsData;
51
+ }
52
+ set stepsData(value) {
53
+ this._stepsData = getListWithUuids<StepDatum>(toJson(value)).map(
54
+ (stepDatum) => {
55
+ // small bit of normalization for cleaner HTML templates with non-required props, etc.
56
+ const normalizedStepDatum = {
57
+ ...stepDatum,
58
+ headerData: stepDatum.headerData || {},
59
+ primaryAction: {
60
+ ...stepDatum.primaryAction,
61
+ variant: stepDatum.primaryAction.variant || "primary",
62
+ iconSprite: stepDatum.primaryAction.iconSprite || "general",
63
+ iconSymbol: stepDatum.primaryAction.iconSymbol || "arrow-right"
64
+ }
65
+ };
66
+
67
+ if (normalizedStepDatum.formData) {
68
+ (normalizedStepDatum as any).formMetadata = JSON.stringify(
69
+ normalizedStepDatum.formData
70
+ );
71
+ }
72
+
73
+ return normalizedStepDatum;
74
+ }
75
+ );
76
+ }
77
+
78
+ private countries = "[]";
79
+ private currentSequenceStep = 0;
80
+ private sessionStorageId = "j2s-card-sequence";
81
+ private tbidUserInfo: any; // TODO typings?
82
+
83
+ private get isLoading() {
84
+ return this._isDrmLoading || this._isTbidLoading;
85
+ }
86
+
87
+ private get isLoggedIn() {
88
+ return Boolean(this.tbidUserInfo);
89
+ }
90
+
91
+ private get isJ2sFormInvalid() {
92
+ return this.currentSequenceStep === 1 ? this._isJ2sFormInvalid : false;
93
+ }
94
+ private set isJ2sFormInvalid(isFormInvalid: boolean) {
95
+ this._isJ2sFormInvalid = isFormInvalid;
96
+ }
97
+
98
+ private get primaryActionVariant() {
99
+ if (this.currentSequenceStep === 1 && this.isJ2sFormInvalid) {
100
+ return "custom"; // override for disabled button styling
101
+ }
102
+ return this.stepsData[this.currentSequenceStep || 0].primaryAction.variant;
103
+ }
104
+
105
+ private get formIncomingUserInfo() {
106
+ if (!this.tbidUserInfo) {
107
+ return "{}";
108
+ }
109
+
110
+ return JSON.stringify({
111
+ firstName: this.tbidUserInfo.given_name,
112
+ lastName: this.tbidUserInfo.family_name,
113
+ email: this.tbidUserInfo.email,
114
+ jobRole: this.tbidUserInfo.custom_attributes?.Role,
115
+ companyName: this.tbidUserInfo.custom_attributes?.CompanyName,
116
+ country: this.tbidUserInfo.custom_attributes?.Country
117
+ });
118
+ }
119
+
120
+ private get initialStepIndex() {
121
+ let initialStepIndex = 0;
122
+
123
+ const storedSessionData = sessionStorage.getItem(this.sessionStorageId);
124
+ if (storedSessionData) {
125
+ try {
126
+ const { currentStepIndex } = JSON.parse(storedSessionData);
127
+ initialStepIndex = currentStepIndex;
128
+ } catch (ex) {
129
+ // noop
130
+ }
131
+ }
132
+
133
+ return initialStepIndex;
134
+ }
135
+ private set initialStepIndex(value: number) {
136
+ sessionStorage.setItem(
137
+ this.sessionStorageId,
138
+ JSON.stringify({
139
+ currentStepIndex: value
140
+ })
141
+ );
142
+ }
143
+
144
+ connectedCallback() {
145
+ this.getCountryList();
146
+ this.getTbidUserInfo();
147
+ // This has to be defined here since it depends on a variable that depends on sessionStorage.
148
+ this.currentSequenceStep = this.initialStepIndex;
149
+ this.resetCustomButtonColors();
150
+ }
151
+
152
+ renderedCallback() {
153
+ if (this.isLoading) {
154
+ return;
155
+ }
156
+
157
+ const { bodyHtml, secondaryActionHtml } = this.stepsData[this.currentSequenceStep];
158
+ const bodyMarkupContainer = this.template.querySelectorAll("span.body-markup")[this.currentSequenceStep];
159
+ const secondaryActionMarkupContainer = this.template.querySelectorAll("span.secondary-action-markup")[this.currentSequenceStep];
160
+ if (bodyMarkupContainer) {
161
+ bodyMarkupContainer.innerHTML = bodyHtml || "";
162
+ }
163
+ if (secondaryActionMarkupContainer) {
164
+ secondaryActionMarkupContainer.innerHTML = secondaryActionHtml || "";
165
+ }
166
+ }
167
+
168
+ handleGetStarted(evt: Event) {
169
+ // If the user is not yet logged in, we need to prevent moving immediately to the next
170
+ // step, but set storage up so that they are on the second step when they return to the
171
+ // site in a logged-in state; then, we need to get them to log in.
172
+ if (!this.isLoggedIn) {
173
+ evt.preventDefault();
174
+ this.initialStepIndex = 1;
175
+ // @ts-ignore: call out to the tbid-controller on DSC
176
+ window.__startTbidLogin();
177
+ }
178
+ }
179
+
180
+ handleFormValidityChange({ detail }: CustomEvent) {
181
+ this.isJ2sFormInvalid = !detail.isValid;
182
+ }
183
+
184
+ handleStepSequenceChange({ detail }: CustomEvent) {
185
+ this.currentSequenceStep = detail.stepIndex;
186
+ this.resetCustomButtonColors();
187
+ }
188
+
189
+ primaryActionHandler(evt: Event) {
190
+ if ((evt.target as Button)?.disabled) {
191
+ evt.preventDefault();
192
+ return;
193
+ }
194
+
195
+ if (!this.currentSequenceStep) {
196
+ this.handleGetStarted(evt);
197
+ } else if (this.currentSequenceStep === 2) {
198
+ // TODO: send data to DRM
199
+ } else if (this.currentSequenceStep === 3) {
200
+ // TODO: Join Slack
201
+ }
202
+ }
203
+
204
+ private resetCustomButtonColors() {
205
+ let bgColor;
206
+ let textColor;
207
+
208
+ if (this.currentSequenceStep === 1) {
209
+ bgColor = "var(--dx-g-gray-80)";
210
+ textColor = "white";
211
+ } else {
212
+ bgColor = "white";
213
+ textColor = "var(--dx-g-blue-vibrant-50)";
214
+ }
215
+
216
+ this.template.host.style.setProperty(
217
+ "--dx-c-button-custom-color",
218
+ textColor
219
+ );
220
+ this.template.host.style.setProperty(
221
+ "--dx-c-button-custom-background",
222
+ bgColor
223
+ );
224
+ this.template.host.style.setProperty(
225
+ "--dx-c-button-custom-border",
226
+ bgColor
227
+ );
228
+ }
229
+
230
+ private async getCountryList() {
231
+ this._isDrmLoading = true;
232
+
233
+ const errorMsg = "Error while getting county list";
234
+ try {
235
+ const res = await fetch(
236
+ `${this.drmDomain}/utilities/services/apexrest/countries`
237
+ );
238
+ if (!res.ok) {
239
+ throw new Error(errorMsg);
240
+ }
241
+ const data = await res.json();
242
+ this.countries = JSON.stringify(data);
243
+ } catch (error) {
244
+ console.error(error);
245
+ }
246
+
247
+ this._isDrmLoading = false;
248
+ }
249
+
250
+ private async getTbidUserInfo() {
251
+ this._isTbidLoading = true;
252
+
253
+ try {
254
+ const res = await fetch(`${this.tbidApiBaseUrl}/userinfo`);
255
+ if (res.ok) {
256
+ this.tbidUserInfo = await res.json();
257
+ }
258
+ } catch (ex) {
259
+ // noop; nothing to do here
260
+ }
261
+
262
+ if (!this.tbidUserInfo && this.initialStepIndex > 0) {
263
+ // login failed and the user was previously beyond the start step; need to send them
264
+ // back to the start:
265
+ this.initialStepIndex = 0;
266
+ (
267
+ this.template.querySelector(
268
+ "dx-step-sequence"
269
+ ) as unknown as StepSequence
270
+ )?.jumpToStep(0);
271
+ }
272
+
273
+ this._isTbidLoading = false;
274
+ }
275
+ }
@@ -0,0 +1,46 @@
1
+ export const stepsData = [
2
+ {
3
+ showStepNumber: "true",
4
+ stepTitle: "Get started now.",
5
+ bodyHtml:
6
+ '<p class="dx-text-display-7">Register for Journey to Salesforce and you\'ll be on your way to becoming a Salesforce Developer.</p><ul class="dx-text-display-8"><li>Step 1: Log in or sign up for a free Trailblazer.me account</li><li>Step 2: Confirm your program registration</li><li>Step 3: Begin your journey!</li></ul>',
7
+ primaryActionText: "Get Started"
8
+ },
9
+ {
10
+ showStepNumber: "true",
11
+ stepTitle: "Complete your registration.",
12
+ formData: {
13
+ countriesWithReferralInput: ["IN"],
14
+ countriewWithRequiredJobRole: ["CA"],
15
+ notAvailableAlertInfo: {
16
+ title: "Not Available",
17
+ body: 'The Journey to Salesforce program is not currently available in your country. See the <a href="https://www.google.com/">program FAQs</a> for a list of participating countries.'
18
+ },
19
+ participatingCountryCodes: ["US", "CA", "IN"]
20
+ },
21
+ bodyHtml:
22
+ '<p class="dx-text-display-7">You\'re almost done! Please review your information and agree to the Journey to Salesforce program terms and conditions.</p>',
23
+ secondaryActionHtml:
24
+ '<span class="required-notice">* Required to participate in Journey to Salesforce</span>',
25
+ primaryActionText: "Complete Registration"
26
+ },
27
+ {
28
+ showStepNumber: "true",
29
+ stepTitle: "Your Registration is Confirmed",
30
+ headerData: {
31
+ iconSymbol: "check-circle",
32
+ iconSprite: "general",
33
+ iconColor: "green-vibrant-65",
34
+ backgroundColor: "green-vibrant-95",
35
+ textColor: "indigo-vibrant-20"
36
+ },
37
+ bodyHtml:
38
+ '<div class="dx-text-display-8"><p>Welcome to Journey to Salesforce! Congratulations on taking this step in your journey towards becoming a Salesforce Developer. Through this program you\'ll gain the knowledge, experience, and skills to help you excel in the Salesforce ecosystem.</p><p>To get started, click the button below to join the Journey to Salesforce community, and make sure to check your email for links to bookmark!</p>',
39
+ secondaryActionHtml:
40
+ '<span class="dx-text-display-7">Ready to jump in?</span>',
41
+ primaryActionText: "Join Slack",
42
+ primaryActionVariant: "custom",
43
+ primaryActionIconSprite: "utility",
44
+ primaryActionIconSymbol: "new_window"
45
+ }
46
+ ];
@@ -0,0 +1,46 @@
1
+ .hidden {
2
+ display: none;
3
+ }
4
+
5
+ .form-row {
6
+ display: flex;
7
+ justify-content: space-between;
8
+ padding-bottom: var(--dx-g-spacing-md);
9
+ }
10
+
11
+ .form-row > * {
12
+ --dx-c-input-width: 100%;
13
+
14
+ font-family: var(--dx-g-font-sans);
15
+ width: calc(50% - 20px);
16
+ }
17
+
18
+ .form-row > :only-child {
19
+ max-width: 100%;
20
+ width: 100%;
21
+ }
22
+
23
+ .form-row .terms {
24
+ --dx-c-checkbox-text-line-height: 20px;
25
+ --dx-c-checkbox-font-size: 14px;
26
+
27
+ font-family: var(--dx-g-font-sans);
28
+ font-size: var(--dx-c-checkbox-font-size);
29
+ font-weight: var(--dx-g-font-normal);
30
+ }
31
+
32
+ .form-row .legal-terms-learn-more:not(.hidden) {
33
+ display: block;
34
+ padding-top: var(--dx-g-spacing-md);
35
+ }
36
+
37
+ .form-row .legal-terms.no-checkbox {
38
+ font-family: var(--dx-g-font-sans);
39
+ font-size: var(--dx-g-text-xs);
40
+ font-weight: var(--dx-g-font-normal);
41
+ margin-left: 28px;
42
+ }
43
+
44
+ .form-terms-container {
45
+ padding-top: var(--dx-g-spacing-sm);
46
+ }