import { motion } from 'framer-motion'; import { memo } from 'react'; import { classNames } from '~/utils/classNames'; import { cubicEasingFn } from '~/utils/easings'; import { genericMemo } from '~/utils/react'; interface SliderOption { value: T; text: string; } export interface SliderOptions { left: SliderOption; right: SliderOption; } interface SliderProps { selected: T; options: SliderOptions; setSelected?: (selected: T) => void; } export const Slider = genericMemo(({ selected, options, setSelected }: SliderProps) => { const isLeftSelected = selected === options.left.value; return (
setSelected?.(options.left.value)}> {options.left.text} setSelected?.(options.right.value)}> {options.right.text}
); }); interface SliderButtonProps { selected: boolean; children: string | JSX.Element | Array; setSelected: () => void; } const SliderButton = memo(({ selected, children, setSelected }: SliderButtonProps) => { return ( ); });