|
1 | 1 | import type { CollectionEntry } from "astro:content"; |
| 2 | +import type { StylesConfig } from "react-select"; |
2 | 3 | import Select from "react-select"; |
3 | 4 | import { useEffect, useState } from "react"; |
4 | 5 |
|
@@ -41,6 +42,47 @@ export default function ProductSelect({ products, groups }: Props) { |
41 | 42 | }, |
42 | 43 | ]; |
43 | 44 |
|
| 45 | + const selectStyles: StylesConfig<Option, false> = { |
| 46 | + control: (base, state) => ({ |
| 47 | + ...base, |
| 48 | + backgroundColor: "var(--sl-color-gray-6)", |
| 49 | + borderColor: state.isFocused |
| 50 | + ? "var(--sl-color-gray-3)" |
| 51 | + : "var(--sl-color-gray-4)", |
| 52 | + "&:hover": { |
| 53 | + borderColor: "var(--sl-color-gray-3)", |
| 54 | + }, |
| 55 | + boxShadow: state.isFocused ? "0 0 0 1px var(--sl-color-gray-3)" : "none", |
| 56 | + }), |
| 57 | + menu: (base) => ({ |
| 58 | + ...base, |
| 59 | + backgroundColor: "var(--sl-color-gray-6)", |
| 60 | + borderColor: "var(--sl-color-gray-4)", |
| 61 | + }), |
| 62 | + option: (base, state) => ({ |
| 63 | + ...base, |
| 64 | + backgroundColor: state.isFocused |
| 65 | + ? "var(--sl-color-gray-5)" |
| 66 | + : "var(--sl-color-gray-6)", |
| 67 | + color: "var(--sl-color-gray-1)", |
| 68 | + "&:active": { |
| 69 | + backgroundColor: "var(--sl-color-gray-4)", |
| 70 | + }, |
| 71 | + }), |
| 72 | + singleValue: (base) => ({ |
| 73 | + ...base, |
| 74 | + color: "var(--sl-color-gray-1)", |
| 75 | + }), |
| 76 | + input: (base) => ({ |
| 77 | + ...base, |
| 78 | + color: "var(--sl-color-gray-1)", |
| 79 | + }), |
| 80 | + groupHeading: (base) => ({ |
| 81 | + ...base, |
| 82 | + color: "var(--sl-color-gray-3)", |
| 83 | + }), |
| 84 | + }; |
| 85 | + |
44 | 86 | useEffect(() => { |
45 | 87 | const url = new URL(window.location.href); |
46 | 88 | const param = url.searchParams.get("product"); |
@@ -78,6 +120,7 @@ export default function ProductSelect({ products, groups }: Props) { |
78 | 120 | options={options} |
79 | 121 | value={selectedOption} |
80 | 122 | onChange={handleChange} |
| 123 | + styles={selectStyles} |
81 | 124 | /> |
82 | 125 | ); |
83 | 126 | } |
0 commit comments