@salesforcedevs/dw-components 0.0.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.
Files changed (58) hide show
  1. package/LICENSE +12 -0
  2. package/lwc.config.json +24 -0
  3. package/package.json +26 -0
  4. package/src/modules/dw/blogsGrid/blogsGrid.css +89 -0
  5. package/src/modules/dw/blogsGrid/blogsGrid.html +73 -0
  6. package/src/modules/dw/blogsGrid/blogsGrid.ts +28 -0
  7. package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.css +3 -0
  8. package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.html +16 -0
  9. package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.ts +29 -0
  10. package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.css +3 -0
  11. package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.html +12 -0
  12. package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.ts +29 -0
  13. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.css +171 -0
  14. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.html +138 -0
  15. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.ts +431 -0
  16. package/src/modules/dw/contentArchive/altData.js +3 -0
  17. package/src/modules/dw/contentArchive/contentArchive.css +242 -0
  18. package/src/modules/dw/contentArchive/contentArchive.html +340 -0
  19. package/src/modules/dw/contentArchive/contentArchive.ts +519 -0
  20. package/src/modules/dw/contentArchive/contentArchive.types.ts +98 -0
  21. package/src/modules/dw/contentArchive/utils.ts +193 -0
  22. package/src/modules/dw/deSignupForm/deSignupForm.css +75 -0
  23. package/src/modules/dw/deSignupForm/deSignupForm.html +117 -0
  24. package/src/modules/dw/deSignupForm/deSignupForm.ts +269 -0
  25. package/src/modules/dw/deSignupForm/submitForm.ts +93 -0
  26. package/src/modules/dw/docsGrid/docsGrid.css +83 -0
  27. package/src/modules/dw/docsGrid/docsGrid.html +89 -0
  28. package/src/modules/dw/docsGrid/docsGrid.ts +540 -0
  29. package/src/modules/dw/eventsList/eventsList.css +113 -0
  30. package/src/modules/dw/eventsList/eventsList.html +98 -0
  31. package/src/modules/dw/eventsList/eventsList.ts +192 -0
  32. package/src/modules/dw/instrumentation/instrumentation.html +1 -0
  33. package/src/modules/dw/instrumentation/instrumentation.ts +97 -0
  34. package/src/modules/dw/newsletterForm/newsletterForm.css +74 -0
  35. package/src/modules/dw/newsletterForm/newsletterForm.html +67 -0
  36. package/src/modules/dw/newsletterForm/newsletterForm.ts +233 -0
  37. package/src/modules/dw/podcastSubscription/podcastSubscription.css +91 -0
  38. package/src/modules/dw/podcastSubscription/podcastSubscription.html +24 -0
  39. package/src/modules/dw/podcastSubscription/podcastSubscription.ts +52 -0
  40. package/src/modules/dw/podcastsGrid/podcastsGrid.css +5 -0
  41. package/src/modules/dw/podcastsGrid/podcastsGrid.html +29 -0
  42. package/src/modules/dw/podcastsGrid/podcastsGrid.ts +9 -0
  43. package/src/modules/dw/podcastsPromo/podcastsPromo.css +32 -0
  44. package/src/modules/dw/podcastsPromo/podcastsPromo.html +36 -0
  45. package/src/modules/dw/podcastsPromo/podcastsPromo.ts +3 -0
  46. package/src/modules/dw/rcgTable/altData.ts +78 -0
  47. package/src/modules/dw/rcgTable/getTableData.ts +10 -0
  48. package/src/modules/dw/rcgTable/rcgTable.css +39 -0
  49. package/src/modules/dw/rcgTable/rcgTable.html +31 -0
  50. package/src/modules/dw/rcgTable/rcgTable.ts +34 -0
  51. package/src/modules/dw/slackCta/slackCta.css +47 -0
  52. package/src/modules/dw/slackCta/slackCta.html +17 -0
  53. package/src/modules/dw/slackCta/slackCta.ts +12 -0
  54. package/src/modules/dw/slackSuccess/slackSuccess.css +65 -0
  55. package/src/modules/dw/slackSuccess/slackSuccess.html +32 -0
  56. package/src/modules/dw/slackSuccess/slackSuccess.ts +34 -0
  57. package/src/modules/dwBaseElements/postsGrid/postsGrid.ts +80 -0
  58. package/src/modules/dwHelpers/postsGrid/postsGrid.css +9 -0
