pr360-questionnaire 0.0.2 → 0.0.3

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.
@@ -16763,21 +16763,21 @@
16763
16763
  @import url("https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap");
16764
16764
  h1 {
16765
16765
  font-size: 2rem;
16766
- font-family: "Lato", Calibri, Tahoma, sans-serif;
16766
+ font-family: "Lato", Helvetica, sans-serif;
16767
16767
  font-weight: 700;
16768
16768
  }
16769
16769
 
16770
16770
  h2 {
16771
16771
  font-weight: 300;
16772
16772
  margin: 0px;
16773
- font-family: "Lato", Calibri, Tahoma, sans-serif;
16773
+ font-family: "Lato", Helvetica, sans-serif;
16774
16774
  font-size: 1.5rem;
16775
16775
  }
16776
16776
 
16777
16777
  h3 {
16778
16778
  font-weight: 300;
16779
16779
  margin-top: 0px;
16780
- font-family: "Lato", Calibri, Tahoma, sans-serif;
16780
+ font-family: "Lato", Helvetica, sans-serif;
16781
16781
  font-size: 1rem;
16782
16782
  }
16783
16783
 
@@ -16796,6 +16796,7 @@ h3 {
16796
16796
  align-items: center;
16797
16797
  justify-content: center;
16798
16798
  padding: 0 30px;
16799
+ min-height: 360px;
16799
16800
  }
