@worksafevictoria/wcl7.5 1.1.0-beta.3 → 1.1.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.
@@ -12,8 +12,7 @@ const config = {
12
12
  options: {}
13
13
  },
14
14
  docs: {
15
- autodocs: 'tag',
16
- defaultName: 'Documentation'
15
+ autodocs: 'tag'
17
16
  }
18
17
  }
19
18
  export default config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@worksafevictoria/wcl7.5",
3
- "version": "1.1.0-beta.3",
3
+ "version": "1.1.0",
4
4
  "main": "src/index.js",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -17,7 +17,6 @@
17
17
  >
18
18
  <search
19
19
  ref="searchInputBox"
20
- :google-search-flag="googleSearchFlag"
21
20
  :initial-search-query="searchQuery"
22
21
  :page-limit="pageLimit"
23
22
  :page-number="pageNumber"
@@ -32,7 +31,7 @@
32
31
  </template>
33
32
 
34
33
  <script>
35
- import Close from '../../../../assets/icons/close.svg?url'
34
+ import Close from '../../../../assets/icons/close.svg'
36
35
  import Search from '../../../SubComponents/Search/index.vue'
37
36
 
38
37
  export default {
@@ -46,10 +45,6 @@ export default {
46
45
  contentParser: {
47
46
  type: Function,
48
47
  required: true
49
- },
50
- googleSearchFlag: {
51
- type: String,
52
- default: 'googlerest'
53
48
  }
54
49
  },
55
50
  data() {
@@ -18,42 +18,45 @@ const contentParser = () => {
18
18
  export default {
19
19
  title: 'Global/AppHeader',
20
20
  component: AppHeader,
21
- tags: ['autodocs'],
22
21
  data() {
23
22
  return {
24
23
  appHeaderData
25
24
  }
26
25
  },
27
26
  argTypes: {
27
+ headerMenu: {
28
+ control: 'object',
29
+ defaultValue: appHeaderData
30
+ },
28
31
  contentParser: {
32
+ control: 'function',
33
+ defaultValue: contentParser,
29
34
  table: { disable: true }
35
+ },
36
+ isWorkWell: {
37
+ control: 'boolean',
38
+ defaultValue: false
39
+ },
40
+ authenticated: {
41
+ control: 'boolean',
42
+ defaultValue: false
30
43
  }
31
- },
32
- args: {
33
- headerMenu: appHeaderData,
34
- contentParser: contentParser,
35
- isWorkWell: false,
36
- authenticated: false,
37
- mainContent: 'Some dummy main content required for this example',
38
- footerContent: 'Some dummy footer content required for this example'
39
44
  }
40
45
  }
41
46
 
42
- const DefaultContent = (args) => ({
47
+ const DefaultContent = (args, { argTypes }) => ({
43
48
  components: { AppHeader },
44
- setup() {
45
- return { args }
46
- },
49
+ props: Object.keys(argTypes),
47
50
  template: `
48
51
  <div>
49
52
  <app-header
50
- v-bind="args"
53
+ v-bind="$props"
51
54
  />
52
55
  <main>
53
56
  <div class="container">
54
57
  <div class="row">
55
58
  <div class="col">
56
- {{args.mainContent}}
59
+ {{$props.mainContent}}
57
60
  </div>
58
61
  </div>
59
62
  </div>
@@ -62,7 +65,7 @@ const DefaultContent = (args) => ({
62
65
  <div class="container">
63
66
  <div class="row">
64
67
  <div class="col">
65
- {{args.footerContent}}
68
+ {{$props.footerContent}}
66
69
  </div>
67
70
  </div>
68
71
  </div>
@@ -72,3 +75,8 @@ const DefaultContent = (args) => ({
72
75
  })
73
76
 
74
77
  export const Default = DefaultContent.bind({})
78
+
79
+ Default.args = {
80
+ mainContent: 'Some dummy main content required for this example',
81
+ footerContent: 'Some dummy footer content required for this example'
82
+ }
@@ -416,14 +416,14 @@
416
416
 
417
417
  <script>
418
418
  import ModalSearch from './ModalSearch/index.vue'
419
- import Close from './../../../assets/icons/close.svg?component'
420
- import WorkSafeLogo from './../../../assets/icons/AppFooter/worksafe-footer-logo.svg?url'
421
- import WorkWellLogo from './../../../assets/icons/AppFooter/logo-workwell-reversed.svg?url'
422
- import CaretRight from './../../../assets/icons/caret-right.svg?component'
423
- import CaretDown from './../../../assets/icons/caret-down.svg?component'
424
- import SearchIcon from './../../../assets/icons/AppHeader/search-32px.svg?component'
425
- import CaretLeft from './../../../assets/icons/caret-left.svg?component'
426
- import MenuIcon from './../../../assets/icons/AppHeader/menu-32px.svg?component'
419
+ import Close from './../../../assets/icons/close.svg'
420
+ import WorkSafeLogo from './../../../assets/icons/AppFooter/worksafe-footer-logo.svg'
421
+ import WorkWellLogo from './../../../assets/icons/AppFooter/logo-workwell-reversed.svg'
422
+ import CaretRight from './../../../assets/icons/caret-right.svg'
423
+ import CaretDown from './../../../assets/icons/caret-down.svg'
424
+ import SearchIcon from './../../../assets/icons/AppHeader/search-32px.svg'
425
+ import CaretLeft from './../../../assets/icons/caret-left.svg'
426
+ import MenuIcon from './../../../assets/icons/AppHeader/menu-32px.svg'
427
427
 
428
428
  export default {
429
429
  components: {
@@ -527,7 +527,6 @@ export default {
527
527
  this.windowWidth = window.innerWidth
528
528
  },
529
529
  firstLevelClick(item, ref) {
530
- console.log('in first level click')
531
530
  // Reset screen to fix whitespace
532
531
  if (window && window.scrollTo && this.screen === 'desktop') {
533
532
  window.scrollTo(0, 0)
@@ -1,10 +1,8 @@
1
1
  <template>
2
- <div>
3
- <h1>Form Instance</h1>
2
+ <h1>Form Instance</h1>
4
3
  <p>
5
4
  The .vue and .stories.js files for SubComponents/FormInstance (displayed in Storybook under Form) must be copied from current Storybook 6 branch when time to upgrade them. They are causing errors preventing Storybook from being rendered and therefore tested.
6
5
  </p>
7
- </div>
8
6
  </template>
9
7
 
10
8
  <script>
@@ -0,0 +1,8 @@
1
+ import GoogleSearch from './index.vue'
2
+
3
+ export default {
4
+ title: 'SubComponents/GoogleSearch',
5
+ component: GoogleSearch
6
+ }
7
+
8
+ export const Default = {}
@@ -0,0 +1,405 @@
1
+ <template>
2
+ <div class="wcl-search">
3
+ <div class="gcse-search"></div>
4
+ </div>
5
+ </template>
6
+
7
+ <script>
8
+ export default {
9
+ mounted() {
10
+ // console.log('Component mounted')
11
+ this.setupCustomeStyle()
12
+
13
+ // Introduce a delay before setting up addEventListener
14
+ setTimeout(() => {
15
+ this.setupCustomAttr()
16
+ this.handleSearchResultLinkTitle()
17
+ }, 2000) // Adjust the delay time as needed
18
+ },
19
+
20
+ beforeDestroy() {
21
+ // Remove event listeners before the component is destroyed
22
+ const targetNode = document.querySelector('input[name="search"]')
23
+ const buttonNode = document.querySelector('button.gsc-search-button')
24
+
25
+ if (targetNode) {
26
+ // Add keyup.enter event listener
27
+ targetNode.removeEventListener('keyup', this.handleKeyUp)
28
+ buttonNode.removeEventListener('click', this.handleKeyUp)
29
+ }
30
+ const paginationNodes = document.querySelectorAll('.gsc-cursor-page')
31
+ paginationNodes.forEach((paginationNode) => {
32
+ paginationNode.removeEventListener('click', this.handleSearchResultTitle)
33
+ })
34
+ },
35
+
36
+ methods: {
37
+ // Method to customize google search style
38
+ setupCustomeStyle() {
39
+ const script = document.createElement('script')
40
+ script.async = true
41
+ script.src = 'https://cse.google.com/cse.js?cx=53b1506aa03c64160'
42
+ document.head.appendChild(script)
43
+
44
+ // Create a new style element
45
+ const style = document.createElement('style')
46
+ style.id = 'searchStyle' // Assign an ID to the style element
47
+ // The CSS we are going to inject
48
+ const cssVar = 'table.gssb_c {display: none !important;}'
49
+ // Inject the style element into the head
50
+ document.head.appendChild(style)
51
+ // Set the text content of the style element to the CSS text
52
+ style.textContent = cssVar
53
+ },
54
+
55
+ // Method to add google search input attributes
56
+ setupCustomAttr() {
57
+ console.log('setupCustomInputAttr ...')
58
+
59
+ const targetNode = document.querySelector('input[name="search"]')
60
+ const buttonNode = document.querySelector('button.gsc-search-button')
61
+
62
+ if (targetNode) {
63
+ // Add keyup.enter event listener
64
+ targetNode.addEventListener('keyup', this.handleKeyUp)
65
+ buttonNode.addEventListener('click', this.handleKeyUp)
66
+ }
67
+
68
+ this.setupPaginationEvent()
69
+ },
70
+
71
+ setupPaginationEvent() {
72
+ console.log('setupPaginationEvent ....')
73
+ // Introduce a delay before setting up addEventListener on pagination
74
+ setTimeout(() => {
75
+ this.handleSearchResultLinkTitle()
76
+ const paginationNodes = document.querySelectorAll('.gsc-cursor-page')
77
+ console.log('paginationNodes length ..', paginationNodes.length)
78
+
79
+ if (paginationNodes && paginationNodes.length > 0) {
80
+ console.log('FOUND PAGINATION ....', paginationNodes)
81
+
82
+ // Loop through each element and add a click event listener
83
+ paginationNodes.forEach((paginationNode) => {
84
+ // Check if the click event listener has already been added
85
+ if (!paginationNode.clickEventListenerAdded) {
86
+ // Add a click event listener
87
+ paginationNode.addEventListener(
88
+ 'click',
89
+ this.handleSearchResultTitle
90
+ )
91
+ // Mark that the click event listener has been added
92
+ paginationNode.clickEventListenerAdded = true
93
+ console.log('Adding a click event listener')
94
+ }
95
+ })
96
+ }
97
+ }, 2000) // Adjust the delay time as needed
98
+ },
99
+
100
+ // Method to trim text after '|'
101
+ handleSearchResultTitle() {
102
+ //alert('handleSearchResultTitle ....')
103
+ this.setupPaginationEvent()
104
+ },
105
+
106
+ handleSearchResultLinkTitle() {
107
+ //alert('handleSearchResultLinkTitle ....')
108
+ // Get all targetNodes with class "a.gs-title"
109
+ var targetNodes = document.querySelectorAll('a.gs-title')
110
+ console.log('search list title targetNodes :- ', targetNodes)
111
+
112
+ // Loop through each element and hide the text after the "|"
113
+ targetNodes.forEach(function(element) {
114
+ // Get the text content
115
+ var text = element.textContent || element.innerText
116
+
117
+ // Find the index of the "|" symbol
118
+ var pipeIndex = text.indexOf('|')
119
+ console.log('text :- ', text)
120
+ // If the "|" symbol is found, update the text content to display only the part before "|"
121
+ if (pipeIndex !== -1) {
122
+ element.textContent = text.substring(0, pipeIndex).trim()
123
+ }
124
+ })
125
+ },
126
+
127
+ handleKeyUp(event) {
128
+ if (event.key === 'Enter' || event.type === 'click') {
129
+ let keyword = event.key
130
+ ? event.target.value
131
+ : document.querySelector('input[name="search"]').value
132
+
133
+ // console.log('Enter key pressed. Value:', keyword)
134
+
135
+ // Check if the URL does not contain "/search"
136
+ if (keyword && !window.location.href.includes('/search')) {
137
+ let origin = window.location.origin
138
+ let hash = window.location.hash
139
+ let pathname = 'search'
140
+ let URL = origin + '/' + pathname + hash
141
+ // console.log('URL does not contains "/search" ...', URL)
142
+ window.location.assign(URL)
143
+ }
144
+
145
+ this.setupPaginationEvent
146
+ }
147
+ }
148
+ }
149
+ }
150
+ </script>
151
+ <style lang="scss" scoped>
152
+ @import '../../../includes/scss/all';
153
+
154
+ .wcl-search {
155
+ :deep(form.gsc-search-box) {
156
+ position: relative;
157
+ display: -ms-flexbox;
158
+ display: flex;
159
+ -ms-flex-wrap: wrap;
160
+ flex-wrap: wrap;
161
+ -ms-flex-align: stretch;
162
+ align-items: stretch;
163
+ width: 100%;
164
+ }
165
+ :deep(.gsib_a) {
166
+ padding: 0 !important;
167
+ height: 56px;
168
+ }
169
+ :deep(.gsib_b) {
170
+ position: absolute;
171
+ right: 5px;
172
+ top: 15px;
173
+ }
174
+ :deep(.gcsc-more-maybe-branding-root) {
175
+ display: none;
176
+ }
177
+ :deep(table.gsc-input) {
178
+ position: relative;
179
+ }
180
+ :deep(td.gsc-input) {
181
+ border: none;
182
+ padding: 0;
183
+ width: 100%;
184
+ }
185
+ :deep(.gsc-input-box) {
186
+ border: none;
187
+ }
188
+ :deep(input.gsc-input) {
189
+ border-radius: 8px 0px 0px 8px;
190
+ border: 1px solid $gray !important;
191
+ border-right: 0 !important;
192
+ background: none !important;
193
+ color: #495057;
194
+ height: 56px !important;
195
+ position: relative;
196
+ -ms-flex: 1 1 auto;
197
+ flex: 1 1 auto;
198
+ padding: 0.375rem 0.75rem !important;
199
+
200
+ @media screen and (max-width: 320px) {
201
+ width: 220px;
202
+ }
203
+
204
+ &:focus {
205
+ box-shadow: none;
206
+ }
207
+ }
208
+ :deep(.gsc-search-button) {
209
+ display: -ms-flexbox;
210
+ display: flex;
211
+ margin-left: 0px;
212
+ height: 56px;
213
+ margin-top: 0px;
214
+ }
215
+ :deep(button.gsc-search-button) {
216
+ background: $orange;
217
+ border: none;
218
+ border-radius: 0px 8px 8px 0px;
219
+ color: $black;
220
+ display: flex;
221
+ align-items: center;
222
+ height: 56px !important;
223
+ font-size: 16px;
224
+ font-weight: 700;
225
+ padding-right: 32px;
226
+ padding-left: 32px;
227
+
228
+ &:before {
229
+ content: 'Search';
230
+ }
231
+ @media screen and (max-width: 767px) {
232
+ margin-top: 6px;
233
+ }
234
+ @media screen and (max-width: 320px) {
235
+ padding-right: 16px;
236
+ padding-left: 16px;
237
+ }
238
+
239
+ svg {
240
+ fill: black;
241
+ height: 18px;
242
+ width: 18px;
243
+ margin-left: 10px;
244
+ }
245
+
246
+ :focus {
247
+ box-shadow: 0px;
248
+ }
249
+ }
250
+
251
+ :deep(.gsst_a .gscb_a) {
252
+ color: #191919;
253
+ }
254
+ :deep(.gsc-result-info) {
255
+ color: #191919;
256
+ font-size: 16px;
257
+ font-weight: 400;
258
+ }
259
+ :deep(.gsc-above-wrapper-area) {
260
+ padding: 20px 0;
261
+ border-bottom: none;
262
+ }
263
+ /* search list start */
264
+ :deep(.gsc-url-top) {
265
+ display: none;
266
+ }
267
+ :deep(.gsc-table-result) {
268
+ line-height: 1.6;
269
+ padding: 0 5px;
270
+ font-size: 16px;
271
+ font-weight: 400;
272
+ width: 80%;
273
+ b {
274
+ color: #191919;
275
+ font-size: 16px;
276
+ font-weight: normal;
277
+ }
278
+ }
279
+ :deep(.gsc-resultsRoot.gsc-tabData) {
280
+ width: 100%;
281
+ margin-left: auto;
282
+ margin-right: auto;
283
+ padding-left: 15px;
284
+ padding-right: 15px;
285
+
286
+ &:hover {
287
+ border: none;
288
+ }
289
+ }
290
+ :deep(.gs-bidi-start-align.gs-snippet) {
291
+ color: #191919 !important;
292
+ line-height: 24px;
293
+ }
294
+ :deep(.gsc-thumbnail-inside) {
295
+ position: relative;
296
+ padding: 0;
297
+
298
+ &::after {
299
+ content: ' ';
300
+ position: absolute;
301
+ height: 16px;
302
+ width: 11px;
303
+ top: 5px;
304
+ right: 16px;
305
+ background-repeat: no-repeat;
306
+ background-image: url(../../../assets/icons/chev-right.svg);
307
+ background-size: 100%;
308
+ }
309
+ div.gs-title {
310
+ width: 90%;
311
+ margin-bottom: 12px;
312
+ overflow: visible;
313
+ }
314
+ a.gs-title {
315
+ color: #191919 !important;
316
+ font-weight: 700;
317
+ line-height: 24px;
318
+ font-size: 20px;
319
+ border: 3px solid transparent;
320
+ padding-left: 5px;
321
+ padding-right: 5px;
322
+ text-decoration: underline;
323
+
324
+ &:hover {
325
+ border: 3px solid #da47ff;
326
+ color: #006bff !important;
327
+ b {
328
+ color: #006bff !important;
329
+ }
330
+ }
331
+
332
+ b {
333
+ color: #191919 !important;
334
+ font-size: 20px;
335
+ }
336
+ }
337
+ }
338
+ :deep(.gsc-orderby-label) {
339
+ font-size: 16px;
340
+ font-weight: 700;
341
+ color: #191919;
342
+ }
343
+ :deep(.gsc-selected-option-container) {
344
+ background-color: white;
345
+ border-radius: 10px;
346
+ margin-top: 0px;
347
+ padding-top: 6px;
348
+ margin-right: 0;
349
+ margin-left: 4px;
350
+ padding-left: 20px;
351
+ padding-bottom: 6px;
352
+ height: 40px;
353
+ .gsc-selected-option {
354
+ font-size: 16px;
355
+ font-weight: 400;
356
+ line-height: 24px;
357
+ margin-right: 20px;
358
+ }
359
+ }
360
+ :deep(.gsc-control-cse .gsc-option-selector) {
361
+ margin-top: 0;
362
+ margin-right: 10px;
363
+ }
364
+ :deep(.gsc-expansionArea > .gsc-webResult.gsc-result) {
365
+ border: 0;
366
+ flex: 0 0 100%;
367
+ max-width: 100%;
368
+ padding: 0;
369
+ &:first-child {
370
+ border-top: 1px solid #bababa;
371
+ }
372
+ > div {
373
+ border-bottom: 1px solid #bababa;
374
+ padding: 32px 0;
375
+ }
376
+ }
377
+
378
+ :deep(.gsc-results .gsc-cursor-box .gsc-cursor-current-page) {
379
+ background-color: lightgrey;
380
+ }
381
+ :deep(.gsc-results .gsc-cursor-box .gsc-cursor-page) {
382
+ border: 1px solid grey;
383
+ color: #333333;
384
+ padding: 10px 12px;
385
+ border-radius: 5px;
386
+ font-size: 16px;
387
+ font-weight: 400;
388
+ }
389
+ :deep(.gsc-results .gsc-cursor-box) {
390
+ margin-top: 50px;
391
+ }
392
+
393
+ /* search list end */
394
+ @include mq('xs') {
395
+ .not-extra-small-screen {
396
+ display: none;
397
+ }
398
+ }
399
+ }
400
+ @media screen and (max-width: 767px) {
401
+ :deep(.gssb_c) {
402
+ width: 85% !important;
403
+ }
404
+ }
405
+ </style>