@@ -0,0 +1,98 @@
1
+ <template>
2
+ <div class="events-container">
3
+ <dx-section class="events-action-bar">
4
+ <div class="records-container">
5
+ <span>Showing { shownEventsTotal } of { events.length }</span>
6
+ </div>
7
+ <div class="filters-container">
8
+ <dx-popover width="max-content">
9
+ <dx-button
10
+ class="filter-button"
11
+ variant="tertiary"
12
+ icon-symbol="chevrondown"
13
+ slot="control"
14
+ >
15
+ Date
16
+ </dx-button>
17
+ <template if:true={showFilters}>
18
+ <dx-checkbox-group
19
+ legend="Date"
20
+ slot="content"
21
+ class="date-filter"
22
+ value={selectedMonths}
23
+ options={monthsList}
24
+ onchange={handleDateFilterChange}
25
+ ></dx-checkbox-group>
26
+ </template>
27
+ </dx-popover>
28
+ <dx-popover width="max-content">
29
+ <dx-button
30
+ class="filter-button"
31
+ variant="tertiary"
32
+ icon-symbol="chevrondown"
33
+ slot="control"
34
+ >
35
+ Event Type
36
+ </dx-button>
37
+ <template if:true={showFilters}>
38
+ <dx-checkbox-group
39
+ legend="Event Type"
40
+ slot="content"
41
+ class="date-filter"
42
+ value={selectedEventTypes}
43
+ options={eventTypeList}
44
+ onchange={handleEventTypeFilterChange}
45
+ ></dx-checkbox-group>
46
+ </template>
47
+ </dx-popover>
48
+ </div>
49
+ </dx-section>
50
+ <dx-section
51
+ class="events-list upcoming-events"
52
+ title="Upcoming Events"
53
+ if:true={upcomingEvents.length}
54
+ >
55
+ <dx-card-event
56
+ for:each={upcomingEvents}
57
+ for:item="item"
58
+ key={item.id}
59
+ href={item.urlStub}
60
+ title={item.name}
61
+ end-datetime={item.endDate}
62
+ start-datetime={item.startDate}
63
+ short-description={item.shortDescription}
64
+ type={item.type}
65
+ target="_blank"
66
+ featured="true"
67
+ ></dx-card-event>
68
+ </dx-section>
69
+
70
+ <dx-hr spacing="2xl"></dx-hr>
71
+
72
+ <dx-section
73
+ class="events-list past-events"
74
+ title="Past Events"
75
+ if:true={pastEvents.length}
76
+ >
77
+ <dx-card-event
78
+ for:each={pastEvents}
79
+ for:item="item"
80
+ key={item.id}
81
+ href={item.urlStub}
82
+ title={item.name}
83
+ end-datetime={item.endDate}
84
+ start-datetime={item.startDate}
85
+ short-description={item.shortDescription}
86
+ type={item.type}
87
+ target="_blank"
88
+ featured="true"
89
+ ></dx-card-event>
90
+ </dx-section>
91
+ <div class="events-empty" if:true={showEmptyState}>
92
+ <dx-empty-state
93
+ title="Beep boop. That did not compute."
94
+ subtitle={emptyStateSubtitle}
95
+ ></dx-empty-state>
96
+ </div>
97
+ </div>
98
+ </template>
@@ -0,0 +1,192 @@
1
+ import { api, LightningElement } from "lwc";
2
+ import { toJson } from "dxUtils/normalizers";
3
+ import qs from "query-string";
4
+ import uniqBy from "lodash.uniqby";
5
+ import orderBy from "lodash.orderby";
6
+
7
+ const MONTH_NAMES = [
8
+ "January",
9
+ "February",
10
+ "March",
11
+ "April",
12
+ "May",
13
+ "June",
14
+ "July",
15
+ "August",
16
+ "September",
17
+ "October",
18
+ "November",
19
+ "December"
20
+ ];
21
+
22
+ export default abstract class EventsList extends LightningElement {
23
+ private _events: any[] = [];
24
+ private monthsList: any[] = [];
25
+ private eventTypeList: any[] = [];
26
+ private selectedMonths: string[] = [];
27
+ private selectedEventTypes: string[] = [];
28
+ private showFilters = false;
29
+
30
+ private get _filteredEvents() {
31
+ return (
32
+ this._events
33
+ .filter((event) => {
34
+ const date = new Date(event.startDate);
35
+ const eventDate = `${MONTH_NAMES[date.getUTCMonth()]}`;
36
+ return (
37
+ this.selectedMonths.includes(eventDate) &&
38
+ this.selectedEventTypes.includes(event.type)
39
+ );
40
+ })
41
+ // some url stubs don't have /events/ prepended to the url
42
+ .map((event) => ({
43
+ ...event,
44
+ urlStub: event.urlStub.match(
45
+ /(\/event(s)?\/)|(http(s)?:\/\/)/
46
+ )
47
+ ? event.urlStub
48
+ : `/events/${event.urlStub}`
49
+ }))
50
+ );
51
+ }
52
+
53
+ @api
54
+ get events() {
55
+ return this._events;
56
+ }
57
+
58
+ set events(value) {
59
+ const tempDate = new Date();
60
+ tempDate.setMonth(tempDate.getMonth() - 2);
61
+ const twoMonthsAgo = tempDate.toISOString();
62
+ // Show past two months of events and all upcoming events
63
+ const events = toJson(value).filter(
64
+ (event) => event.startDate > twoMonthsAgo
65
+ );
66
+ this._events = events;
67
+ this.createFilters();
68
+ }
69
+
70
+ get upcomingEvents() {
71
+ const today = new Date().toISOString();
72
+ return this._filteredEvents.filter((event) => event.startDate > today);
73
+ }
74
+
75
+ get pastEvents() {
76
+ const today = new Date().toISOString();
77
+ return orderBy(
78
+ this._filteredEvents.filter((event) => event.startDate < today),
79
+ ["startDate"],
80
+ ["desc"]
81
+ );
82
+ }
83
+
84
+ get shownEventsTotal() {
85
+ return this._filteredEvents.length;
86
+ }
87
+
88
+ get showEmptyState() {
89
+ return !this.upcomingEvents.length && !this.pastEvents.length;
90
+ }
91
+
92
+ connectedCallback(): void {
93
+ const { months = "", types = "" } = qs.parse(window.location.search);
94
+ this.selectedMonths =
95
+ months === "" ? this.selectedMonths : months.split(",");
96
+ this.selectedEventTypes =
97
+ types === "" ? this.selectedEventTypes : types.split(",");
98
+ window.addEventListener("popstate", this.handleURLStateChange);
99
+ }
100
+
101
+ disconnectedCallback(): void {
102
+ window.removeEventListener("popstate", this.handleURLStateChange);
103
+ }
104
+
105
+ createMonthsList() {
106
+ return this._events.map((event) => {
107
+ const date = new Date(event.startDate);
108
+ return {
109
+ rawDate: date,
110
+ value: `${MONTH_NAMES[date.getUTCMonth()]}`,
111
+ label: `${
112
+ MONTH_NAMES[date.getUTCMonth()]
113
+ } ${date.getUTCFullYear()}`
114
+ };
115
+ });
116
+ }
117
+
118
+ createEventTypeList() {
119
+ return this._events.map((event) => ({
120
+ value: event.type,
121
+ label: event.type
122
+ }));
123
+ }
124
+
125
+ createFilters() {
126
+ this.monthsList = orderBy(
127
+ uniqBy(this.createMonthsList(), "value"),
128
+ ["rawDate"],
129
+ ["desc"]
130
+ );
131
+ this.selectedMonths = this.monthsList.map((month) => month.value);
132
+
133
+ this.eventTypeList = uniqBy(this.createEventTypeList(), "value");
134
+ this.selectedEventTypes = this.eventTypeList.map(
135
+ (eventType) => eventType.value
136
+ );
137
+
138
+ this.showFilters = true;
139
+ }
140
+
141
+ handleDateFilterChange(e) {
142
+ this.selectedMonths = e.detail.value;
143
+ this.setSearchParams();
144
+ }
145
+
146
+ handleEventTypeFilterChange(e) {
147
+ this.selectedEventTypes = e.detail.value;
148
+ this.setSearchParams();
149
+ }
150
+
151
+ handleURLStateChange = () => {
152
+ const { months = "", types = "" } = qs.parse(window.location.search);
153
+ this.selectedMonths =
154
+ months === ""
155
+ ? this.monthsList.map((month) => month.value)
156
+ : months.split(",");
157
+ this.selectedEventTypes =
158
+ types === ""
159
+ ? this.eventTypeList.map((type) => type.value)
160
+ : types.split(",");
161
+ };
162
+
163
+ setSearchParams() {
164
+ const months = this.normalizeParamList(
165
+ this.selectedMonths,
166
+ this.monthsList
167
+ );
168
+ const types = this.normalizeParamList(
169
+ this.selectedEventTypes,
170
+ this.eventTypeList
171
+ );
172
+ const params = { months, types };
173
+
174
+ for (const key in params) {
175
+ if (!params[key] || params[key] === "") {
176
+ delete params[key];
177
+ }
178
+ }
179
+
180
+ let searchParams = qs.stringify(params, { encode: false });
181
+ searchParams = searchParams === "" ? "" : `?${searchParams}`;
182
+
183
+ const newurl = `${window.location.protocol}//${window.location.host}${window.location.pathname}${searchParams}`;
184
+ window.history.pushState({ path: newurl }, "", newurl);
185
+ }
186
+
187
+ normalizeParamList(selectedList, totalList) {
188
+ return selectedList.length === totalList.length
189
+ ? ""
190
+ : selectedList.join(",");
191
+ }
192
+ }
@@ -0,0 +1 @@
1
+ <template></template>
@@ -0,0 +1,97 @@
1
+ import { LightningElement, api } from "lwc";
2
+ import {
3
+ TRACKING_EVENT_NAME,
4
+ LISTENER_QUEUE,
5
+ LISTENER_INDICATOR,
6
+ track
7
+ } from "dxUtils/analytics";
8
+
9
+ const googleTagManager = {
10
+ track: function (e: Event) {
11
+ if ((window as any).dataLayer === undefined) {
12
+ (window as any).dataLayer = [];
13
+ }
14
+ const { event, payload } = (e as CustomEvent).detail;
15
+ (window as any).dataLayer.push({ ...payload, event });
16
+ }
17
+ };
18
+
19
+ interface TrackEventListener {
20
+ add: () => void;
21
+ remove: () => void;
22
+ }
23
+
24
+ export function developerwebTrackEventListener(
25
+ trackerFns: { track: (e: Event) => void }[] = []
26
+ ): TrackEventListener {
27
+ if (trackerFns.length === 0) {
28
+ throw new Error("No tracker functions passed");
29
+ }
30
+
31
+ const trackdeveloperwebEvent = (e: Event) => {
32
+ trackerFns.forEach((tracker) => {
33
+ tracker.track(e);
34
+ });
35
+ };
36
+
37
+ const attachEventListener = () => {
38
+ document.addEventListener(TRACKING_EVENT_NAME, trackdeveloperwebEvent);
39
+ };
40
+
41
+ const removeEventListener = () => {
42
+ document.removeEventListener(
43
+ TRACKING_EVENT_NAME,
44
+ trackdeveloperwebEvent
45
+ );
46
+ };
47
+
48
+ return {
49
+ add: attachEventListener,
50
+ remove: removeEventListener
51
+ };
52
+ }
53
+
54
+ export default class Instrumentation extends LightningElement {
55
+ @api useGoogleTagManager = false;
56
+
57
+ private tracker: TrackEventListener | null = null;
58
+
59
+ private setupTracker() {
60
+ const trackerFunctions = this.useGoogleTagManager
61
+ ? [googleTagManager]
62
+ : [];
63
+ this.tracker = developerwebTrackEventListener(trackerFunctions);
64
+ this.tracker.add();
65
+ (window as any)[LISTENER_INDICATOR] = true;
66
+ }
67
+
68
+ private dispatchQueuedEvents() {
69
+ while ((window as any)[LISTENER_QUEUE].length > 0) {
70
+ const event = (window as any)[LISTENER_QUEUE].pop() as {
71
+ event: string;
72
+ payload: Record<string, unknown>;
73
+ };
74
+ track(this, event.event, event.payload);
75
+ }
76
+ }
77
+
78
+ renderedCallback() {
79
+ if (this.tracker === null) {
80
+ this.setupTracker();
81
+
82
+ if (
83
+ (window as any)[LISTENER_QUEUE] !== undefined &&
84
+ (window as any)[LISTENER_QUEUE].length > 0
85
+ ) {
86
+ this.dispatchQueuedEvents();
87
+ }
88
+ }
89
+ }
90
+
91
+ disconnectedCallback() {
92
+ if (this.tracker !== null) {
93
+ this.tracker.remove();
94
+ this.tracker = null;
95
+ }
96
+ }
97
+ }
@@ -0,0 +1,74 @@
1
+ @import "dxHelpers/text";
2
+ @import "dxHelpers/button";
3
+
4
+ :host {
5
+ --dx-g-text-base: 20px;
6
+ --dx-c-checkbox-text-line-height: 20px;
7
+ --dx-c-checkbox-align-label: flex-start;
8
+ --dx-c-checkbox-font-size: 14px;
9
+ --dx-c-checkbox-text-transform: none;
10
+ }
11
+
12
+ h4 {
13
+ font-size: 20px;
14
+ margin: 0 0 28px 0;
15
+ text-align: center;
16
+ }
17
+
18
+ dx-input,
19
+ dx-select {
20
+ display: block;
21
+ margin-top: 12px;
22
+ height: 77px;
23
+ }
24
+
25
+ dx-input {
26
+ --dx-c-input-width: 100%;
27
+ }
28
+
29
+ dx-checkbox:not(:first-child) {
30
+ margin-top: 12px;
31
+ }
32
+
33
+ dx-checkbox:last-of-type {
34
+ margin-bottom: 16px;
35
+ }
36
+
37
+ .form-submit {
38
+ background-color: var(--dx-g-blue-vibrant-50);
39
+ border: 2px solid var(--dx-g-blue-vibrant-50);
40
+ border-radius: 4px;
41
+ font-family: var(--dx-g-font-display);
42
+ font-size: 14px;
43
+ color: white;
44
+ height: 44px;
45
+ width: 100%;
46
+ margin-top: 20px;
47
+ }
48
+
49
+ .form-submit:hover {
50
+ background-color: var(--dx-g-blue-vibrant-40);
51
+ border-color: var(--dx-g-blue-vibrant-40);
52
+ cursor: pointer;
53
+ }
54
+
55
+ .marketing-text,
56
+ .legal-text {
57
+ font-size: 14px;
58
+ margin: 0 0 16px 0;
59
+ }
60
+
61
+ @media screen and (max-width: 360px) {
62
+ :host {
63
+ --dx-g-text-base: 16px;
64
+ --dx-c-checkbox-display: inline-block;
65
+ }
66
+
67
+ h4 {
68
+ font-size: 16px;
69
+ }
70
+
71
+ .form-submit {
72
+ margin-top: 0;
73
+ }
74
+ }
@@ -0,0 +1,67 @@
1
+ <template>
2
+ <form
3
+ onsubmit={handleSubmit}
4
+ onchange={handleChange}
5
+ onkeydown={handleKeyDown}
6
+ >
7
+ <slot name="form-heading">
8
+ <h4 class="newsletter-form-heading dx-text-heading-8">
9
+ Sign up now to receive developer updates.
10
+ </h4>
11
+ </slot>
12
+ <dx-input
13
+ name="fname"
14
+ value={firstName}
15
+ placeholder="Your first name"
16
+ label="First Name"
17
+ onchange={handleChange}
18
+ missing-error-message="Enter your first name"
19
+ validity-on-blur="true"
20
+ required="true"
21
+ ></dx-input>
22
+ <dx-input
23
+ name="lname"
24
+ value={lastName}
25
+ placeholder="Your last name"
26
+ label="Last Name"
27
+ onchange={handleChange}
28
+ missing-error-message="Enter your last name"
29
+ validity-on-blur="true"
30
+ required="true"
31
+ ></dx-input>
32
+ <dx-input
33
+ name="email"
34
+ type="email"
35
+ value={email}
36
+ placeholder="Your email address"
37
+ label="Email"
38
+ onchange={handleChange}
39
+ missing-error-message="Enter your email address"
40
+ validity-on-blur="true"
41
+ required="true"
42
+ ></dx-input>
43
+ <dx-select
44
+ name="country"
45
+ class="country-select"
46
+ label="Country/Region"
47
+ onchange={handleChange}
48
+ placeholder="Select your Country/Region"
49
+ message-when-value-missing="Select your country/region"
50
+ options={countries}
51
+ value={country}
52
+ required="true"
53
+ ></dx-select>
54
+ <template if:true={checkboxTextSet}>
55
+ <p class="marketing-text">{marketingText}</p>
56
+ <p class="legal-text" lwc:dom="manual"></p>
57
+ <template if:true={showLegalCheckbox}>
58
+ <dx-checkbox
59
+ class="legal-checkbox"
60
+ value={legalText}
61
+ required="true"
62
+ ></dx-checkbox>
63
+ </template>
64
+ </template>
65
+ <button class="form-submit" type="submit">Subscribe Now</button>
66
+ </form>
67
+ </template>