16800
16801
  @media screen and (max-width: 700px) {
16801
16802
  .questionnaire--bt-contain {
@@ -16819,16 +16820,17 @@ h3 {
16819
16820
  width: 80%;
16820
16821
  max-width: 350px;
16821
16822
  }
16822
- @media screen and (max-width: 700px) {
16823
+ @media screen and (max-width: 1200px) {
16823
16824
  .questionnaire-illustration {
16824
16825
  margin-bottom: 35px;
16825
16826
  }
16826
16827
  }
16827
16828
 
16828
- button {
16829
- font-family: "lato", Calibri, Tahoma, sans-serif;
16829
+ .button--primary {
16830
+ font-family: "lato", Helvetica, sans-serif;
16830
16831
  padding: 10px 35px;
16831
- width: 400px;
16832
+ min-width: 150px;
16833
+ width: 35vw;
16832
16834
  min-height: 85px;
16833
16835
  display: block;
16834
16836
  border: 1px solid #8c8c8c;
@@ -16840,28 +16842,57 @@ button {
16840
16842
  line-height: 23px;
16841
16843
  transition: transform 150ms;
16842
16844
  }
16843
- @media screen and (max-width: 700px) {
16844
- button {
16845
+ @media screen and (max-width: 1200px) {
16846
+ .button--primary {
16845
16847
  height: unset;
16846
16848
  }
16847
16849
  }
16848
16850
 
16849
- button:hover {
16851
+ .button--primary:hover {
16850
16852
  border: 2px solid #e9a0a1;
16851
- transform: translateY(4px);
16853
+ transform: translateY(2px);
16854
+ }
16855
+
16856
+ .button--begin {
16857
+ font-family: "lato", Helvetica, sans-serif;
16858
+ padding: 5px 25px;
16859
+ min-height: 60px;
16860
+ width: 150px;
16861
+ border: 1px solid #cacaca;
16862
+ border-radius: 20px;
16863
+ background-color: #fff;
16864
+ font-size: 1rem;
16865
+ font-weight: 300;
16866
+ transition: transform 150ms;
16867
+ }
16868
+ .button--begin:hover {
16869
+ background-color: #efefef;
16870
+ transform: translateY(2px);
16871
+ }
16872
+
16873
+ .button--link {
16874
+ color: #8c8c8c;
16875
+ background-color: transparent;
16876
+ border: none;
16877
+ position: absolute;
16878
+ top: 15px;
16879
+ left: 15px;
16880
+ }
16881
+ .button--link:hover {
16882
+ text-decoration: underline;
16852
16883
  }
16853
16884
 
16854
16885
  .contactform--container {
16855
16886
  padding: 100px;
16856
16887
  }
16857
- @media screen and (max-width: 700px) {
16888
+ @media screen and (max-width: 1200px) {
16858
16889
  .contactform--container {
16859
16890
  padding: 100px 15px;
16860
16891
  width: 92%;
16861
16892
  }
16862
16893
  }
16863
16894
  .contactform--container label {
16864
- width: 28%;
16895
+ width: 315px;
16865
16896
  display: block;
16866
16897
  margin: 0 auto;
16867
16898
  text-align: left;
@@ -16869,9 +16900,9 @@ button:hover {
16869
16900
  }
16870
16901
  .contactform--container input {
16871
16902
  display: block;
16872
- font-family: "lato", Calibri, Tahoma, sans-serif;
16903
+ font-family: "lato", Helvetica, sans-serif;
16873
16904
  padding: 5px 15px;
16874
- width: 25%;
16905
+ width: 300px !important;
16875
16906
  display: block;
16876
16907
  margin: 0 auto;
16877
16908
  text-align: left;
@@ -16885,7 +16916,7 @@ button:hover {
16885
16916
  font-weight: 300;
16886
16917
  transition: all 0.3s ease;
16887
16918
  }
16888
- @media screen and (max-width: 700px) {
16919
+ @media screen and (max-width: 1200px) {
16889
16920
  .contactform--container input {
16890
16921
  width: unset;
16891
16922
  }
@@ -16893,9 +16924,29 @@ button:hover {
16893
16924
  .contactform--container button {
16894
16925
  background-color: #e9a0a1;
16895
16926
  color: #fff;
16927
+ border: 0;
16928
+ border-radius: 30px;
16896
16929
  max-width: 20%;
16897
16930
  display: inline-block;
16898
16931
  min-height: 50px;
16932
+ font-family: "lato", Helvetica, sans-serif;
16933
+ padding: 10px 35px;
16934
+ min-width: 150px;
16935
+ margin-bottom: 20px;
16936
+ font-size: 1rem;
16937
+ font-weight: 300;
16938
+ line-height: 23px;
16939
+ transition: transform 150ms;
16940
+ }
16941
+
16942
+ .video--container {
16943
+ padding: 50px;
16944
+ }
16945
+ @media screen and (max-width: 1200px) {
16946
+ .video--container {
16947
+ padding: 100px 15px;
16948
+ width: 92%;
16949
+ }
16899
16950
  }
16900
16951
 
16901
16952
  .fade-in {
@@ -16934,16 +16985,31 @@ button:hover {
16934
16985
  margin-bottom: 0px;
16935
16986
  }
16936
16987
 
16988
+ .u-margin--bt {
16989
+ margin-bottom: 15px;
16990
+ }
16991
+
16937
16992
  .u-margin--top {
16938
16993
  margin-top: 15px;
16994
+ }
16995
+
16996
+ .questionnaire--video {
16997
+ width: 60%;
16998
+ min-height: 400px;
16999
+ }
17000
+ @media screen and (max-width: 1200px) {
17001
+ .questionnaire--video {
17002
+ width: 100%;
17003
+ min-height: 200px;
17004
+ }
16939
17005
  }`;
16940
17006
 
16941
17007
  // js/questionnaire.ts
16942
17008
  var QuestionnaireElement = class extends s4 {
16943
17009
  constructor() {
16944
- super();
17010
+ super(...arguments);
17011
+ this.visitedNodes = [];
16945
17012
  this.hubspotId = "40834387";
16946
- this.addEventListener("click", this.openModal);
16947
17013
  }
16948
17014
  get topic() {
16949
17015
  return `questionnaires:${this.siteId}`;
@@ -16961,8 +17027,7 @@ button:hover {
16961
17027
  }
16962
17028
  render() {
16963
17029
  return x`
16964
- <h2>Questionnaire</h2>
16965
- <slot></slot>
17030
+ <button class="button--begin" @click=${this.openModal}><slot>Begin</slot></button>
16966
17031
  <dialog id="question-modal" class="questionnaire--modal">${this.renderCurrentStep()}</dialog>
16967
17032
  `;
16968
17033
  }
@@ -16978,15 +17043,19 @@ button:hover {
16978
17043
  }
16979
17044
  renderVideo() {
16980
17045
  return x`
16981
- <div>${this.currentStep.text}</div>
16982
- <vimeo-video controls src=${this.currentStep.url}></vimeo-video>
17046
+ <div class="video--container">
17047
+ <h1 class="u-margin-none--bt">Thanks for that!</h1>
17048
+ <h2 class="u-margin--bt">${this.currentStep.text}</h2>
17049
+ <span class="questionnaire--video">
17050
+ <vimeo-video controls src=${this.currentStep.url} class="questionnaire--video"></vimeo-video></span>
17051
+ </div>
16983
17052
  `;
16984
17053
  }
16985
17054
  renderContactInfo() {
16986
17055
  return x`
16987
- <form class="contactform--container">
17056
+ <form class="contactform--container" @submit=${this.submitContactInfo}>
16988
17057
  <h1 class="u-margin-none--bt">We think we can help.</h1>
16989
- <h2>Enter your information below to get your assesment.</h2>
17058
+ <h2>${this.currentStep.text}</h2>
16990
17059
  <div class="u-margin--top">
16991
17060
  <label for="name">Name</label>
16992
17061
  <input type="text" id="name" name="name" required/>
@@ -16999,7 +17068,7 @@ button:hover {
16999
17068
  <label for="phone">Phone</label>
17000
17069
  <input type="tel" id="phone" name="phone" required/>
17001
17070
  </div>
17002
- <button type="submit" @click=${this.submitContactInfo}>Submit</button>
17071
+ <button type="submit">Submit</button>
17003
17072
  </form>
17004
17073
  `;
17005
17074
  }
@@ -17009,7 +17078,8 @@ button:hover {
17009
17078
  <div class="questionnaire--header">
17010
17079
  <h1> ${this.questionnaireName} </h1>
17011
17080
  </div>
17012
- <div class="questionnaire--question"> <h2>${question.text}</h2></div>
17081
+ <div class="questionnaire--question"><h2>${question.text}</h2></div>
17082
+ <div class="questionnaire--subtitle"><h3>${question.subtitle}</h3></div>
17013
17083
  <div class="questionnaire--bt-contain">
17014
17084
  <div class="questionnaire-illustration"><img src=${question.url}> </div>
17015
17085
  <div>
@@ -17018,13 +17088,16 @@ button:hover {
17018
17088
  `)}
17019
17089
  </div>
17020
17090
  </div>
17091
+ ${this.visitedNodes.length > 1 ? x`<button class="button--link" @click=${this.goBack}>Back</button>` : x``}
17021
17092
  `;
17022
17093
  }
17023
17094
  openModal() {
17024
17095
  this.modal?.showModal();
17025
17096
  }
17097
+ goBack(_event) {
17098
+ this.dispatchEvent(new CustomEvent("goBack"));
17099
+ }
17026
17100
  answerQuestion(event) {
17027
- console.log(event);
17028
17101
  event.stopPropagation();
17029
17102
  this.dispatchEvent(new CustomEvent("answerQuestion", {
17030
17103
  detail: {
@@ -17033,16 +17106,21 @@ button:hover {
17033
17106
  }));
17034
17107
  }
17035
17108
  submitContactInfo(event) {
17036
- event.preventDefault();
17037
17109
  event.stopPropagation();
17038
- this.dispatchEvent(new CustomEvent("submitContactInfo", {
17039
- detail: {
17040
- nodeId: this.currentStep?.id,
17041
- name: this.nameInput.value,
17042
- email: this.emailInput.value,
17043
- phone_number: this.phoneInput.value
17044
- }
17045
- }));
17110
+ event.preventDefault();
17111
+ if (this.contactInfoForm?.checkValidity()) {
17112
+ const email = this.emailInput?.value;
17113
+ window["_hsq"] = window["_hsq"] || [];
17114
+ window["_hsq"].push(["identify", { email }]);
17115
+ this.dispatchEvent(new CustomEvent("submitContactInfo", {
17116
+ detail: {
17117
+ nodeId: this.currentStep?.id,
17118
+ name: this.nameInput.value,
17119
+ email,
17120
+ phone_number: this.phoneInput.value
17121
+ }
17122
+ }));
17123
+ }
17046
17124
  }
17047
17125
  };
17048
17126
  QuestionnaireElement.styles = questionnaire_lit_default;
@@ -17052,6 +17130,9 @@ button:hover {
17052
17130
  __decorateClass([
17053
17131
  t3()
17054
17132
  ], QuestionnaireElement.prototype, "questionnaireName", 2);
17133
+ __decorateClass([
17134
+ t3()
17135
+ ], QuestionnaireElement.prototype, "visitedNodes", 2);
17055
17136
  __decorateClass([
17056
17137
  n5(),
17057
17138
  liveStateConfig("url")
@@ -17074,15 +17155,18 @@ button:hover {
17074
17155
  __decorateClass([
17075
17156
  i4("#phone")
17076
17157
  ], QuestionnaireElement.prototype, "phoneInput", 2);
17158
+ __decorateClass([
17159
+ i4("form")
17160
+ ], QuestionnaireElement.prototype, "contactInfoForm", 2);
17077
17161
  __decorateClass([
17078
17162
  liveStateConfig("topic")
17079
17163
  ], QuestionnaireElement.prototype, "topic", 1);
17080
17164
  QuestionnaireElement = __decorateClass([
17081
17165
  e4("pr360-questionnaire"),
17082
17166
  liveStateDecorator_default({
17083
- properties: ["currentStep", "questionnaireName"],
17167
+ properties: ["currentStep", "questionnaireName", "visitedNodes"],
17084
17168
  events: {
17085
- send: ["answerQuestion", "submitContactInfo"]
17169
+ send: ["answerQuestion", "submitContactInfo", "goBack"]
17086
17170
  },
17087
17171
  provide: {
17088
17172
  scope: window,
@@ -31466,16 +31550,18 @@ ${inspect(response)}
31466
31550
 
31467
31551
  // test/questionnaire-test.ts
31468
31552
  describe("questionnaire test", async () => {
31553
+ let questionnaireElement;
31469
31554
  beforeEach(async () => {
31470
31555
  window["questionnaireState"] = sinon_esm_default.createStubInstance(src_default);
31471
- });
31472
- it("renders a question", async () => {
31473
- const questionnaireElement = await fixture(`
31556
+ questionnaireElement = await fixture(`
31474
31557
  <pr360-questionnaire url="wss://foo.bar">
31475
31558
  <button>Click me</button>
31476
31559
  </pr360-questionnaire>
31477
31560
  `);
31561
+ });
31562
+ it("renders a question", async () => {
31478
31563
  questionnaireElement.currentStep = {
31564
+ subtitle: "foo",
31479
31565
  id: "1",
31480
31566
  type: "Question",
31481
31567
  text: "What is your favorite color?",
@@ -31494,11 +31580,6 @@ ${inspect(response)}
31494
31580
  f2(questionnaireElement.shadowRoot?.textContent).to.contain("What is your favorite color?");
31495
31581
  });
31496
31582
  it("adds hubspot tracking code", async () => {
31497
- const questionnaireElement = await fixture(`
31498
- <pr360-questionnaire url="wss://foo.bar">
31499
- <button>Click me</button>
31500
- </pr360-questionnaire>
31501
- `);
31502
31583
  const script = document.querySelector("script#hs-script-loader");
31503
31584
  f2(script).to.not.be.null;
31504
31585
  });
@@ -2,21 +2,21 @@
2
2
 
3
3
  h1 {
4
4
  font-size: 2rem;
5
- font-family: 'Lato', Calibri, Tahoma, sans-serif;
5
+ font-family: 'Lato', Helvetica, sans-serif;
6
6
  font-weight: 700;
7
7
 
8
8
  }
9
9
  h2 {
10
10
  font-weight: 300;
11
11
  margin: 0px;
12
- font-family: 'Lato', Calibri, Tahoma, sans-serif;
12
+ font-family: 'Lato', Helvetica, sans-serif;
13
13
  font-size: 1.5rem;
14
14
  }
15
15
 
16
16
  h3 {
17
17
  font-weight: 300;
18
18
  margin-top: 0px;
19
- font-family: 'Lato', Calibri, Tahoma, sans-serif;
19
+ font-family: 'Lato', Helvetica, sans-serif;
20
20
  font-size: 1rem;
21
21
 
22
22
  }
@@ -36,6 +36,7 @@ h3 {
36
36
  align-items: center;
37
37
  justify-content: center;
38
38
  padding: 0 30px;
39
+ min-height: 360px;
39
40
 
40
41
  @media screen and (max-width: 700px) {
41
42
  flex-direction: column;
@@ -59,15 +60,16 @@ h3 {
59
60
  max-width: 350px;
60
61
  }
61
62
 
62
- @media screen and (max-width: 700px) {
63
+ @media screen and (max-width: 1200px) {
63
64
  margin-bottom: 35px;
64
65
  }
65
66
  }
66
67
 
67
- button {
68
- font-family: "lato", Calibri, Tahoma, sans-serif;
68
+ .button--primary {
69
+ font-family: "lato", Helvetica, sans-serif;
69
70
  padding: 10px 35px;
70
- width: 400px;
71
+ min-width: 150px;
72
+ width: 35vw;
71
73
  min-height: 85px;
72
74
  display: block;
73
75
  border: 1px solid #8c8c8c;
@@ -79,26 +81,62 @@ button {
79
81
  line-height: 23px;
80
82
  transition: transform 150ms;
81
83
 
82
- @media screen and (max-width: 700px) {
84
+ @media screen and (max-width: 1200px) {
83
85
  height: unset;
84
86
  }
85
87
  }
86
88
 
87
- button:hover {
88
- border: 2px solid #e9a0a1;
89
- transform: translateY(4px);
89
+ .button--primary:hover {
90
+ border: 2px solid #e9a0a1;
91
+ transform: translateY(2px);
92
+ }
93
+
94
+
95
+ .button--begin {
96
+ font-family: "lato", Helvetica, sans-serif;
97
+ padding: 5px 25px;
98
+ min-height: 60px;
99
+ width: 150px;
100
+ border: 1px solid #cacaca;
101
+ border-radius: 20px;
102
+ background-color: #fff;
103
+ font-size: 1rem;
104
+ font-weight: 300;
105
+ transition: transform 150ms;
106
+
107
+ &:hover {
108
+ background-color: #efefef;
109
+ transform: translateY(2px);
110
+ }
111
+
112
+ }
113
+
114
+
115
+ .button--link {
116
+ color: #8c8c8c;
117
+ background-color: transparent;
118
+ border:none;
119
+ position: absolute;
120
+ top: 15px;
121
+ left: 15px;
122
+
123
+ &:hover {
124
+ text-decoration: underline;
125
+ }
90
126
  }
91
127
 
128
+
129
+
92
130
  .contactform--container {
93
131
  padding: 100px;
94
132
 
95
- @media screen and (max-width: 700px) {
133
+ @media screen and (max-width: 1200px) {
96
134
  padding: 100px 15px;
97
135
  width: 92%;
98
136
  }
99
137
 
100
138
  label {
101
- width: 28%;
139
+ width: 315px;
102
140
  display: block;
103
141
  margin: 0 auto;
104
142
  text-align: left;
@@ -107,9 +145,9 @@ button:hover {
107
145
 
108
146
  input {
109
147
  display: block;
110
- font-family: "lato", Calibri, Tahoma, sans-serif;
148
+ font-family: "lato", Helvetica, sans-serif;
111
149
  padding: 5px 15px;
112
- width: 25%;
150
+ width: 300px !important;
113
151
  display: block;
114
152
  margin: 0 auto;
115
153
  text-align: left;
@@ -123,7 +161,7 @@ button:hover {
123
161
  font-weight: 300;
124
162
  transition: all .3s ease;
125
163
 
126
- @media screen and (max-width: 700px) {
164
+ @media screen and (max-width: 1200px) {
127
165
  width: unset;
128
166
  }
129
167
  }
@@ -132,12 +170,31 @@ button:hover {
132
170
  button {
133
171
  background-color: #e9a0a1;
134
172
  color: #fff;
173
+ border: 0;
174
+ border-radius: 30px;
135
175
  max-width: 20%;
136
176
  display: inline-block;
137
177
  min-height: 50px;
178
+ font-family: "lato", Helvetica, sans-serif;
179
+ padding: 10px 35px;
180
+ min-width: 150px;
181
+ margin-bottom: 20px;
182
+ font-size: 1rem;
183
+ font-weight: 300;
184
+ line-height: 23px;
185
+ transition: transform 150ms;
138
186
  }
139
187
  }
140
188
 
189
+ .video--container {
190
+ padding: 50px;
191
+
192
+ @media screen and (max-width: 1200px) {
193
+ padding: 100px 15px;
194
+ width: 92%;
195
+ }
196
+ }
197
+
141
198
  .fade-in {
142
199
  animation: fadeIn ease 1.2s;
143
200
  -webkit-animation: fadeIn ease 1.2s;
@@ -176,6 +233,20 @@ button:hover {
176
233
  margin-bottom: 0px;
177
234
  }
178
235
 
236
+ .u-margin--bt {
237
+ margin-bottom: 15px;
238
+ }
239
+
179
240
  .u-margin--top {
180
241
  margin-top: 15px;
242
+ }
243
+
244
+ .questionnaire--video {
245
+ width: 60%;
246
+ min-height: 400px;
247
+
248
+ @media screen and (max-width: 1200px) {
249
+ width: 100%;
250
+ min-height: 200px;
251
+ }
181
252
  }
package/dist/index.js CHANGED
@@ -6957,21 +6957,21 @@
6957
6957
  @import url("https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&display=swap");
6958
6958
  h1 {
6959
6959
  font-size: 2rem;
6960
- font-family: "Lato", Calibri, Tahoma, sans-serif;
6960
+ font-family: "Lato", Helvetica, sans-serif;
6961
6961
  font-weight: 700;
6962
6962
  }
6963
6963
 
6964
6964
  h2 {
6965
6965
  font-weight: 300;
6966
6966
  margin: 0px;
6967
- font-family: "Lato", Calibri, Tahoma, sans-serif;
6967
+ font-family: "Lato", Helvetica, sans-serif;
6968
6968
  font-size: 1.5rem;
6969
6969
  }
6970
6970
 
6971
6971
  h3 {
6972
6972
  font-weight: 300;
6973
6973
  margin-top: 0px;
6974
- font-family: "Lato", Calibri, Tahoma, sans-serif;
6974
+ font-family: "Lato", Helvetica, sans-serif;
6975
6975
  font-size: 1rem;
6976
6976
  }
6977
6977
 
@@ -6990,6 +6990,7 @@ h3 {
6990
6990
  align-items: center;
6991
6991
  justify-content: center;
6992
6992
  padding: 0 30px;
6993
+ min-height: 360px;
6993
6994
  }
6994
6995
  @media screen and (max-width: 700px) {
6995
6996
  .questionnaire--bt-contain {
@@ -7013,16 +7014,17 @@ h3 {
7013
7014
  width: 80%;
7014
7015
  max-width: 350px;
7015
7016
  }
7016
- @media screen and (max-width: 700px) {
7017
+ @media screen and (max-width: 1200px) {
7017
7018
  .questionnaire-illustration {
7018
7019
  margin-bottom: 35px;
7019
7020
  }
7020
7021
  }
7021
7022
 
7022
- button {
7023
- font-family: "lato", Calibri, Tahoma, sans-serif;
7023
+ .button--primary {
7024
+ font-family: "lato", Helvetica, sans-serif;
7024
7025
  padding: 10px 35px;
7025
- width: 400px;
7026
+ min-width: 150px;
7027
+ width: 35vw;
7026
7028
  min-height: 85px;
7027
7029
  display: block;
7028
7030
  border: 1px solid #8c8c8c;
@@ -7034,28 +7036,57 @@ button {
7034
7036
  line-height: 23px;
7035
7037
  transition: transform 150ms;
7036
7038
  }
7037
- @media screen and (max-width: 700px) {
7038
- button {
7039
+ @media screen and (max-width: 1200px) {
7040
+ .button--primary {
7039
7041
  height: unset;
7040
7042
  }
7041
7043
  }
7042
7044
 
7043
- button:hover {
7045
+ .button--primary:hover {
7044
7046
  border: 2px solid #e9a0a1;
7045
- transform: translateY(4px);
7047
+ transform: translateY(2px);
7048
+ }
7049
+
7050
+ .button--begin {
7051
+ font-family: "lato", Helvetica, sans-serif;
7052
+ padding: 5px 25px;
7053
+ min-height: 60px;
7054
+ width: 150px;
7055
+ border: 1px solid #cacaca;
7056
+ border-radius: 20px;
7057
+ background-color: #fff;
7058
+ font-size: 1rem;
7059
+ font-weight: 300;
7060
+ transition: transform 150ms;
7061
+ }
7062
+ .button--begin:hover {
7063
+ background-color: #efefef;
7064
+ transform: translateY(2px);
7065
+ }
7066
+
7067
+ .button--link {
7068
+ color: #8c8c8c;
7069
+ background-color: transparent;
7070
+ border: none;
7071
+ position: absolute;
7072
+ top: 15px;
7073
+ left: 15px;
7074
+ }
7075
+ .button--link:hover {
7076
+ text-decoration: underline;
7046
7077
  }
7047
7078
 
7048
7079
  .contactform--container {
7049
7080
  padding: 100px;
7050
7081
  }
7051
- @media screen and (max-width: 700px) {
7082
+ @media screen and (max-width: 1200px) {
7052
7083
  .contactform--container {
7053
7084
  padding: 100px 15px;
7054
7085
  width: 92%;
7055
7086
  }
7056
7087
  }
7057
7088
  .contactform--container label {
7058
- width: 28%;
7089
+ width: 315px;
7059
7090
  display: block;
7060
7091
  margin: 0 auto;
7061
7092
  text-align: left;
@@ -7063,9 +7094,9 @@ button:hover {
7063
7094
  }
7064
7095
  .contactform--container input {
7065
7096
  display: block;
7066
- font-family: "lato", Calibri, Tahoma, sans-serif;
7097
+ font-family: "lato", Helvetica, sans-serif;
7067
7098
  padding: 5px 15px;
7068
- width: 25%;
7099
+ width: 300px !important;
7069
7100
  display: block;
7070
7101
  margin: 0 auto;
7071
7102
  text-align: left;
@@ -7079,7 +7110,7 @@ button:hover {
7079
7110
  font-weight: 300;
7080
7111
  transition: all 0.3s ease;
7081
7112
  }
7082
- @media screen and (max-width: 700px) {
7113
+ @media screen and (max-width: 1200px) {
7083
7114
  .contactform--container input {
7084
7115
  width: unset;
7085
7116
  }
@@ -7087,9 +7118,29 @@ button:hover {
7087
7118
  .contactform--container button {
7088
7119
  background-color: #e9a0a1;
7089
7120
  color: #fff;
7121
+ border: 0;
7122
+ border-radius: 30px;
7090
7123
  max-width: 20%;
7091
7124
  display: inline-block;
7092
7125
  min-height: 50px;
7126
+ font-family: "lato", Helvetica, sans-serif;
7127
+ padding: 10px 35px;
7128
+ min-width: 150px;
7129
+ margin-bottom: 20px;
7130
+ font-size: 1rem;
7131
+ font-weight: 300;
7132
+ line-height: 23px;
7133
+ transition: transform 150ms;
7134
+ }
7135
+
7136
+ .video--container {
7137
+ padding: 50px;
7138
+ }
7139
+ @media screen and (max-width: 1200px) {
7140
+ .video--container {
7141
+ padding: 100px 15px;
7142
+ width: 92%;
7143
+ }
7093
7144
  }
7094
7145
 
7095
7146
  .fade-in {
@@ -7128,16 +7179,31 @@ button:hover {
7128
7179
  margin-bottom: 0px;
7129
7180
  }
7130
7181
 
7182
+ .u-margin--bt {
7183
+ margin-bottom: 15px;
7184
+ }
7185
+
7131
7186
  .u-margin--top {
7132
7187
  margin-top: 15px;
7188
+ }
7189
+
7190
+ .questionnaire--video {
7191
+ width: 60%;
7192
+ min-height: 400px;
7193
+ }
7194
+ @media screen and (max-width: 1200px) {
7195
+ .questionnaire--video {
7196
+ width: 100%;
7197
+ min-height: 200px;
7198
+ }
7133
7199
  }`;
7134
7200
 
7135
7201
  // js/questionnaire.ts
7136
7202
  var QuestionnaireElement = class extends s4 {
7137
7203
  constructor() {
7138
- super();
7204
+ super(...arguments);
7205
+ this.visitedNodes = [];
7139
7206
  this.hubspotId = "40834387";
7140
- this.addEventListener("click", this.openModal);
7141
7207
  }
7142
7208
  get topic() {
7143
7209
  return `questionnaires:${this.siteId}`;
@@ -7155,8 +7221,7 @@ button:hover {
7155
7221
  }
7156
7222
  render() {
7157
7223
  return x`
7158
- <h2>Questionnaire</h2>
7159
- <slot></slot>
7224
+ <button class="button--begin" @click=${this.openModal}><slot>Begin</slot></button>
7160
7225
  <dialog id="question-modal" class="questionnaire--modal">${this.renderCurrentStep()}</dialog>
7161
7226
  `;
7162
7227
  }
@@ -7172,15 +7237,19 @@ button:hover {
7172
7237
  }
7173
7238
  renderVideo() {
7174
7239
  return x`
7175
- <div>${this.currentStep.text}</div>
7176
- <vimeo-video controls src=${this.currentStep.url}></vimeo-video>
7240
+ <div class="video--container">
7241
+ <h1 class="u-margin-none--bt">Thanks for that!</h1>
7242
+ <h2 class="u-margin--bt">${this.currentStep.text}</h2>
7243
+ <span class="questionnaire--video">
7244
+ <vimeo-video controls src=${this.currentStep.url} class="questionnaire--video"></vimeo-video></span>
7245
+ </div>
7177
7246
  `;
7178
7247
  }
7179
7248
  renderContactInfo() {
7180
7249
  return x`
7181
- <form class="contactform--container">
7250
+ <form class="contactform--container" @submit=${this.submitContactInfo}>
7182
7251
  <h1 class="u-margin-none--bt">We think we can help.</h1>
7183
- <h2>Enter your information below to get your assesment.</h2>
7252
+ <h2>${this.currentStep.text}</h2>
7184
7253
  <div class="u-margin--top">
7185
7254
  <label for="name">Name</label>
7186
7255
  <input type="text" id="name" name="name" required/>
@@ -7193,7 +7262,7 @@ button:hover {
7193
7262
  <label for="phone">Phone</label>
7194
7263
  <input type="tel" id="phone" name="phone" required/>
7195
7264
  </div>
7196
- <button type="submit" @click=${this.submitContactInfo}>Submit</button>
7265
+ <button type="submit">Submit</button>
7197
7266
  </form>
7198
7267
  `;
7199
7268
  }
@@ -7203,7 +7272,8 @@ button:hover {
7203
7272
  <div class="questionnaire--header">
7204
7273
  <h1> ${this.questionnaireName} </h1>
7205
7274
  </div>
7206
- <div class="questionnaire--question"> <h2>${question.text}</h2></div>
7275
+ <div class="questionnaire--question"><h2>${question.text}</h2></div>
7276
+ <div class="questionnaire--subtitle"><h3>${question.subtitle}</h3></div>
7207
7277
  <div class="questionnaire--bt-contain">
7208
7278
  <div class="questionnaire-illustration"><img src=${question.url}> </div>
7209
7279
  <div>
@@ -7212,13 +7282,16 @@ button:hover {
7212
7282
  `)}
7213
7283
  </div>
7214
7284
  </div>
7285
+ ${this.visitedNodes.length > 1 ? x`<button class="button--link" @click=${this.goBack}>Back</button>` : x``}
7215
7286
  `;
7216
7287
  }
7217
7288
  openModal() {
7218
7289
  this.modal?.showModal();
7219
7290
  }
7291
+ goBack(_event) {
7292
+ this.dispatchEvent(new CustomEvent("goBack"));
7293
+ }
7220
7294
  answerQuestion(event) {
7221
- console.log(event);
7222
7295
  event.stopPropagation();
7223
7296
  this.dispatchEvent(new CustomEvent("answerQuestion", {
7224
7297
  detail: {
@@ -7227,16 +7300,21 @@ button:hover {
7227
7300
  }));
7228
7301
  }
7229
7302
  submitContactInfo(event) {
7230
- event.preventDefault();
7231
7303
  event.stopPropagation();
7232
- this.dispatchEvent(new CustomEvent("submitContactInfo", {
7233
- detail: {
7234
- nodeId: this.currentStep?.id,
7235
- name: this.nameInput.value,
7236
- email: this.emailInput.value,
7237
- phone_number: this.phoneInput.value
7238
- }
7239
- }));
7304
+ event.preventDefault();
7305
+ if (this.contactInfoForm?.checkValidity()) {
7306
+ const email = this.emailInput?.value;
7307
+ window["_hsq"] = window["_hsq"] || [];
7308
+ window["_hsq"].push(["identify", { email }]);
7309
+ this.dispatchEvent(new CustomEvent("submitContactInfo", {
7310
+ detail: {
7311
+ nodeId: this.currentStep?.id,
7312
+ name: this.nameInput.value,
7313
+ email,
7314
+ phone_number: this.phoneInput.value
7315
+ }
7316
+ }));
7317
+ }
7240
7318
  }
7241
7319
  };
7242
7320
  QuestionnaireElement.styles = questionnaire_lit_default;
@@ -7246,6 +7324,9 @@ button:hover {
7246
7324
  __decorateClass([
7247
7325
  t3()
7248
7326
  ], QuestionnaireElement.prototype, "questionnaireName", 2);
7327
+ __decorateClass([
7328
+ t3()
7329
+ ], QuestionnaireElement.prototype, "visitedNodes", 2);
7249
7330
  __decorateClass([
7250
7331
  n5(),
7251
7332
  liveStateConfig("url")
@@ -7268,15 +7349,18 @@ button:hover {
7268
7349
  __decorateClass([
7269
7350
  i4("#phone")
7270
7351
  ], QuestionnaireElement.prototype, "phoneInput", 2);
7352
+ __decorateClass([
7353
+ i4("form")
7354
+ ], QuestionnaireElement.prototype, "contactInfoForm", 2);
7271
7355
  __decorateClass([
7272
7356
  liveStateConfig("topic")
7273
7357
  ], QuestionnaireElement.prototype, "topic", 1);
7274
7358
  QuestionnaireElement = __decorateClass([
7275
7359
  e4("pr360-questionnaire"),
7276
7360
  liveStateDecorator_default({
7277
- properties: ["currentStep", "questionnaireName"],
7361
+ properties: ["currentStep", "questionnaireName", "visitedNodes"],
7278
7362
  events: {
7279
- send: ["answerQuestion", "submitContactInfo"]
7363
+ send: ["answerQuestion", "submitContactInfo", "goBack"]
7280
7364
  },
7281
7365
  provide: {
7282
7366
  scope: window,
package/js/app.js CHANGED
@@ -21,9 +21,16 @@ import "phoenix_html"
21
21
  import {Socket} from "phoenix"
22
22
  import {LiveSocket} from "phoenix_live_view"
23
23
  import topbar from "../vendor/topbar"
24
+ import Prism from './prism';
25
+
26
+ const PrismHook = {
27
+ mounted() { this.highlight() },
28
+ reconnected() { this.highlight() },
29
+ highlight() { Prism.highlightAll() }
30
+ };
24
31
 
25
32
  let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
26
- let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}})
33
+ let liveSocket = new LiveSocket("/live", Socket, {params: {_csrf_token: csrfToken}, hooks: {Prism: PrismHook}})
27
34
 
28
35
  // Show progress bar on live navigation and form submits
29
36
  topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"})
@@ -39,4 +46,4 @@ liveSocket.connect()
39
46
  // >> liveSocket.disableLatencySim()
40
47
  window.liveSocket = liveSocket
41
48
 
42
- import './questionnaire.ts'
49
+ import './questionnaire.ts';
package/js/prism.js ADDED
@@ -0,0 +1,7 @@
1
+ /* PrismJS 1.29.0
2
+ https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup&plugins=unescaped-markup+toolbar+copy-to-clipboard */
3
+ var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(e){var n=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,t=0,r={},a={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(n){return n instanceof i?new i(n.type,e(n.content),n.alias):Array.isArray(n)?n.map(e):n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).slice(8,-1)},objId:function(e){return e.__id||Object.defineProperty(e,"__id",{value:++t}),e.__id},clone:function e(n,t){var r,i;switch(t=t||{},a.util.type(n)){case"Object":if(i=a.util.objId(n),t[i])return t[i];for(var l in r={},t[i]=r,n)n.hasOwnProperty(l)&&(r[l]=e(n[l],t));return r;case"Array":return i=a.util.objId(n),t[i]?t[i]:(r=[],t[i]=r,n.forEach((function(n,a){r[a]=e(n,t)})),r);default:return n}},getLanguage:function(e){for(;e;){var t=n.exec(e.className);if(t)return t[1].toLowerCase();e=e.parentElement}return"none"},setLanguage:function(e,t){e.className=e.className.replace(RegExp(n,"gi"),""),e.classList.add("language-"+t)},currentScript:function(){if("undefined"==typeof document)return null;if("currentScript"in document)return document.currentScript;try{throw new Error}catch(r){var e=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(r.stack)||[])[1];if(e){var n=document.getElementsByTagName("script");for(var t in n)if(n[t].src==e)return n[t]}return null}},isActive:function(e,n,t){for(var r="no-"+n;e;){var a=e.classList;if(a.contains(n))return!0;if(a.contains(r))return!1;e=e.parentElement}return!!t}},languages:{plain:r,plaintext:r,text:r,txt:r,extend:function(e,n){var t=a.util.clone(a.languages[e]);for(var r in n)t[r]=n[r];return t},insertBefore:function(e,n,t,r){var i=(r=r||a.languages)[e],l={};for(var o in i)if(i.hasOwnProperty(o)){if(o==n)for(var s in t)t.hasOwnProperty(s)&&(l[s]=t[s]);t.hasOwnProperty(o)||(l[o]=i[o])}var u=r[e];return r[e]=l,a.languages.DFS(a.languages,(function(n,t){t===u&&n!=e&&(this[n]=l)})),l},DFS:function e(n,t,r,i){i=i||{};var l=a.util.objId;for(var o in n)if(n.hasOwnProperty(o)){t.call(n,o,n[o],r||o);var s=n[o],u=a.util.type(s);"Object"!==u||i[l(s)]?"Array"!==u||i[l(s)]||(i[l(s)]=!0,e(s,t,o,i)):(i[l(s)]=!0,e(s,t,null,i))}}},plugins:{},highlightAll:function(e,n){a.highlightAllUnder(document,e,n)},highlightAllUnder:function(e,n,t){var r={callback:t,container:e,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};a.hooks.run("before-highlightall",r),r.elements=Array.prototype.slice.apply(r.container.querySelectorAll(r.selector)),a.hooks.run("before-all-elements-highlight",r);for(var i,l=0;i=r.elements[l++];)a.highlightElement(i,!0===n,r.callback)},highlightElement:function(n,t,r){var i=a.util.getLanguage(n),l=a.languages[i];a.util.setLanguage(n,i);var o=n.parentElement;o&&"pre"===o.nodeName.toLowerCase()&&a.util.setLanguage(o,i);var s={element:n,language:i,grammar:l,code:n.textContent};function u(e){s.highlightedCode=e,a.hooks.run("before-insert",s),s.element.innerHTML=s.highlightedCode,a.hooks.run("after-highlight",s),a.hooks.run("complete",s),r&&r.call(s.element)}if(a.hooks.run("before-sanity-check",s),(o=s.element.parentElement)&&"pre"===o.nodeName.toLowerCase()&&!o.hasAttribute("tabindex")&&o.setAttribute("tabindex","0"),!s.code)return a.hooks.run("complete",s),void(r&&r.call(s.element));if(a.hooks.run("before-highlight",s),s.grammar)if(t&&e.Worker){var c=new Worker(a.filename);c.onmessage=function(e){u(e.data)},c.postMessage(JSON.stringify({language:s.language,code:s.code,immediateClose:!0}))}else u(a.highlight(s.code,s.grammar,s.language));else u(a.util.encode(s.code))},highlight:function(e,n,t){var r={code:e,grammar:n,language:t};if(a.hooks.run("before-tokenize",r),!r.grammar)throw new Error('The language "'+r.language+'" has no grammar.');return r.tokens=a.tokenize(r.code,r.grammar),a.hooks.run("after-tokenize",r),i.stringify(a.util.encode(r.tokens),r.language)},tokenize:function(e,n){var t=n.rest;if(t){for(var r in t)n[r]=t[r];delete n.rest}var a=new s;return u(a,a.head,e),o(e,a,n,a.head,0),function(e){for(var n=[],t=e.head.next;t!==e.tail;)n.push(t.value),t=t.next;return n}(a)},hooks:{all:{},add:function(e,n){var t=a.hooks.all;t[e]=t[e]||[],t[e].push(n)},run:function(e,n){var t=a.hooks.all[e];if(t&&t.length)for(var r,i=0;r=t[i++];)r(n)}},Token:i};function i(e,n,t,r){this.type=e,this.content=n,this.alias=t,this.length=0|(r||"").length}function l(e,n,t,r){e.lastIndex=n;var a=e.exec(t);if(a&&r&&a[1]){var i=a[1].length;a.index+=i,a[0]=a[0].slice(i)}return a}function o(e,n,t,r,s,g){for(var f in t)if(t.hasOwnProperty(f)&&t[f]){var h=t[f];h=Array.isArray(h)?h:[h];for(var d=0;d<h.length;++d){if(g&&g.cause==f+","+d)return;var v=h[d],p=v.inside,m=!!v.lookbehind,y=!!v.greedy,k=v.alias;if(y&&!v.pattern.global){var x=v.pattern.toString().match(/[imsuy]*$/)[0];v.pattern=RegExp(v.pattern.source,x+"g")}for(var b=v.pattern||v,w=r.next,A=s;w!==n.tail&&!(g&&A>=g.reach);A+=w.value.length,w=w.next){var E=w.value;if(n.length>e.length)return;if(!(E instanceof i)){var P,L=1;if(y){if(!(P=l(b,A,e,m))||P.index>=e.length)break;var S=P.index,O=P.index+P[0].length,j=A;for(j+=w.value.length;S>=j;)j+=(w=w.next).value.length;if(A=j-=w.value.length,w.value instanceof i)continue;for(var C=w;C!==n.tail&&(j<O||"string"==typeof C.value);C=C.next)L++,j+=C.value.length;L--,E=e.slice(A,j),P.index-=A}else if(!(P=l(b,0,E,m)))continue;S=P.index;var N=P[0],_=E.slice(0,S),M=E.slice(S+N.length),W=A+E.length;g&&W>g.reach&&(g.reach=W);var z=w.prev;if(_&&(z=u(n,z,_),A+=_.length),c(n,z,L),w=u(n,z,new i(f,p?a.tokenize(N,p):N,k,N)),M&&u(n,w,M),L>1){var I={cause:f+","+d,reach:W};o(e,n,t,w.prev,A,I),g&&I.reach>g.reach&&(g.reach=I.reach)}}}}}}function s(){var e={value:null,prev:null,next:null},n={value:null,prev:e,next:null};e.next=n,this.head=e,this.tail=n,this.length=0}function u(e,n,t){var r=n.next,a={value:t,prev:n,next:r};return n.next=a,r.prev=a,e.length++,a}function c(e,n,t){for(var r=n.next,a=0;a<t&&r!==e.tail;a++)r=r.next;n.next=r,r.prev=n,e.length-=a}if(e.Prism=a,i.stringify=function e(n,t){if("string"==typeof n)return n;if(Array.isArray(n)){var r="";return n.forEach((function(n){r+=e(n,t)})),r}var i={type:n.type,content:e(n.content,t),tag:"span",classes:["token",n.type],attributes:{},language:t},l=n.alias;l&&(Array.isArray(l)?Array.prototype.push.apply(i.classes,l):i.classes.push(l)),a.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=" "+s+'="'+(i.attributes[s]||"").replace(/"/g,"&quot;")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'"'+o+">"+i.content+"</"+i.tag+">"},!e.document)return e.addEventListener?(a.disableWorkerMessageHandler||e.addEventListener("message",(function(n){var t=JSON.parse(n.data),r=t.language,i=t.code,l=t.immediateClose;e.postMessage(a.highlight(i,a.languages[r],r)),l&&e.close()}),!1),a):a;var g=a.util.currentScript();function f(){a.manual||a.highlightAll()}if(g&&(a.filename=g.src,g.hasAttribute("data-manual")&&(a.manual=!0)),!a.manual){var h=document.readyState;"loading"===h||"interactive"===h&&g&&g.defer?document.addEventListener("DOMContentLoaded",f):window.requestAnimationFrame?window.requestAnimationFrame(f):window.setTimeout(f,16)}return a}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism);
4
+ Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup,Prism.hooks.add("wrap",(function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&amp;/,"&"))})),Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(a,e){var s={};s["language-"+e]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[e]},s.cdata=/^<!\[CDATA\[|\]\]>$/i;var t={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:s}};t["language-"+e]={pattern:/[\s\S]+/,inside:Prism.languages[e]};var n={};n[a]={pattern:RegExp("(<__[^>]*>)(?:<!\\[CDATA\\[(?:[^\\]]|\\](?!\\]>))*\\]\\]>|(?!<!\\[CDATA\\[)[^])*?(?=</__>)".replace(/__/g,(function(){return a})),"i"),lookbehind:!0,greedy:!0,inside:t},Prism.languages.insertBefore("markup","cdata",n)}}),Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(a,e){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp("(^|[\"'\\s])(?:"+a+")\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s'\">=]+(?=[\\s>]))","i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[e,"language-"+e],inside:Prism.languages[e]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup,Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.ssml=Prism.languages.xml,Prism.languages.atom=Prism.languages.xml,Prism.languages.rss=Prism.languages.xml;
5
+ "undefined"!=typeof Prism&&"undefined"!=typeof document&&(Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector),Prism.plugins.UnescapedMarkup=!0,Prism.hooks.add("before-highlightall",(function(e){e.selector+=', [class*="lang-"] script[type="text/plain"], [class*="language-"] script[type="text/plain"], script[type="text/plain"][class*="lang-"], script[type="text/plain"][class*="language-"]'})),Prism.hooks.add("before-sanity-check",(function(e){var t=e.element;if(t.matches('script[type="text/plain"]')){var a=document.createElement("code"),c=document.createElement("pre");c.className=a.className=t.className;var n=t.dataset;return Object.keys(n||{}).forEach((function(e){Object.prototype.hasOwnProperty.call(n,e)&&(c.dataset[e]=n[e])})),a.textContent=e.code=e.code.replace(/&lt;\/script(?:>|&gt;)/gi,"<\/script>"),c.appendChild(a),t.parentNode.replaceChild(c,t),void(e.element=a)}if(!e.code){var o=t.childNodes;1===o.length&&"#comment"==o[0].nodeName&&(t.textContent=e.code=o[0].textContent)}})));
6
+ !function(){if("undefined"!=typeof Prism&&"undefined"!=typeof document){var e=[],t={},n=function(){};Prism.plugins.toolbar={};var a=Prism.plugins.toolbar.registerButton=function(n,a){var r;r="function"==typeof a?a:function(e){var t;return"function"==typeof a.onClick?((t=document.createElement("button")).type="button",t.addEventListener("click",(function(){a.onClick.call(this,e)}))):"string"==typeof a.url?(t=document.createElement("a")).href=a.url:t=document.createElement("span"),a.className&&t.classList.add(a.className),t.textContent=a.text,t},n in t?console.warn('There is a button with the key "'+n+'" registered already.'):e.push(t[n]=r)},r=Prism.plugins.toolbar.hook=function(a){var r=a.element.parentNode;if(r&&/pre/i.test(r.nodeName)&&!r.parentNode.classList.contains("code-toolbar")){var o=document.createElement("div");o.classList.add("code-toolbar"),r.parentNode.insertBefore(o,r),o.appendChild(r);var i=document.createElement("div");i.classList.add("toolbar");var l=e,d=function(e){for(;e;){var t=e.getAttribute("data-toolbar-order");if(null!=t)return(t=t.trim()).length?t.split(/\s*,\s*/g):[];e=e.parentElement}}(a.element);d&&(l=d.map((function(e){return t[e]||n}))),l.forEach((function(e){var t=e(a);if(t){var n=document.createElement("div");n.classList.add("toolbar-item"),n.appendChild(t),i.appendChild(n)}})),o.appendChild(i)}};a("label",(function(e){var t=e.element.parentNode;if(t&&/pre/i.test(t.nodeName)&&t.hasAttribute("data-label")){var n,a,r=t.getAttribute("data-label");try{a=document.querySelector("template#"+r)}catch(e){}return a?n=a.content:(t.hasAttribute("data-url")?(n=document.createElement("a")).href=t.getAttribute("data-url"):n=document.createElement("span"),n.textContent=r),n}})),Prism.hooks.add("complete",r)}}();
7
+ !function(){function t(t){var e=document.createElement("textarea");e.value=t.getText(),e.style.top="0",e.style.left="0",e.style.position="fixed",document.body.appendChild(e),e.focus(),e.select();try{var o=document.execCommand("copy");setTimeout((function(){o?t.success():t.error()}),1)}catch(e){setTimeout((function(){t.error(e)}),1)}document.body.removeChild(e)}"undefined"!=typeof Prism&&"undefined"!=typeof document&&(Prism.plugins.toolbar?Prism.plugins.toolbar.registerButton("copy-to-clipboard",(function(e){var o=e.element,n=function(t){var e={copy:"Copy","copy-error":"Press Ctrl+C to copy","copy-success":"Copied!","copy-timeout":5e3};for(var o in e){for(var n="data-prismjs-"+o,c=t;c&&!c.hasAttribute(n);)c=c.parentElement;c&&(e[o]=c.getAttribute(n))}return e}(o),c=document.createElement("button");c.className="copy-to-clipboard-button",c.setAttribute("type","button");var r=document.createElement("span");return c.appendChild(r),u("copy"),function(e,o){e.addEventListener("click",(function(){!function(e){navigator.clipboard?navigator.clipboard.writeText(e.getText()).then(e.success,(function(){t(e)})):t(e)}(o)}))}(c,{getText:function(){return o.textContent},success:function(){u("copy-success"),i()},error:function(){u("copy-error"),setTimeout((function(){!function(t){window.getSelection().selectAllChildren(t)}(o)}),1),i()}}),c;function i(){setTimeout((function(){u("copy")}),n["copy-timeout"])}function u(t){r.textContent=n[t],c.setAttribute("data-copy-state",t)}})):console.warn("Copy to Clipboard plugin loaded before Toolbar plugin."))}();
@@ -11,6 +11,7 @@ export type Question = {
11
11
  text: string;
12
12
  answers: Answer[];
13
13
  url: string;
14
+ subtitle: string;
14
15
  }
15
16
 
16
17
  export type Video = {
@@ -23,6 +24,7 @@ export type Video = {
23
24
  export type ContactInfo = {
24
25
  id: string;
25
26
  type: "ContactInfo";
27
+ text: string;
26
28
  }
27
29
 
28
30
  export type Answer = {
@@ -32,9 +34,9 @@ export type Answer = {
32
34
 
33
35
  @customElement('pr360-questionnaire')
34
36
  @liveState({
35
- properties: ['currentStep', "questionnaireName"],
37
+ properties: ['currentStep', 'questionnaireName', 'visitedNodes'],
36
38
  events: {
37
- send: ['answerQuestion', 'submitContactInfo']
39
+ send: ['answerQuestion', 'submitContactInfo', 'goBack']
38
40
  },
39
41
  provide: {
40
42
  scope: window,
@@ -43,10 +45,6 @@ export type Answer = {
43
45
  })
44
46
  export class QuestionnaireElement extends LitElement {
45
47
  static styles = questionnaireStyles;
46
- constructor() {
47
- super();
48
- this.addEventListener('click', this.openModal);
49
- }
50
48
 
51
49
  @state()
52
50
  currentStep: Question | ContactInfo | Video | undefined;
@@ -54,6 +52,9 @@ export class QuestionnaireElement extends LitElement {
54
52
  @state()
55
53
  questionnaireName: string;
56
54
 
55
+ @state()
56
+ visitedNodes: string[] = [];
57
+
57
58
  @property()
58
59
  @liveStateConfig('url')
59
60
  url: string | undefined;
@@ -76,6 +77,9 @@ export class QuestionnaireElement extends LitElement {
76
77
  @query('#phone')
77
78
  phoneInput: HTMLInputElement | undefined;
78
79
 
80
+ @query('form')
81
+ contactInfoForm: HTMLFormElement | undefined;
82
+
79
83
  @liveStateConfig('topic')
80
84
  get topic() {
81
85
  return `questionnaires:${this.siteId}`;
@@ -95,8 +99,7 @@ export class QuestionnaireElement extends LitElement {
95
99
 
96
100
  render() {
97
101
  return html`
98
- <h2>Questionnaire</h2>
99
- <slot></slot>
102
+ <button class="button--begin" @click=${this.openModal}><slot>Begin</slot></button>
100
103
  <dialog id="question-modal" class="questionnaire--modal">${this.renderCurrentStep()}</dialog>
101
104
  `;
102
105
  }
@@ -111,15 +114,19 @@ export class QuestionnaireElement extends LitElement {
111
114
 
112
115
  renderVideo() {
113
116
  return html`
114
- <div>${(this.currentStep as Video).text}</div>
115
- <vimeo-video controls src=${(this.currentStep as Video).url}></vimeo-video>
117
+ <div class="video--container">
118
+ <h1 class="u-margin-none--bt">Thanks for that!</h1>
119
+ <h2 class="u-margin--bt">${(this.currentStep as Video).text}</h2>
120
+ <span class="questionnaire--video">
121
+ <vimeo-video controls src=${(this.currentStep as Video).url} class="questionnaire--video"></vimeo-video></span>
122
+ </div>
116
123
  ` }
117
124
 
118
125
  renderContactInfo() {
119
126
  return html`
120
- <form class="contactform--container">
127
+ <form class="contactform--container" @submit=${this.submitContactInfo}>
121
128
  <h1 class="u-margin-none--bt">We think we can help.</h1>
122
- <h2>Enter your information below to get your assesment.</h2>
129
+ <h2>${(this.currentStep as ContactInfo).text}</h2>
123
130
  <div class="u-margin--top">
124
131
  <label for="name">Name</label>
125
132
  <input type="text" id="name" name="name" required/>
@@ -132,7 +139,7 @@ export class QuestionnaireElement extends LitElement {
132
139
  <label for="phone">Phone</label>
133
140
  <input type="tel" id="phone" name="phone" required/>
134
141
  </div>
135
- <button type="submit" @click=${this.submitContactInfo}>Submit</button>
142
+ <button type="submit">Submit</button>
136
143
  </form>
137
144
  `;
138
145
  }
@@ -143,7 +150,8 @@ export class QuestionnaireElement extends LitElement {
143
150
  <div class="questionnaire--header">
144
151
  <h1> ${this.questionnaireName} </h1>
145
152
  </div>
146
- <div class="questionnaire--question"> <h2>${question.text}</h2></div>
153
+ <div class="questionnaire--question"><h2>${question.text}</h2></div>
154
+ <div class="questionnaire--subtitle"><h3>${question.subtitle}</h3></div>
147
155
  <div class="questionnaire--bt-contain">
148
156
  <div class="questionnaire-illustration"><img src=${question.url}> </div>
149
157
  <div>
@@ -152,6 +160,7 @@ export class QuestionnaireElement extends LitElement {
152
160
  `)}
153
161
  </div>
154
162
  </div>
163
+ ${this.visitedNodes.length > 1 ? html`<button class="button--link" @click=${this.goBack}>Back</button>` : html``}
155
164
  `;
156
165
  }
157
166
 
@@ -159,8 +168,11 @@ export class QuestionnaireElement extends LitElement {
159
168
  this.modal?.showModal();
160
169
  }
161
170
 
171
+ goBack(_event) {
172
+ this.dispatchEvent(new CustomEvent('goBack'));
173
+ }
174
+
162
175
  answerQuestion(event: Event) {
163
- console.log(event);
164
176
  event.stopPropagation();
165
177
  this.dispatchEvent(new CustomEvent('answerQuestion', {
166
178
  detail: {
@@ -170,15 +182,20 @@ export class QuestionnaireElement extends LitElement {
170
182
  }
171
183
 
172
184
  submitContactInfo(event: Event) {
173
- event.preventDefault();
174
185
  event.stopPropagation();
175
- this.dispatchEvent(new CustomEvent('submitContactInfo', {
176
- detail: {
177
- nodeId: this.currentStep?.id,
178
- name: this.nameInput.value,
179
- email: this.emailInput.value,
180
- phone_number: this.phoneInput.value
181
- }
182
- }));
186
+ event.preventDefault();
187
+ if (this.contactInfoForm?.checkValidity()) {
188
+ const email = this.emailInput?.value;
189
+ window['_hsq'] = window['_hsq'] || [];
190
+ window['_hsq'].push(['identify', { email: email }]);
191
+ this.dispatchEvent(new CustomEvent('submitContactInfo', {
192
+ detail: {
193
+ nodeId: this.currentStep?.id,
194
+ name: this.nameInput.value,
195
+ email: email,
196
+ phone_number: this.phoneInput.value
197
+ }
198
+ }));
199
+ }
183
200
  }
184
201
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pr360-questionnaire",
3
3
  "description": "An element to render a questionnaire for PatientReach 360.",
4
- "version": "0.0.2",
4
+ "version": "0.0.3",
5
5
  "main": "dist/index.js",
6
6
  "author": {
7
7
  "email": "chris@launchscout.com",
@@ -12,7 +12,6 @@
12
12
  "type": "github",
13
13
  "url": "https://github.com/PatientReach360/patient_reach_360"
14
14
  },
15
-
16
15
  "scripts": {
17
16
  "build": "node build.mjs",
18
17
  "test": "web-test-runner \"build/questionnaire-test.js\" --node-resolve",
@@ -32,6 +31,7 @@
32
31
  "devDependencies": {
33
32
  "@open-wc/testing": "^3.2.0",
34
33
  "@web/test-runner": "^0.17.0",
34
+ "@web/test-runner-commands": "^0.8.0",
35
35
  "sinon": "^15.2.0",
36
36
  "typescript": "^5.1.6"
37
37
  }
@@ -1,21 +1,24 @@
1
1
  import '../js/questionnaire';
2
2
  import { expect } from "@esm-bundle/chai";
3
- import { QuestionnaireElement} from '../js/questionnaire';
3
+ import { ContactInfo, QuestionnaireElement} from '../js/questionnaire';
4
4
  import { fixture } from '@open-wc/testing';
5
+ import { sendKeys } from '@web/test-runner-commands';
5
6
  import LiveState from 'phx-live-state';
6
7
  import sinon from 'sinon';
7
8
 
8
9
  describe('questionnaire test', async () => {
10
+ let questionnaireElement: QuestionnaireElement;
9
11
  beforeEach(async () => {
10
12
  window['questionnaireState'] = sinon.createStubInstance(LiveState);
11
- });
12
- it('renders a question', async () => {
13
- const questionnaireElement: QuestionnaireElement = await fixture(`
13
+ questionnaireElement = await fixture(`
14
14
  <pr360-questionnaire url="wss://foo.bar">
15
15
  <button>Click me</button>
16
16
  </pr360-questionnaire>
17
17
  `);
18
+ });
19
+ it('renders a question', async () => {
18
20
  questionnaireElement.currentStep = {
21
+ subtitle: "foo",
19
22
  id: "1",
20
23
  type: "Question",
21
24
  text: "What is your favorite color?",
@@ -34,11 +37,6 @@ describe('questionnaire test', async () => {
34
37
  expect(questionnaireElement.shadowRoot?.textContent).to.contain("What is your favorite color?");
35
38
  });
36
39
  it('adds hubspot tracking code', async () => {
37
- const questionnaireElement: QuestionnaireElement = await fixture(`
38
- <pr360-questionnaire url="wss://foo.bar">
39
- <button>Click me</button>
40
- </pr360-questionnaire>
41
- `);
42
40
  const script = document.querySelector('script#hs-script-loader');
43
41
  expect(script).to.not.be.null;
44
42
  });