import { usePomodoroContext } from "use-pomodoro"; import { ButtonHTMLAttributes, useMemo, forwardRef } from "react"; import { FastForwardIcon } from "@heroicons/react/solid"; import { Provider, Root, Trigger, Content, Arrow, } from "@radix-ui/react-tooltip"; import { FC } from "react"; import * as Progress from "@radix-ui/react-progress"; const PomodoroProgress = () => { const { state } = usePomodoroContext(); // TODO: add pomodoro progress to use-pomodoro package return ( ); }; type TooltipProps = { content: string; }; export const Tooltip: FC = ({ children, content }) => ( {children} {content} ); type Size = "xs" | "sm" | "md" | "lg" | "xl"; type Variant = "primary" | "secondary" | "white" | "outline"; type HeroIconComponent = (props: React.ComponentProps<"svg">) => JSX.Element; type ButtonProps = ButtonHTMLAttributes; type CustomButtonProps = { size?: Size; variant?: Variant; leadingIcon?: HeroIconComponent; trailingIcon?: HeroIconComponent; }; type Props = ButtonProps & CustomButtonProps; const commonStyles = `inline-flex items-center border-2 border-transparent font-medium shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2`; export const Button = forwardRef( ( { size = "md", variant = "primary", children, className, disabled, leadingIcon: LeadingIcon, trailingIcon: TrailingIcon, ...rest }, ref ) => { const sizeStyles = useMemo(() => { return { xs: "px-2.5 py-1.5 text-xs rounded", sm: "px-3 py-2 text-sm leading-4 rounded-md", md: "px-4 py-2 text-sm rounded-md", lg: "px-4 py-2 text-base rounded-md", xl: "px-6 py-3 text-base rounded-md", }[size]; }, [size]); const variantStyles = useMemo(() => { return { primary: "bg-primary-600 hover:bg-primary-700 focus:ring-primary-500 text-white", secondary: "text-secondary-700 bg-secondary-100 hover:bg-secondary-200 focus:ring-secondary-500", white: "text-gray-700 bg-white hover:bg-gray-50 focus:ring-primary-500", outline: "text-primary-500 bg-transparent hover:bg-transparent/[0.2] focus:ring-primary-500 border-primary-500", }[variant]; }, [variant]); const disabledStyles = useMemo(() => { return disabled ? "cursor-not-allowed bg-gray-500 hover:bg-gray-500 text-gray-400 border-gray-500" : ""; }, [disabled]); const leadingIconStyles = useMemo(() => { return { xs: "hidden", sm: "-ml-0.5 mr-2 h-4 w-4", md: "-ml-1 mr-2 h-5 w-5", lg: "-ml-1 mr-3 h-5 w-5", xl: "-ml-1 mr-3 h-5 w-5", }[size]; }, [size]); const trailingIconStyles = useMemo(() => { return { xs: "hidden", sm: "ml-2 -mr-0.5 h-4 w-4", md: "ml-2 -mr-1 h-5 w-5", lg: "ml-3 -mr-1 h-5 w-5", xl: "ml-3 -mr-1 h-5 w-5", }[size]; }, [size]); return ( {LeadingIcon && ( )} {children} {TrailingIcon && ( )} ); } ); type Tab = { name: string; type: string; }; const tabs: Tab[] = [ { name: "Pomodoro", type: "pomodoro" }, { name: "Short Break", type: "shortBreak" }, { name: "Long Break", type: "longBreak" }, ]; function classNames(...classes: string[]) { return classes.filter(Boolean).join(" "); } function TimerTypeTabs() { const { state, goPomodoro, goShortBreak, goLongBreak } = usePomodoroContext(); return ( Select a tab {/* Use an "onChange" listener to redirect the user to the selected tab URL. */} {tabs.map((tab) => ( {tab.name} ))} {tabs.map((tab) => ( {tab.name} ))} ); } const App = () => { const { state, toggle, next } = usePomodoroContext(); return ( <> {state.formattedTimer} {state.paused ? "Start" : "Stop"} {!state.paused && ( // TODO: implement this in use-pomodoro package )} Current state: {JSON.stringify(state, null, 2)} > ); }; export default App;
{state.formattedTimer}
{JSON.stringify(state, null, 2)}