From e4da908ae8924de7822a85e72801851f458f52cc Mon Sep 17 00:00:00 2001
From: w3bdesign <45217974+w3bdesign@users.noreply.github.com>
Date: Wed, 29 Jan 2025 03:55:43 +0100
Subject: [PATCH 4/7] Remove unused import
---
src/components/Product/ProductFilters.component.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/Product/ProductFilters.component.tsx b/src/components/Product/ProductFilters.component.tsx
index 45b8b1a1f..2eadbc7e1 100644
--- a/src/components/Product/ProductFilters.component.tsx
+++ b/src/components/Product/ProductFilters.component.tsx
@@ -1,4 +1,4 @@
-import { Dispatch, SetStateAction, ChangeEvent } from 'react';
+import { Dispatch, SetStateAction } from 'react';
import { Product, ProductType } from '@/types/product';
import Button from '@/components/UI/Button.component';
import Checkbox from '@/components/UI/Checkbox.component';
From 03e2791b0b015f0c50ea775a41ecac031f1822b8 Mon Sep 17 00:00:00 2001
From: w3bdesign <45217974+w3bdesign@users.noreply.github.com>
Date: Wed, 29 Jan 2025 03:57:12 +0100
Subject: [PATCH 5/7] Slider cursor
---
src/components/Product/ProductFilters.component.tsx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/components/Product/ProductFilters.component.tsx b/src/components/Product/ProductFilters.component.tsx
index 2eadbc7e1..bc1d48512 100644
--- a/src/components/Product/ProductFilters.component.tsx
+++ b/src/components/Product/ProductFilters.component.tsx
@@ -95,7 +95,7 @@ const ProductFilters = ({
onChange={(e) =>
setPriceRange([priceRange[0], parseInt(e.target.value)])
}
- className="w-full"
+ className="w-full cursor-pointer"
/>
kr {priceRange[0]}
From e2af0e781cc5d81c7d463339ee50ddc5d73aa45d Mon Sep 17 00:00:00 2001
From: w3bdesign <45217974+w3bdesign@users.noreply.github.com>
Date: Wed, 29 Jan 2025 03:58:27 +0100
Subject: [PATCH 6/7] Reusable Range slider
---
.../Product/ProductFilters.component.tsx | 27 ++++----
src/components/UI/RangeSlider.component.tsx | 63 +++++++++++++++++++
2 files changed, 74 insertions(+), 16 deletions(-)
create mode 100644 src/components/UI/RangeSlider.component.tsx
diff --git a/src/components/Product/ProductFilters.component.tsx b/src/components/Product/ProductFilters.component.tsx
index bc1d48512..ce8b960e7 100644
--- a/src/components/Product/ProductFilters.component.tsx
+++ b/src/components/Product/ProductFilters.component.tsx
@@ -2,6 +2,7 @@ import { Dispatch, SetStateAction } from 'react';
import { Product, ProductType } from '@/types/product';
import Button from '@/components/UI/Button.component';
import Checkbox from '@/components/UI/Checkbox.component';
+import RangeSlider from '@/components/UI/RangeSlider.component';
interface ProductFiltersProps {
selectedSizes: string[];
@@ -85,22 +86,16 @@ const ProductFilters = ({
PRIS
-
-
- setPriceRange([priceRange[0], parseInt(e.target.value)])
- }
- className="w-full cursor-pointer"
- />
-
- kr {priceRange[0]}
- kr {priceRange[1]}
-
+
setPriceRange([priceRange[0], value])}
+ formatValue={(value) => `kr ${value}`}
+ />
diff --git a/src/components/UI/RangeSlider.component.tsx b/src/components/UI/RangeSlider.component.tsx
new file mode 100644
index 000000000..0235a7b30
--- /dev/null
+++ b/src/components/UI/RangeSlider.component.tsx
@@ -0,0 +1,63 @@
+import { ChangeEvent } from 'react';
+
+interface IRangeSliderProps {
+ id: string;
+ label: string;
+ min: number;
+ max: number;
+ value: number;
+ onChange: (value: number) => void;
+ startValue?: number;
+ formatValue?: (value: number) => string;
+}
+
+/**
+ * A reusable range slider component with labels
+ * @function RangeSlider
+ * @param {string} id - Unique identifier for the slider
+ * @param {string} label - Accessible label for the slider
+ * @param {number} min - Minimum value of the range
+ * @param {number} max - Maximum value of the range
+ * @param {number} value - Current value of the slider
+ * @param {function} onChange - Handler for when the slider value changes
+ * @param {number} startValue - Optional starting value to display (defaults to min)
+ * @param {function} formatValue - Optional function to format the displayed values
+ * @returns {JSX.Element} - Rendered component
+ */
+const RangeSlider = ({
+ id,
+ label,
+ min,
+ max,
+ value,
+ onChange,
+ startValue = min,
+ formatValue = (val: number) => val.toString(),
+}: IRangeSliderProps) => {
+ const handleChange = (e: ChangeEvent
) => {
+ onChange(parseInt(e.target.value));
+ };
+
+ return (
+
+
+
+
+ {formatValue(startValue)}
+ {formatValue(value)}
+
+
+ );
+};
+
+export default RangeSlider;
From 76110055256a991b42b103444fa4324b9cbfe08b Mon Sep 17 00:00:00 2001
From: w3bdesign <45217974+w3bdesign@users.noreply.github.com>
Date: Wed, 29 Jan 2025 04:02:21 +0100
Subject: [PATCH 7/7] Fix build errors
---
src/components/Cart/CartContents.component.tsx | 6 +++---
src/components/Index/Hero.component.tsx | 2 +-
src/components/UI/Button.component.tsx | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/components/Cart/CartContents.component.tsx b/src/components/Cart/CartContents.component.tsx
index 8e6d1790e..f449fd490 100644
--- a/src/components/Cart/CartContents.component.tsx
+++ b/src/components/Cart/CartContents.component.tsx
@@ -136,7 +136,7 @@ const CartContents = () => {
data.cart.contents.nodes,
)
}
- color="red"
+ variant="secondary"
buttonDisabled={updateCartProcessing}
>
Fjern
@@ -156,7 +156,7 @@ const CartContents = () => {
{!isCheckoutPage && (
-
+
)}
@@ -168,7 +168,7 @@ const CartContents = () => {
Ingen produkter i handlekurven
-
+
)}
diff --git a/src/components/Index/Hero.component.tsx b/src/components/Index/Hero.component.tsx
index d2cfdd4f4..06fa67e03 100644
--- a/src/components/Index/Hero.component.tsx
+++ b/src/components/Index/Hero.component.tsx
@@ -27,7 +27,7 @@ const Hero = () => (
diff --git a/src/components/UI/Button.component.tsx b/src/components/UI/Button.component.tsx
index 39af09223..8ffb7793a 100644
--- a/src/components/UI/Button.component.tsx
+++ b/src/components/UI/Button.component.tsx
@@ -56,7 +56,7 @@ const Button = ({
fullWidth ? 'w-full md:w-auto' : ''
}`;
- if (href && variant === 'hero') {
+ if (href) {
return (
{children}