244988e212
* Added a new dropdown help and feedback menu to the side menu * Added a shortcut to the popover menu * Removed dev cli connected button for now * Contact us form uses original Feedback component to prevent broken links * Improved the messaging when selecting different options in the email form * buttons style tweak * SideMenuItem supports the trailingIconClassName * Adding a consistent focus-visible states * Removing tooltips for now * Squashed commit of the following: commit7d11123c0aAuthor: Eric Goldman <eric@sequin.io> Date: Mon Sep 30 17:54:06 2024 -0700 Add sequin guide (#1368) Co-authored-by: James Ritchie <james@trigger.dev> commit8da495ac00Author: nicktrn <55853254+nicktrn@users.noreply.github.com> Date: Mon Sep 30 13:42:22 2024 +0100 Improve checkpoint reliability and cleanup of temp files (#1367) * improve cleanup reliability * improve logging * bye-bye execa * fix for trailing newlines * prettier errors * trim args and log output by default * fix archive cleanup * prevent potential memleak * more cleanup debug logs * ignore abort during cleanup * rename checkpoint dir env var and move to helper * add global never throw override * add tmp cleaner * also clean up checkpoint dir by default * split by any whitespace, not just tabs * only create tmp cleaner if paths to clean commit69ec68ee31Author: Eric Allam <eallam@icloud.com> Date: Sun Sep 29 19:18:39 2024 -0700 Release 3.0.9 commita6ea8444c9Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun Sep 29 19:17:26 2024 -0700 chore: Update version for release (#1366) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> commit4c1ee3d6eaAuthor: Eric Allam <eallam@icloud.com> Date: Sun Sep 29 19:09:38 2024 -0700 fix: run metadata not working when using npx/pnpm dlx * More support for custom-focus * More custom focus styles added * Support for focus-visible style for the Segmented control * Fixed table triple dot menu z-index issue * Improved help menu wording * When you submit the help form, close the modal * focus-visible style for radio buttons * button prop is now optional in the SideMenu component * focus styling for a text link * Deleted unused sequin files
98 lines
2.7 KiB
TypeScript
98 lines
2.7 KiB
TypeScript
import { RadioGroup } from "@headlessui/react";
|
|
import { motion } from "framer-motion";
|
|
import { cn } from "~/utils/cn";
|
|
|
|
const variants = {
|
|
primary: {
|
|
base: "bg-charcoal-700",
|
|
active: "text-text-bright hover:bg-charcoal-750/50",
|
|
},
|
|
secondary: {
|
|
base: "bg-charcoal-700/50",
|
|
active: "text-text-bright bg-charcoal-700 rounded-[2px] border border-charcoal-600/50",
|
|
},
|
|
};
|
|
|
|
type Variants = keyof typeof variants;
|
|
|
|
type Options = {
|
|
label: string;
|
|
value: string;
|
|
};
|
|
|
|
type SegmentedControlProps = {
|
|
name: string;
|
|
value?: string;
|
|
defaultValue?: string;
|
|
options: Options[];
|
|
variant?: Variants;
|
|
fullWidth?: boolean;
|
|
onChange?: (value: string) => void;
|
|
};
|
|
|
|
export default function SegmentedControl({
|
|
name,
|
|
value,
|
|
defaultValue,
|
|
options,
|
|
variant = "secondary",
|
|
fullWidth,
|
|
onChange,
|
|
}: SegmentedControlProps) {
|
|
return (
|
|
<div
|
|
className={cn(
|
|
"flex h-10 rounded text-text-bright",
|
|
variants[variant].base,
|
|
fullWidth ? "w-full" : "w-fit"
|
|
)}
|
|
>
|
|
<RadioGroup
|
|
value={value}
|
|
defaultValue={defaultValue ?? options[0].value}
|
|
name={name}
|
|
onChange={(c: string) => {
|
|
if (onChange) {
|
|
onChange(c);
|
|
}
|
|
}}
|
|
className="w-full"
|
|
>
|
|
<div className="flex h-full w-full items-center justify-between gap-x-1 p-1">
|
|
{options.map((option) => (
|
|
<RadioGroup.Option
|
|
key={option.value}
|
|
value={option.value}
|
|
className={({ active, checked }) =>
|
|
cn(
|
|
"relative flex h-full grow cursor-pointer text-center font-normal focus-custom",
|
|
checked
|
|
? variants[variant].active
|
|
: "text-text-dimmed transition hover:text-text-bright"
|
|
)
|
|
}
|
|
>
|
|
{({ checked }) => (
|
|
<>
|
|
<div className="relative flex h-full w-full items-center justify-between px-3 py-[0.13rem]">
|
|
<div className="z-10 flex h-full w-full items-center justify-center text-sm">
|
|
<RadioGroup.Label as="p">{option.label}</RadioGroup.Label>
|
|
</div>
|
|
{checked && variant === "primary" && (
|
|
<motion.div
|
|
layoutId={`segmented-control-${name}`}
|
|
transition={{ duration: 0.4, type: "spring" }}
|
|
className="absolute inset-0 rounded-[2px] shadow-md outline outline-3 outline-primary"
|
|
/>
|
|
)}
|
|
</div>
|
|
</>
|
|
)}
|
|
</RadioGroup.Option>
|
|
))}
|
|
</div>
|
|
</RadioGroup>
|
|
</div>
|
|
);
|
|
}
|