@sonic-equipment/ui 0.0.9 → 0.0.11
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 +191 -0
- package/dist/{dts → buttons}/button/button.d.ts +1 -4
- package/dist/buttons/button/button.stories.d.ts +18 -0
- package/dist/buttons/favorite/favorite-button.d.ts +5 -0
- package/dist/buttons/favorite/favorite-button.stories.d.ts +17 -0
- package/dist/buttons/icon-button/icon-button.d.ts +7 -0
- package/dist/buttons/icon-button/icon-button.stories.d.ts +17 -0
- package/dist/cards/product-card/product-card.d.ts +9 -0
- package/dist/cards/product-card/product-card.stories.d.ts +13 -0
- package/dist/{base.css → fonts.css} +17 -107
- package/dist/icons/favorite/favorite-filled-icon.d.ts +2 -0
- package/dist/icons/favorite/favorite-outline-icon.d.ts +2 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.js +74 -0
- package/dist/{dts → inputs}/checkbox/checkbox.d.ts +0 -1
- package/dist/inputs/checkbox/checkbox.stories.d.ts +17 -0
- package/dist/{dts/color-filter → product-listing/filters/colors}/color-filter.d.ts +5 -8
- package/dist/product-listing/filters/filter/filter.d.ts +7 -0
- package/dist/{dts/product-listing → product-listing}/product-listing.d.ts +1 -3
- package/dist/product-listing/product-listing.stories.d.ts +16 -0
- package/dist/{dts/product-listing → product-listing}/search-params.d.ts +2 -3
- package/dist/reset.css +0 -3
- package/dist/styles.css +297 -0
- package/package.json +51 -52
- package/dist/app.css +0 -12
- package/dist/button.css +0 -49
- package/dist/button.js +0 -12
- package/dist/checkbox.css +0 -63
- package/dist/checkbox.js +0 -10
- package/dist/dts/button/button.d.ts.map +0 -1
- package/dist/dts/checkbox/checkbox.d.ts.map +0 -1
- package/dist/dts/color-filter/color-filter.d.ts.map +0 -1
- package/dist/dts/filter/filter.d.ts +0 -8
- package/dist/dts/filter/filter.d.ts.map +0 -1
- package/dist/dts/product-card/product-card.d.ts +0 -10
- package/dist/dts/product-card/product-card.d.ts.map +0 -1
- package/dist/dts/product-listing/product-listing.d.ts.map +0 -1
- package/dist/dts/product-listing/search-params.d.ts.map +0 -1
- package/dist/product-card.js +0 -7
- package/dist/product-listing.css +0 -63
- package/dist/product-listing.js +0 -25
- package/dist/search-params.ts +0 -20
package/dist/button.css
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
.button-module-YrVJX {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
justify-content: center;
|
|
5
|
-
flex-shrink: 0;
|
|
6
|
-
-webkit-user-select: none;
|
|
7
|
-
-moz-user-select: none;
|
|
8
|
-
user-select: none;
|
|
9
|
-
vertical-align: top;
|
|
10
|
-
text-transform: uppercase;
|
|
11
|
-
font-style: italic;
|
|
12
|
-
font-weight: var(--font-weight-bold);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/*********************************************************
|
|
16
|
-
*
|
|
17
|
-
* Sizes
|
|
18
|
-
*
|
|
19
|
-
*********************************************************/
|
|
20
|
-
|
|
21
|
-
.button-module-JKC7O {
|
|
22
|
-
min-height: 40px;
|
|
23
|
-
border-radius: var(--border-radius-7);
|
|
24
|
-
padding-inline: var(--space-20);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.button-module-QYp75 {
|
|
28
|
-
min-height: 44px;
|
|
29
|
-
border-radius: var(--border-radius-8);
|
|
30
|
-
padding-inline: var(--space-20);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/*********************************************************
|
|
34
|
-
*
|
|
35
|
-
* Variants
|
|
36
|
-
*
|
|
37
|
-
*********************************************************/
|
|
38
|
-
|
|
39
|
-
/* Solid */
|
|
40
|
-
|
|
41
|
-
.button-module-trXaT:where(.button-module-2nlh8) {
|
|
42
|
-
background-color: var(--brand-color-red);
|
|
43
|
-
color: var(--white);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.button-module-trXaT:where(.button-module-2nlh8):where([data-hovered]),
|
|
47
|
-
.button-module-trXaT:where(.button-module-2nlh8):where([data-pressed]) {
|
|
48
|
-
background-color: var(--brand-color-dark-red);
|
|
49
|
-
}
|
package/dist/button.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import clsx from 'clsx';
|
|
3
|
-
import { Button as Button$1 } from 'react-aria-components';
|
|
4
|
-
|
|
5
|
-
var styles = {"button":"button-module-YrVJX","md":"button-module-JKC7O","lg":"button-module-QYp75","solid":"button-module-trXaT","primary":"button-module-2nlh8"};
|
|
6
|
-
|
|
7
|
-
function Button({ children, variant = "solid", size = "md", color = "primary", className, ...props }) {
|
|
8
|
-
return (jsx(Button$1, { ...props, className: clsx(styles.button, styles[variant], styles[size], styles[color], className), children: children }));
|
|
9
|
-
}
|
|
10
|
-
Button.displayName = "Button";
|
|
11
|
-
|
|
12
|
-
export { Button };
|
package/dist/checkbox.css
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
.checkbox-module-FLuy1 {
|
|
2
|
-
--selected-color: var(--brand-color-red);
|
|
3
|
-
--selected-color-pressed: var(--brand-color-dark-red);
|
|
4
|
-
--checkmark-color: var(--white);
|
|
5
|
-
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
gap: 0.571rem;
|
|
9
|
-
font-size: var(--font-size-24);
|
|
10
|
-
line-height: 14px;
|
|
11
|
-
color: var(--brand-color-black);
|
|
12
|
-
forced-color-adjust: none;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.checkbox-module-FLuy1 .checkbox-module-v6JLF {
|
|
16
|
-
width: 16px;
|
|
17
|
-
height: 16px;
|
|
18
|
-
border: 2px solid var(--brand-color-medium-gray);
|
|
19
|
-
border-radius: var(--border-radius-1);
|
|
20
|
-
transition: all 200ms;
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
justify-content: center;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.checkbox-module-FLuy1 svg {
|
|
27
|
-
width: 1rem;
|
|
28
|
-
height: 1rem;
|
|
29
|
-
fill: none;
|
|
30
|
-
stroke: var(--checkmark-color);
|
|
31
|
-
stroke-width: 3px;
|
|
32
|
-
stroke-dasharray: 22px;
|
|
33
|
-
stroke-dashoffset: 66;
|
|
34
|
-
transition: all 200ms;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.checkbox-module-FLuy1[data-pressed] .checkbox-module-v6JLF {
|
|
38
|
-
border-color: var(--brand-color-dark-gray);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.checkbox-module-FLuy1[data-focus-visible] .checkbox-module-v6JLF {
|
|
42
|
-
outline: 2px solid var(--focus-ring-color);
|
|
43
|
-
outline-offset: 2px;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.checkbox-module-FLuy1[data-selected] .checkbox-module-v6JLF, .checkbox-module-FLuy1[data-indeterminate] .checkbox-module-v6JLF {
|
|
47
|
-
border-color: var(--selected-color);
|
|
48
|
-
background: var(--selected-color);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.checkbox-module-FLuy1[data-selected][data-pressed] .checkbox-module-v6JLF, .checkbox-module-FLuy1[data-indeterminate][data-pressed] .checkbox-module-v6JLF {
|
|
52
|
-
border-color: var(--selected-color-pressed);
|
|
53
|
-
background: var(--selected-color-pressed);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.checkbox-module-FLuy1[data-selected] svg, .checkbox-module-FLuy1[data-indeterminate] svg {
|
|
57
|
-
stroke-dashoffset: 44;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.checkbox-module-FLuy1[data-indeterminate] svg {
|
|
61
|
-
stroke: none;
|
|
62
|
-
fill: var(--checkmark-color);
|
|
63
|
-
}
|
package/dist/checkbox.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { Checkbox as Checkbox$1 } from 'react-aria-components';
|
|
3
|
-
|
|
4
|
-
var styles = {"checkbox":"checkbox-module-FLuy1","box":"checkbox-module-v6JLF"};
|
|
5
|
-
|
|
6
|
-
function Checkbox({ children, ...props }) {
|
|
7
|
-
return (jsxs(Checkbox$1, { ...props, className: styles.checkbox, children: [jsx("div", { className: styles.box, children: jsx("svg", { viewBox: "0 0 18 18", "aria-hidden": "true", children: jsx("polyline", { points: "1 9 7 14 15 4" }) }) }), children] }));
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export { Checkbox };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/button/button.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAE7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,OAAO,CAAC;AAGjD,MAAM,MAAM,WAAW,GAAG,wBAAwB,CAAC,OAAO,UAAU,CAAC,GAAG;IACtE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,OAAO,CAAC;IACxC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,CAAC;CAC7D,CAAC;AAEF,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,OAAiB,EACjB,IAAW,EACX,KAAiB,EACjB,SAAS,EACT,GAAG,KAAK,EACT,EAAE,WAAW,2CAeb;yBAtBe,MAAM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/checkbox/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,wBAAwB,EAAa,MAAM,OAAO,CAAC;AAG5D,MAAM,MAAM,aAAa,GAAG,wBAAwB,CAAC,OAAO,YAAY,CAAC,CAAC;AAE1E,wBAAgB,QAAQ,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,aAAa,2CAW7D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"color-filter.d.ts","sourceRoot":"","sources":["../../../src/color-filter/color-filter.tsx"],"names":[],"mappings":"AACA,OAAO,EAAU,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG;IAC3C,OAAO,EAAE;QACP;YACE,KAAK,EAAE,MAAM,CAAC;YACd,KAAK,EAAE,MAAM,CAAC;YACd,KAAK,EAAE,MAAM,CAAC;SACf;KACF,CAAC;IACF,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,gBAAgB,2CAwBzE"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PropsWithChildren } from "react";
|
|
2
|
-
export type FilterProps = PropsWithChildren<{
|
|
3
|
-
title?: string;
|
|
4
|
-
isCollapseable?: boolean;
|
|
5
|
-
initialIsCollapsed?: boolean;
|
|
6
|
-
}>;
|
|
7
|
-
export declare function Filter({ title, children, isCollapseable, initialIsCollapsed, }: FilterProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/filter/filter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,MAAM,WAAW,GAAG,iBAAiB,CAAC;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC,CAAC;AAEH,wBAAgB,MAAM,CAAC,EACrB,KAAK,EACL,QAAQ,EACR,cAAqB,EACrB,kBAA0B,GAC3B,EAAE,WAAW,2CASb"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type ProductCardProps = {
|
|
2
|
-
product: {
|
|
3
|
-
id: string;
|
|
4
|
-
title: string;
|
|
5
|
-
};
|
|
6
|
-
onAddToCart?: (productId: string) => void;
|
|
7
|
-
onAddToList?: (productId: string) => void;
|
|
8
|
-
};
|
|
9
|
-
export declare function ProductCard({ product }: ProductCardProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
-
//# sourceMappingURL=product-card.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../src/product-card/product-card.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,wBAAgB,WAAW,CAAC,EAAE,OAAO,EAAE,EAAE,gBAAgB,2CAMxD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"product-listing.d.ts","sourceRoot":"","sources":["../../../src/product-listing/product-listing.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,MAAM,OAAO,GAAG;IACpB,KAAK,EAAE;QACL,OAAO,EAAE;YACP,KAAK,EAAE,MAAM,CAAC;YACd,KAAK,EAAE,MAAM,CAAC;YACd,KAAK,EAAE,MAAM,CAAC;SACf,EAAE,CAAC;KACL,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC7C,QAAQ,EAAE;QACR,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,aAAa,CAAC;IAC7B,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,IAAI,CAAC;IACjD,YAAY,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;CACpC,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,WAAW,EAAE,WAAW,EACxB,QAAQ,EACR,OAAO,EACP,SAAiB,EACjB,aAAa,EACb,cAAc,EACd,YAAY,GACb,EAAE,mBAAmB,2CAsCrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search-params.d.ts","sourceRoot":"","sources":["../../../src/product-listing/search-params.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,EAAE,CAAC;KAClB,CAAC;CACH,mBAWA;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,eAAe;;;;;;;;EAQxD"}
|
package/dist/product-card.js
DELETED
package/dist/product-listing.css
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
.checkbox-module-FLuy1 {
|
|
2
|
-
--selected-color: var(--brand-color-red);
|
|
3
|
-
--selected-color-pressed: var(--brand-color-dark-red);
|
|
4
|
-
--checkmark-color: var(--white);
|
|
5
|
-
|
|
6
|
-
display: flex;
|
|
7
|
-
align-items: center;
|
|
8
|
-
gap: 0.571rem;
|
|
9
|
-
font-size: var(--font-size-24);
|
|
10
|
-
line-height: 14px;
|
|
11
|
-
color: var(--brand-color-black);
|
|
12
|
-
forced-color-adjust: none;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.checkbox-module-FLuy1 .checkbox-module-v6JLF {
|
|
16
|
-
width: 16px;
|
|
17
|
-
height: 16px;
|
|
18
|
-
border: 2px solid var(--brand-color-medium-gray);
|
|
19
|
-
border-radius: var(--border-radius-1);
|
|
20
|
-
transition: all 200ms;
|
|
21
|
-
display: flex;
|
|
22
|
-
align-items: center;
|
|
23
|
-
justify-content: center;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.checkbox-module-FLuy1 svg {
|
|
27
|
-
width: 1rem;
|
|
28
|
-
height: 1rem;
|
|
29
|
-
fill: none;
|
|
30
|
-
stroke: var(--checkmark-color);
|
|
31
|
-
stroke-width: 3px;
|
|
32
|
-
stroke-dasharray: 22px;
|
|
33
|
-
stroke-dashoffset: 66;
|
|
34
|
-
transition: all 200ms;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
.checkbox-module-FLuy1[data-pressed] .checkbox-module-v6JLF {
|
|
38
|
-
border-color: var(--brand-color-dark-gray);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.checkbox-module-FLuy1[data-focus-visible] .checkbox-module-v6JLF {
|
|
42
|
-
outline: 2px solid var(--focus-ring-color);
|
|
43
|
-
outline-offset: 2px;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.checkbox-module-FLuy1[data-selected] .checkbox-module-v6JLF, .checkbox-module-FLuy1[data-indeterminate] .checkbox-module-v6JLF {
|
|
47
|
-
border-color: var(--selected-color);
|
|
48
|
-
background: var(--selected-color);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.checkbox-module-FLuy1[data-selected][data-pressed] .checkbox-module-v6JLF, .checkbox-module-FLuy1[data-indeterminate][data-pressed] .checkbox-module-v6JLF {
|
|
52
|
-
border-color: var(--selected-color-pressed);
|
|
53
|
-
background: var(--selected-color-pressed);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.checkbox-module-FLuy1[data-selected] svg, .checkbox-module-FLuy1[data-indeterminate] svg {
|
|
57
|
-
stroke-dashoffset: 44;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.checkbox-module-FLuy1[data-indeterminate] svg {
|
|
61
|
-
stroke: none;
|
|
62
|
-
fill: var(--checkmark-color);
|
|
63
|
-
}
|
package/dist/product-listing.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { Checkbox as Checkbox$1 } from 'react-aria-components';
|
|
3
|
-
|
|
4
|
-
var styles = {"checkbox":"checkbox-module-FLuy1","box":"checkbox-module-v6JLF"};
|
|
5
|
-
|
|
6
|
-
function Checkbox({ children, ...props }) {
|
|
7
|
-
return (jsxs(Checkbox$1, { ...props, className: styles.checkbox, children: [jsx("div", { className: styles.box, children: jsx("svg", { viewBox: "0 0 18 18", "aria-hidden": "true", children: jsx("polyline", { points: "1 9 7 14 15 4" }) }) }), children] }));
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function Filter({ title, children, isCollapseable = true, initialIsCollapsed = false, }) {
|
|
11
|
-
return (jsxs("div", { children: [jsx("div", { children: jsx("h3", { children: title }) }), jsx("div", { children: children })] }));
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function ColorFilter({ options, value, onChange }) {
|
|
15
|
-
return (jsx(Filter, { title: "Color", children: jsx("ul", { children: options.map((option) => (jsx("li", { children: jsx(Checkbox, { onChange: (isSelected) => onChange(isSelected
|
|
16
|
-
? [...value, option.value]
|
|
17
|
-
: value.filter((v) => v !== option.value)), value: option.value, isSelected: value.includes(option.value), children: option.label }) }, option.value))) }) }));
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function ProductListing({ productCard: ProductCard, products, filters, isLoading = false, activeFilters, onFilterChange, onSortChange, }) {
|
|
21
|
-
return (jsxs("div", { children: [jsx("h1", { children: "Product listing" }), jsxs("aside", { children: [jsx("h2", { children: "Filter" }), jsx("div", { children: jsx(ColorFilter, { options: filters.color.options, value: activeFilters.colors, onChange: (colors) => onFilterChange({ colors }) }) })] }), jsx("main", { children: jsxs("select", { onChange: (e) => onSortChange({ by: e.target.value, direction: "asc" }), children: [jsx("option", { value: "", children: "Sort By" }) // translations
|
|
22
|
-
, " // translations", jsx("option", { value: "price", children: "Price" }), jsx("option", { value: "title", children: "Title" })] }) }), isLoading ? (jsx("p", { children: "Loading..." })) : (jsx("ul", { children: products.map((product) => (jsx("li", { children: jsx(ProductCard, { product: product }) }, product.id))) }))] }));
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { ProductListing };
|
package/dist/search-params.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
function createSearchParams(state) {
|
|
2
|
-
const params = new URLSearchParams();
|
|
3
|
-
if (state.filters.colors.length > 0) {
|
|
4
|
-
params.set("colors", state.filters.colors.join(","));
|
|
5
|
-
}
|
|
6
|
-
params.set("sortBy", state.sort.by);
|
|
7
|
-
params.set("sortDirection", state.sort.direction);
|
|
8
|
-
return params;
|
|
9
|
-
}
|
|
10
|
-
function parseSearchParams(params) {
|
|
11
|
-
return {
|
|
12
|
-
filters: { colors: params.get("colors")?.split(",") ?? [] },
|
|
13
|
-
sort: {
|
|
14
|
-
by: params.get("sortBy") ?? "relevance",
|
|
15
|
-
direction: params.get("sortDirection") ?? "asc",
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export { createSearchParams, parseSearchParams };
|