Skip to content

Commit 3d05b0b

Browse files
committed
Separate SVGX into a React component
1 parent d6c7056 commit 3d05b0b

File tree

5 files changed

+48
-31
lines changed

5 files changed

+48
-31
lines changed

components/Cart/CartPage/CartItem.component.jsx

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState } from 'react';
2-
import { v4 } from 'uuid';
32

4-
import SVGCloseX from 'components/SVG/SVGCloseX.component';
3+
import SVGX from "components/SVG/SVGX.component"
4+
55

66
const CartItem = ({
77
item,
@@ -16,26 +16,15 @@ const CartItem = ({
1616
<tr className="bg-gray-100">
1717
<td className="px-4 py-2 border">
1818
<span>
19-
<svg
20-
id="xsvg"
19+
<SVGX
2120
onClick={() => {
2221
//setisExpanded(!isExpanded);
2322
}}
23+
/>
24+
25+
2426

25-
xmlns="http://www.w3.org/2000/svg"
26-
width="20"
27-
height="20"
28-
viewBox="0 0 20 20"
29-
fill="none"
30-
stroke="currentColor"
31-
strokeWidth="2"
32-
strokeLinecap="round"
33-
strokeLinejoin="round"
34-
className="feather feather-x"
35-
>
36-
<line x1="18" y1="6" x2="6" y2="18"></line>
37-
<line x1="6" y1="6" x2="18" y2="18"></line>
38-
</svg>
27+
3928

4029
</span>
4130
</td>

components/Header/Hamburger.component.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ const Hamburger = () => {
9999
className="absolute right-0 z-10 w-full text-center text-black bg-white "
100100
>
101101
<ul>
102-
<li className="w-full p-4 border-b border-gray-400 border-solid rounded">
102+
<li className="w-full p-4 border-b border-gray-400 border-solid rounded">
103103
<Link href="/">
104104
<a
105105
className="inline-block px-4 py-2 no-underline hover:text-black hover:underline"
@@ -119,7 +119,10 @@ const Hamburger = () => {
119119
</a>
120120
</Link>
121121
</li>
122-
<li id="mobile-li" className="w-full p-4 border-b border-gray-400 border-solid rounded">
122+
<li
123+
id="mobile-li"
124+
className="w-full p-4 border-b border-gray-400 border-solid rounded"
125+
>
123126
<Link href="/kategorier">
124127
<a
125128
className="inline-block px-4 py-2 no-underline hover:text-black hover:underline"
@@ -128,7 +131,7 @@ const Hamburger = () => {
128131
Kategorier
129132
</a>
130133
</Link>
131-
</li>
134+
</li>
132135
</ul>
133136
</animated.div>
134137
)}

components/SVG/SVGCloseX.component.jsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
/**
2-
* The SVG that we display to close the cart or the mobile search
3-
* @param {Object} props
2+
* The SVG that we display to close the cart or the mobile search
43
*/
5-
const SVGCloseX = (props) => {
6-
7-
8-
const { isExpanded, setisExpanded } = props;
4+
const SVGCloseX = () => {
95
return (
106
<>
117
<svg
128
width="80px"
139
height="80px"
14-
onClick={() => {
15-
setisExpanded(!isExpanded);
16-
}}
1710
xmlns="http://www.w3.org/2000/svg"
1811
viewBox="0 0 234.6 45.47"
1912
>

components/SVG/SVGMobileSearchIcon.component.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ const SVGMobileSearchIcon = () => {
4747
className="absolute right-0 z-50 w-full p-4 text-black bg-white"
4848
>
4949
<div className="absolute right-0 mr-6 -mt-12 cursor-pointer">
50-
<SVGCloseX isExpanded={isExpanded} setisExpanded={setisExpanded} />
50+
<SVGCloseX
51+
onClick={() => {
52+
setisExpanded(!isExpanded);
53+
}}
54+
/>
5155
</div>
5256
<br />
5357
<MobileSearch />

components/SVG/SVGX.component.jsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* The SVG that we display inside of the cart to remove items
3+
*/
4+
5+
const SVGX = () => {
6+
return (
7+
<>
8+
<svg
9+
id="xsvg"
10+
xmlns="http://www.w3.org/2000/svg"
11+
width="20"
12+
height="20"
13+
viewBox="0 0 20 20"
14+
fill="none"
15+
stroke="currentColor"
16+
strokeWidth="2"
17+
strokeLinecap="round"
18+
strokeLinejoin="round"
19+
className="feather feather-x"
20+
>
21+
<line x1="18" y1="6" x2="6" y2="18"></line>
22+
<line x1="6" y1="6" x2="18" y2="18"></line>
23+
</svg>
24+
</>
25+
);
26+
};
27+
28+
export default SVGX;

0 commit comments

Comments
 (0)