All files / src/components/profile/tabs BrandColorPicker.tsx

100% Statements 10/10
100% Branches 17/17
100% Functions 7/7
100% Lines 10/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150                    2x                                           14x                             84x 84x         1x 1x                                                                                 1x         1x                                   1x         1x                                                    
import { Palette, Check } from "lucide-react";
import { Input } from "../../ui/input";
import {
	Card,
	CardContent,
	CardHeader,
	CardTitle,
	CardDescription,
} from "../../ui/card";
 
const BRAND_COLORS = [
	{ primary: "#0F172A", secondary: "#3B82F6", name: "Professional Blue" },
	{ primary: "#134E4A", secondary: "#14B8A6", name: "Modern Teal" },
	{ primary: "#7C2D12", secondary: "#F97316", name: "Warm Orange" },
	{ primary: "#581C87", secondary: "#A855F7", name: "Elegant Purple" },
	{ primary: "#166534", secondary: "#22C55E", name: "Fresh Green" },
	{ primary: "#881337", secondary: "#EC4899", name: "Bold Pink" },
];
 
interface BrandColorPickerProps {
	primary: string;
	secondary: string;
	onPrimaryChange: (value: string) => void;
	onSecondaryChange: (value: string) => void;
}
 
export function BrandColorPicker({
	primary,
	secondary,
	onPrimaryChange,
	onSecondaryChange,
}: BrandColorPickerProps) {
	return (
		<Card>
			<CardHeader>
				<CardTitle className="flex items-center gap-2">
					<Palette className="h-5 w-5" />
					Brand Colors
				</CardTitle>
				<CardDescription>
					Choose colors that represent your brand
				</CardDescription>
			</CardHeader>
			<CardContent className="space-y-4">
				<div className="grid grid-cols-3 sm:grid-cols-6 gap-3">
					{BRAND_COLORS.map((color) => {
						const isSelected =
							primary === color.primary && secondary === color.secondary;
						return (
							<button
								key={color.name}
								type="button"
								onClick={() => {
									onPrimaryChange(color.primary);
									onSecondaryChange(color.secondary);
								}}
								className={`relative flex flex-col items-center gap-1 p-2 rounded-lg border-2 transition-all ${
									isSelected
										? "border-primary-500 ring-2 ring-primary-500/20"
										: "border-border-default hover:border-border-hover"
								}`}
							>
								<div className="flex gap-1">
									<div
										className="w-6 h-6 rounded-full"
										style={{ backgroundColor: color.primary }}
									/>
									<div
										className="w-6 h-6 rounded-full"
										style={{ backgroundColor: color.secondary }}
									/>
								</div>
								<span className="text-[10px] text-foreground-subtle text-center leading-tight">
									{color.name}
								</span>
								{isSelected && (
									<Check className="absolute -top-1 -right-1 h-4 w-4 text-primary-500 bg-background-elevated rounded-full" />
								)}
							</button>
						);
					})}
				</div>
				<div className="flex items-center gap-4">
					<div>
						<label
							htmlFor="brandColorPrimary"
							className="block text-xs text-foreground-subtle mb-1"
						>
							Primary
						</label>
						<div className="flex items-center gap-2">
							<input
								type="color"
								id="brandColorPrimary"
								value={primary || "#0F172A"}
								onChange={(e) => onPrimaryChange(e.target.value)}
								className="h-8 w-8 rounded cursor-pointer border-0"
							/>
							<Input
								value={primary}
								onChange={(e) => onPrimaryChange(e.target.value)}
								placeholder="#0F172A"
								className="w-24 text-xs"
							/>
						</div>
					</div>
					<div>
						<label
							htmlFor="brandColorSecondary"
							className="block text-xs text-foreground-subtle mb-1"
						>
							Secondary
						</label>
						<div className="flex items-center gap-2">
							<input
								type="color"
								id="brandColorSecondary"
								value={secondary || "#3B82F6"}
								onChange={(e) => onSecondaryChange(e.target.value)}
								className="h-8 w-8 rounded cursor-pointer border-0"
							/>
							<Input
								value={secondary}
								onChange={(e) => onSecondaryChange(e.target.value)}
								placeholder="#3B82F6"
								className="w-24 text-xs"
							/>
						</div>
					</div>
					{(primary || secondary) && (
						<div className="ml-auto">
							<span className="block text-xs text-foreground-subtle mb-1">
								Preview
							</span>
							<div
								className="px-4 py-2 rounded-md text-foreground-inverse text-xs font-medium"
								style={{ backgroundColor: primary || "#0F172A" }}
							>
								<span style={{ color: secondary || "#3B82F6" }}>
									Your Brand
								</span>
							</div>
						</div>
					)}
				</div>
			</CardContent>
		</Card>
	);
}