@wayke-se/components-react 3.0.0 → 3.1.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -46
- package/dist-node/index.js +99 -11
- package/dist-node/index.js.map +1 -1
- package/dist-src/components/Gallery/wrapper.js +70 -1
- package/dist-src/components/Grid/index.js +17 -2
- package/dist-src/components/ProductCard/index.js +6 -3
- package/dist-src/layouts/searchItem/Related.js +2 -2
- package/dist-src/utils/regex.js +1 -1
- package/dist-web/index.js +96 -9
- package/dist-web/index.js.map +1 -1
- package/package.json +2 -4
- package/assets/ajax-loader.gif +0 -0
- package/assets/default.css +0 -1
- package/assets/fonts/slick.eot +0 -0
- package/assets/fonts/slick.svg +0 -14
- package/assets/fonts/slick.ttf +0 -0
- package/assets/fonts/slick.woff +0 -0
package/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
# Components React
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This repository contains components for search and items to use on external websites.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Usage
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Get started using `@wayke-se/components-react`.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Before you start
|
|
10
10
|
|
|
11
|
-
Install
|
|
11
|
+
**Install**
|
|
12
12
|
```bash
|
|
13
13
|
npm install @wayke-se/components-react
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Install peer dependencies
|
|
16
|
+
**Install peer dependencies**
|
|
17
17
|
```bash
|
|
18
18
|
npm install react react-dom styled-components
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
### Basic usage
|
|
22
|
+
|
|
21
23
|
```javascript
|
|
22
24
|
import React from 'react';
|
|
23
25
|
import WaykeComposite from '@wayke-se/components-react'
|
|
24
|
-
import '@wayke-se/
|
|
25
|
-
// Optional
|
|
26
|
-
import '@wayke-se/ecom-web/dist/index.css';
|
|
26
|
+
import '@wayke-se/ecom-web/dist/index.css'; // Only required if Ecom is activated
|
|
27
27
|
|
|
28
28
|
const ProviderSettings: WaykeProviderSettings = {
|
|
29
29
|
graphQlUrl: "https://gql.wayketech.se/query",
|
|
@@ -66,18 +66,24 @@ const ProviderSettings: WaykeProviderSettings = {
|
|
|
66
66
|
}
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
|
|
70
69
|
### WaykeComposite uses hash-route, i want to use path-route
|
|
71
70
|
|
|
72
|
-
In this case you need to make sure that you are in control of the routing where same html file is
|
|
71
|
+
In this case you need to make sure that you are in control of the routing, if the user reloads the page, where same html file is
|
|
73
72
|
served for `/your/path/to/this/component` and `/your/path/to/this/component/00000000-0000-0000-0000-000000000000`.
|
|
74
73
|
|
|
74
|
+
Examples given the application is located in `/search/vehicles`:
|
|
75
|
+
|
|
76
|
+
1) pathRoute is `/search/vehicles` => `//yoursite.com/search/vehicles/00000000-0000-0000-0000-000000000000`
|
|
77
|
+
2) pathRoute is `/item` => `//yoursite.com/item/00000000-0000-0000-0000-000000000000`
|
|
78
|
+
3) pathRoute is `/a/b` => `//yoursite.com/a/b/00000000-0000-0000-0000-000000000000`
|
|
79
|
+
4) pathRoute is `item` => `//yoursite.com/search/item/00000000-0000-0000-0000-000000000000`
|
|
80
|
+
5) pathRoute is `a/b` => `//yoursite.com/search/a/b/00000000-0000-0000-0000-000000000000`
|
|
81
|
+
6) pathRoute is `https://www.wayke.se/objekt` => `https://www.wayke.se/objekt/00000000-0000-0000-0000-000000000000`
|
|
82
|
+
|
|
75
83
|
```javascript
|
|
76
84
|
import React from 'react';
|
|
77
85
|
import { WaykeCompositePath } from '@wayke-se/components-react'
|
|
78
|
-
import '@wayke
|
|
79
|
-
// Optional
|
|
80
|
-
import '@wayke-se/ecom-web/dist/index.css';
|
|
86
|
+
import '@wayke-se/ecom-web/dist/index.css'; // Only required if Ecom is activated
|
|
81
87
|
|
|
82
88
|
const App = () => (
|
|
83
89
|
<WaykeCompositePath
|
|
@@ -110,7 +116,6 @@ const App = () => {
|
|
|
110
116
|
);
|
|
111
117
|
};
|
|
112
118
|
```
|
|
113
|
-
|
|
114
119
|
### I only want to use the Search Item component
|
|
115
120
|
|
|
116
121
|
It's recomended to place WaykeItemProvider close to app-root in order to keep the cache
|
|
@@ -118,9 +123,7 @@ It's recomended to place WaykeItemProvider close to app-root in order to keep th
|
|
|
118
123
|
```javascript
|
|
119
124
|
import React, { useCallback } from 'react';
|
|
120
125
|
import { WaykeItemProvider, WaykeSearchItem } from '@wayke-se/components-react'
|
|
121
|
-
import '@wayke
|
|
122
|
-
// Optional
|
|
123
|
-
import '@wayke-se/ecom-web/dist/index.css';
|
|
126
|
+
import '@wayke-se/ecom-web/dist/index.css'; // Only required if Ecom is activated
|
|
124
127
|
|
|
125
128
|
const App = ({}) => {
|
|
126
129
|
const id = 'd01f79a3-7552-49c4-9d4d-deb3aa581c31';
|
|
@@ -155,12 +158,12 @@ const App = ({}) => {
|
|
|
155
158
|
| disableResetScrollOnInit | boolean | false | |
|
|
156
159
|
| placeholderImage | string | false | |
|
|
157
160
|
| onClickSearchItem | function | false | (id: string) => void |
|
|
158
|
-
| modifyDocumentTitleItem | boolean | false | |
|
|
161
|
+
| modifyDocumentTitleItem | boolean | false | |
|
|
159
162
|
|
|
160
163
|
* Required
|
|
161
164
|
* `id` - Guid that represents a vehicle.
|
|
162
165
|
* Optional
|
|
163
|
-
* `pathRoute` - If set
|
|
166
|
+
* `pathRoute` - If set, then if a item is clicked it will use the provided url and append the guid. Supports both relative and absolute.
|
|
164
167
|
* `hashRoute` - If set to true, then if a item is clicked it will append #guid to the url (is not used if `pathRoute` is set).
|
|
165
168
|
* `disableResetScrollOnInit` - Loading the item page resets the scroll, here it's possible to disable it.
|
|
166
169
|
* `placeholderImage` - Provide custom placeholder image when image is missing.
|
|
@@ -181,7 +184,7 @@ const App = ({}) => {
|
|
|
181
184
|
| modifyDocumentTitleSearch | string | |
|
|
182
185
|
|
|
183
186
|
* Optional
|
|
184
|
-
* `pathRoute` - If set
|
|
187
|
+
* `pathRoute` - If set, then if a item is clicked it will use the provided url and append the guid. Supports both relative and absolute.
|
|
185
188
|
* `hashRoute` - If set to true, then if a item is clicked it will append #guid to the url (is not used if `pathRoute` is set).
|
|
186
189
|
* `filterList` - Select what filters that should be visible and in whiched order, drivingWheel, price, mileage, modelYear
|
|
187
190
|
* `initialQueryParams` - Set the default filter that should be applid upon init.
|
|
@@ -429,7 +432,7 @@ To style the components, copy the following snippet into your *CSS* file and mod
|
|
|
429
432
|
}
|
|
430
433
|
```
|
|
431
434
|
|
|
432
|
-
...or if you want to use it as
|
|
435
|
+
...or if you want to use it as _Sass_ (.scss):
|
|
433
436
|
|
|
434
437
|
```scss
|
|
435
438
|
.wayke__theme {
|
|
@@ -461,17 +464,23 @@ To style the components, copy the following snippet into your *CSS* file and mod
|
|
|
461
464
|
}
|
|
462
465
|
```
|
|
463
466
|
|
|
467
|
+
> **It is highly recommended to *NOT* add or remove any properties defined above in the color selectors**. However, since fonts usually requires more configuration we encourage you to add the necessary font styling required to match your current profile. If you add new properties to the font selectors, please be careful and ensure everything looks as intended before going into production.
|
|
468
|
+
|
|
464
469
|
### Ecom theme
|
|
465
|
-
The default ecom css can be found and imported `node_module/@wayke-se/ecom-web/dist/index.css`.
|
|
466
470
|
|
|
467
|
-
|
|
471
|
+
The default Ecom *CSS* can be found and imported from `@wayke-se/ecom-web/dist/index.css`. This is only necessary if Ecom is activated. If activated and the *CSS* is not imported, the Ecom module will not be displayed correctly.
|
|
472
|
+
|
|
473
|
+
If you want to customize the look of the Ecom module we refer you to the documentation of [@wayke-se/ecom-web](https://www.npmjs.com/package/@wayke-se/ecom-web).
|
|
468
474
|
|
|
469
|
-
## Run example from
|
|
470
|
-
This repository contains a example app that uses [@wayke-se/components-react](https://www.npmjs.com/package/@wayke-se/components-react).
|
|
475
|
+
## Run example from this repository
|
|
471
476
|
|
|
477
|
+
This repository contains an example app that uses [@wayke-se/components-react](https://www.npmjs.com/package/@wayke-se/components-react).
|
|
472
478
|
|
|
473
479
|
|
|
474
|
-
|
|
480
|
+
### Setup environment variables
|
|
481
|
+
|
|
482
|
+
To start the example create an `.env` file in root with the following content.
|
|
483
|
+
|
|
475
484
|
```
|
|
476
485
|
WAYKE_HOST=YOUR_HOST_1,YOUR_HOST_2
|
|
477
486
|
WAYKE_SEARCH_URL=https://test-ext-api.wayketech.se/vehicles
|
|
@@ -482,10 +491,15 @@ WAYKE_ECOM_URL=https://ecom.wayketech.se
|
|
|
482
491
|
GOOGLE_MAPS_API_KEY=YOUR_GOOGLE_MAPS_STATIC_API_KEY
|
|
483
492
|
```
|
|
484
493
|
|
|
485
|
-
|
|
494
|
+
#### Notes
|
|
495
|
+
|
|
496
|
+
* `WAYKE_SEARCH_MLT_URL` - An *optional* flag. Will fetch related vehicles to current vehicle. If not provided
|
|
486
497
|
`WAYKE_SEARCH_URL` will be used instead, but will fetch latest vehicles.
|
|
487
498
|
|
|
488
|
-
|
|
499
|
+
### Start the example app
|
|
500
|
+
|
|
501
|
+
Run the following commands to start the example app.
|
|
502
|
+
|
|
489
503
|
```bash
|
|
490
504
|
npm install
|
|
491
505
|
cd example
|
|
@@ -493,35 +507,38 @@ npm install
|
|
|
493
507
|
npm start
|
|
494
508
|
```
|
|
495
509
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
This will change the origin, while still pointing to localhost.
|
|
500
|
-
Start the example and open `test.com.localhost:5000`.
|
|
510
|
+
### Custom host
|
|
511
|
+
|
|
512
|
+
`WAYKE_HOST` can be used instead of using and exposing the `WAYKE_SEARCH_X_API_KEY`. If, for example, your development host is `test.com.localhost`.
|
|
501
513
|
|
|
502
|
-
To
|
|
514
|
+
To do so update your local host file and add:
|
|
515
|
+
```txt
|
|
516
|
+
127.0.0.1 test.com.localhost
|
|
503
517
|
```
|
|
518
|
+
|
|
519
|
+
This will change the origin, while still pointing to `localhost`. Start the example app and open `test.com.localhost:5000` in your browser.
|
|
520
|
+
|
|
521
|
+
### Multiple hosts
|
|
522
|
+
|
|
523
|
+
To add multiple hosts, add all hohsts to your local host file and then update `WAYKE_HOST` in `.env` as a comma separated list.
|
|
524
|
+
|
|
525
|
+
```txt
|
|
504
526
|
WAYKE_HOST=a.com.localhost,b.com.localhost
|
|
505
527
|
```
|
|
506
|
-
`a.com.localhost:5000` and `b.com.localhost:5000` can now be accessed.
|
|
507
528
|
|
|
529
|
+
`a.com.localhost:5000` and `b.com.localhost:5000` can now be accessed.
|
|
508
530
|
|
|
509
|
-
### Available
|
|
531
|
+
### Available routes (independent)
|
|
510
532
|
|
|
511
|
-
|
|
533
|
+
**WaykeComposite**
|
|
512
534
|
[http://localhost:5000](http://localhost:5000)
|
|
513
535
|
|
|
514
|
-
|
|
536
|
+
**WaykeSearch With WaykeProvider**
|
|
515
537
|
[http://localhost:5000/search](http://localhost:5000/search)
|
|
516
538
|
|
|
517
|
-
|
|
539
|
+
**WaykeSearchItem With WaykeProvider**
|
|
518
540
|
[http://localhost:5000/search-item/d01f79a3-7552-49c4-9d4d-deb3aa581c31](http://localhost:5000/search-item/d01f79a3-7552-49c4-9d4d-deb3aa581c31)
|
|
519
541
|
|
|
520
|
-
|
|
521
542
|
## Example repositories
|
|
522
543
|
|
|
523
|
-
|
|
524
|
-
[https://github.com/wayke-se/components-react-boilerplate](https://github.com/wayke-se/components-react-boilerplate)
|
|
525
|
-
|
|
526
|
-
### Non-React with/without Typescript example
|
|
527
|
-
[https://github.com/wayke-se/components-react-example](https://github.com/wayke-se/components-react-example)
|
|
544
|
+
We have setup an example repository where you can see how we've implemented `@wayke-se/components-react`. You'll find the repository here: [https://github.com/wayke-se/components-react-example](https://github.com/wayke-se/components-react-example).
|
package/dist-node/index.js
CHANGED
|
@@ -2475,9 +2475,13 @@ const ProductCard = ({
|
|
|
2475
2475
|
const _onClick = React.useMemo(() => onClick ? () => onClick(id) : undefined, [id]);
|
|
2476
2476
|
|
|
2477
2477
|
const onHrefClick = React.useCallback(e => {
|
|
2478
|
-
if (
|
|
2479
|
-
|
|
2480
|
-
|
|
2478
|
+
if (pathRoute && href) {
|
|
2479
|
+
const reg = new RegExp('^((http|https)://)|//');
|
|
2480
|
+
|
|
2481
|
+
if (!pathRoute.match(reg) && !pathRoute.startsWith(location.origin)) {
|
|
2482
|
+
e.preventDefault();
|
|
2483
|
+
pushState(href);
|
|
2484
|
+
}
|
|
2481
2485
|
}
|
|
2482
2486
|
}, [id, pathRoute, href]);
|
|
2483
2487
|
return React__default.createElement(Wrapper$8, {
|
|
@@ -2528,10 +2532,25 @@ const Grid = ({
|
|
|
2528
2532
|
}
|
|
2529
2533
|
|
|
2530
2534
|
return React__default.createElement(Wrapper$7, null, React__default.createElement(List$4, null, documents.map(document => {
|
|
2531
|
-
|
|
2535
|
+
/*
|
|
2536
|
+
const _path = pathRoute?.replace(/^\/|\/$/g, '');
|
|
2537
|
+
const prefix = _path ? `/${_path}/` : '/';
|
|
2538
|
+
const pathRouteUrl =
|
|
2539
|
+
window.location.pathname === '/'
|
|
2540
|
+
? `${prefix}${document._id}`
|
|
2541
|
+
: `${window.location.pathname}${prefix}${document._id}`;
|
|
2542
|
+
*/
|
|
2543
|
+
|
|
2544
|
+
/*
|
|
2545
|
+
const _pathRoute = pathRoute
|
|
2546
|
+
? pathRoute.startsWith('/')
|
|
2547
|
+
? `${location.pathname}${pathRoute}/${document._id}`
|
|
2548
|
+
: `${pathRoute}/${document._id}`
|
|
2549
|
+
: undefined;
|
|
2550
|
+
console.log(_pathRoute);
|
|
2551
|
+
*/
|
|
2552
|
+
const _pathRoute = pathRoute ? `${pathRoute}/${document._id}` : undefined;
|
|
2532
2553
|
|
|
2533
|
-
const prefix = _path ? `/${_path}/` : '/';
|
|
2534
|
-
const pathRouteUrl = window.location.pathname === '/' ? `${prefix}${document._id}` : `${window.location.pathname}${prefix}${document._id}`;
|
|
2535
2554
|
return React__default.createElement(Item$4, {
|
|
2536
2555
|
key: document._id
|
|
2537
2556
|
}, React__default.createElement(ProductCard, {
|
|
@@ -2539,7 +2558,7 @@ const Grid = ({
|
|
|
2539
2558
|
onClick: onClickItem,
|
|
2540
2559
|
title: document.title,
|
|
2541
2560
|
pathRoute: pathRoute,
|
|
2542
|
-
href:
|
|
2561
|
+
href: _pathRoute ? _pathRoute : hashRoute ? `#${document._id}` : undefined,
|
|
2543
2562
|
image: resolveImage(document),
|
|
2544
2563
|
placeholderImage: placeholderImage,
|
|
2545
2564
|
description: document.shortDescription,
|
|
@@ -3438,6 +3457,76 @@ const SliderWrapper = styled__default.div`
|
|
|
3438
3457
|
bottom: 0;
|
|
3439
3458
|
left: 0;
|
|
3440
3459
|
right: 0;
|
|
3460
|
+
user-select: none;
|
|
3461
|
+
touch-action: pan-y;
|
|
3462
|
+
-webkit-tap-highlight-color: transparent;
|
|
3463
|
+
|
|
3464
|
+
.slick-list,
|
|
3465
|
+
.slick-track {
|
|
3466
|
+
transform: translate3d(0, 0, 0);
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
|
|
3470
|
+
.slick-list {
|
|
3471
|
+
position: relative;
|
|
3472
|
+
display: block;
|
|
3473
|
+
margin: 0;
|
|
3474
|
+
padding: 0;
|
|
3475
|
+
overflow: hidden;
|
|
3476
|
+
|
|
3477
|
+
&:focus {
|
|
3478
|
+
outline: none;
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
&.dragging {
|
|
3482
|
+
cursor: pointer;
|
|
3483
|
+
cursor: hand;
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
|
|
3487
|
+
.slick-track {
|
|
3488
|
+
position: relative;
|
|
3489
|
+
top: 0;
|
|
3490
|
+
left: 0;
|
|
3491
|
+
display: block;
|
|
3492
|
+
margin-left: auto;
|
|
3493
|
+
margin-right: auto;
|
|
3494
|
+
|
|
3495
|
+
&::before,
|
|
3496
|
+
&::after {
|
|
3497
|
+
content: '';
|
|
3498
|
+
display: table;
|
|
3499
|
+
}
|
|
3500
|
+
|
|
3501
|
+
&::after {
|
|
3502
|
+
clear: both;
|
|
3503
|
+
}
|
|
3504
|
+
}
|
|
3505
|
+
|
|
3506
|
+
.slick-slide {
|
|
3507
|
+
display: none;
|
|
3508
|
+
float: left;
|
|
3509
|
+
min-height: 1px;
|
|
3510
|
+
}
|
|
3511
|
+
|
|
3512
|
+
.slick-loading {
|
|
3513
|
+
.slick-track {
|
|
3514
|
+
visibility: hidden;
|
|
3515
|
+
}
|
|
3516
|
+
|
|
3517
|
+
img {
|
|
3518
|
+
display: none;
|
|
3519
|
+
}
|
|
3520
|
+
}
|
|
3521
|
+
|
|
3522
|
+
.slick-initialized {
|
|
3523
|
+
.slick-slide {
|
|
3524
|
+
display: block;
|
|
3525
|
+
}
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3528
|
+
.slick-slide.dragging img {
|
|
3529
|
+
pointer-events: none;
|
|
3441
3530
|
}
|
|
3442
3531
|
|
|
3443
3532
|
${props => props.theme.breakpoint.LtMd} {
|
|
@@ -3450,7 +3539,6 @@ const SliderWrapper = styled__default.div`
|
|
|
3450
3539
|
|
|
3451
3540
|
.slick-slide {
|
|
3452
3541
|
border-right: ${size(1)} solid ${props => props.theme.color.bg};
|
|
3453
|
-
//transform: scale(0.95);
|
|
3454
3542
|
transform-origin: 0 50%;
|
|
3455
3543
|
transition: transform 150ms ease;
|
|
3456
3544
|
}
|
|
@@ -6939,7 +7027,7 @@ const useRelatedSearch = id => {
|
|
|
6939
7027
|
const regexEndGuid = /[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
6940
7028
|
const escapeRegExpString = s => s.replace(/[-[\]/{}()*+?.\\^$|]/g, '\\$&');
|
|
6941
7029
|
const regexPathGuid = path => {
|
|
6942
|
-
if (!path) {
|
|
7030
|
+
if (!path || path) {
|
|
6943
7031
|
return regexEndGuid;
|
|
6944
7032
|
}
|
|
6945
7033
|
|
|
@@ -6991,8 +7079,8 @@ const Related = ({
|
|
|
6991
7079
|
var _document$featuredIma, _document$featuredIma2, _document$featuredIma3;
|
|
6992
7080
|
|
|
6993
7081
|
const prefix = pathRoute ? `/${pathRoute}` : '/';
|
|
6994
|
-
const r = regexPathGuid(
|
|
6995
|
-
const pathRouteUrl = window.location.pathname === '/' ? `${prefix}${document._id}` : r.test(`${pathRoute}${id}`) ? window.location.pathname.replace(r,
|
|
7082
|
+
const r = regexPathGuid();
|
|
7083
|
+
const pathRouteUrl = window.location.pathname === '/' ? `${prefix}${document._id}` : r.test(`${pathRoute}${id}`) ? window.location.pathname.replace(r, document._id) : `${window.location.pathname}${prefix}${document._id}`;
|
|
6996
7084
|
return React__default.createElement(OverflowGridItem, {
|
|
6997
7085
|
key: document._id
|
|
6998
7086
|
}, React__default.createElement(ProductCard, {
|