Skip to content

Commit c82e500

Browse files
committed
separate component for the checkbox as it’s shared
1 parent 1fcb9d3 commit c82e500

File tree

3 files changed

+28
-43
lines changed

3 files changed

+28
-43
lines changed

apps/webapp/app/components/onboarding/TechnologyPicker.tsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
ChevronDownIcon,
88
} from "@heroicons/react/20/solid";
99
import { useCallback, useMemo, useRef, useState } from "react";
10+
import { CheckboxIndicator } from "~/components/primitives/CheckboxIndicator";
1011
import { cn } from "~/utils/cn";
1112
import { matchSorter } from "match-sorter";
1213
import { ShortcutKey } from "~/components/primitives/ShortcutKey";
@@ -252,26 +253,7 @@ export function TechnologyPicker({
252253
}}
253254
>
254255
<div className="flex h-8 w-full items-center gap-2 rounded-sm px-2 group-data-[active-item=true]:bg-tertiary hover:bg-tertiary">
255-
<div
256-
className={cn(
257-
"flex size-4 flex-none items-center justify-center rounded border",
258-
value.includes(option)
259-
? "border-indigo-500 bg-indigo-600"
260-
: "border-charcoal-600 bg-charcoal-700"
261-
)}
262-
>
263-
{value.includes(option) && (
264-
<svg className="size-3 text-white" viewBox="0 0 12 12" fill="none">
265-
<path
266-
d="M2.5 6L5 8.5L9.5 3.5"
267-
stroke="currentColor"
268-
strokeWidth="1.5"
269-
strokeLinecap="round"
270-
strokeLinejoin="round"
271-
/>
272-
</svg>
273-
)}
274-
</div>
256+
<CheckboxIndicator checked={value.includes(option)} />
275257
<span className="grow truncate text-text-bright">{option}</span>
276258
</div>
277259
</Ariakit.ComboboxItem>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { cn } from "~/utils/cn";
2+
3+
export function CheckboxIndicator({ checked }: { checked: boolean }) {
4+
return (
5+
<div
6+
className={cn(
7+
"flex size-4 flex-none items-center justify-center rounded border",
8+
checked ? "border-indigo-500 bg-indigo-600" : "border-charcoal-600 bg-charcoal-700"
9+
)}
10+
>
11+
{checked && (
12+
<svg className="size-3 text-white" viewBox="0 0 12 12" fill="none">
13+
<path
14+
d="M2.5 6L5 8.5L9.5 3.5"
15+
stroke="currentColor"
16+
strokeWidth="1.5"
17+
strokeLinecap="round"
18+
strokeLinejoin="round"
19+
/>
20+
</svg>
21+
)}
22+
</div>
23+
);
24+
}

apps/webapp/app/components/primitives/Select.tsx

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -450,28 +450,7 @@ export interface SelectItemProps extends Ariakit.SelectItemProps {
450450
const selectItemClasses =
451451
"group cursor-pointer px-1 pt-1 text-2sm text-text-dimmed focus-custom last:pb-1";
452452

453-
function LeftCheckbox({ checked }: { checked: boolean }) {
454-
return (
455-
<div
456-
className={cn(
457-
"flex size-4 flex-none items-center justify-center rounded border",
458-
checked ? "border-indigo-500 bg-indigo-600" : "border-charcoal-600 bg-charcoal-700"
459-
)}
460-
>
461-
{checked && (
462-
<svg className="size-3 text-white" viewBox="0 0 12 12" fill="none">
463-
<path
464-
d="M2.5 6L5 8.5L9.5 3.5"
465-
stroke="currentColor"
466-
strokeWidth="1.5"
467-
strokeLinecap="round"
468-
strokeLinejoin="round"
469-
/>
470-
</svg>
471-
)}
472-
</div>
473-
);
474-
}
453+
import { CheckboxIndicator } from "./CheckboxIndicator";
475454

476455
export function SelectItem({
477456
icon,
@@ -523,7 +502,7 @@ export function SelectItem({
523502
checkPosition === "left" ? "gap-2" : "gap-1"
524503
)}
525504
>
526-
{checkPosition === "left" && <LeftCheckbox checked={isChecked} />}
505+
{checkPosition === "left" && <CheckboxIndicator checked={isChecked} />}
527506
{icon}
528507
<div className="grow truncate">{props.children || props.value}</div>
529508
{checkPosition === "right" && checkIcon}

0 commit comments

Comments
 (0)