a collection of tools for fly for fun universe skillulator.lol

more action button refactors

besaid.zone 0f3ce459 e16ca40e

verified
Changed files
+36 -20
apps
skillulator
src
routes
c
$class
+32
apps/skillulator/src/routes/c/$class/components/action-buttons.tsx
··· 1 import clsx from "clsx"; 2 import { useTreeStore } from "@/zustand/treeStore"; 3 import type { Skill } from "@/types"; 4 5 export function DecreaseSkillPointButton(props: { 6 skill: Skill; ··· 119 </button> 120 ); 121 }
··· 1 import clsx from "clsx"; 2 import { useTreeStore } from "@/zustand/treeStore"; 3 import type { Skill } from "@/types"; 4 + import { t } from "i18next"; 5 6 export function DecreaseSkillPointButton(props: { 7 skill: Skill; ··· 120 </button> 121 ); 122 } 123 + 124 + export function CopyButton(props: { 125 + copied: boolean; 126 + copyToClipboard: () => void; 127 + }) { 128 + return ( 129 + <button 130 + type="button" 131 + disabled={props.copied} 132 + onClick={props.copyToClipboard} 133 + className={clsx( 134 + "h-min w-full self-end rounded-md bg-indigo-500 px-4 py-1.5 font-semibold text-white duration-150 hover:bg-indigo-600 md:w-max a11y-focus", 135 + props.copied ? "disabled:bg-green-500" : undefined, 136 + )} 137 + > 138 + {props.copied ? t("copiedText") : t("copyText")} 139 + </button> 140 + ); 141 + } 142 + 143 + export function ResetButton(props: { handleReset: () => void }) { 144 + return ( 145 + <button 146 + type="button" 147 + className="h-min w-full self-end rounded-md border border-red-300 bg-red-100 px-4 py-1.5 text-red-900 duration-150 hover:bg-red-200 md:w-max a11y-focus" 148 + onClick={props.handleReset} 149 + > 150 + {t("resetText")} 151 + </button> 152 + ); 153 + }
+4 -20
apps/skillulator/src/routes/c/$class/route.tsx
··· 1 - import { createFileRoute } from "@tanstack/react-router"; 2 - import { Link, useParams } from "@tanstack/react-router"; 3 import clsx from "clsx"; 4 import { t } from "i18next"; 5 import { Suspense } from "react"; 6 import Skill from "./components/Skill"; 7 import { useSkillTree } from "@/hooks/useSkillTree"; 8 9 export const Route = createFileRoute("/c/$class")({ 10 component: SkillTree, ··· 62 /> 63 </div> 64 </div> 65 - <button 66 - type="button" 67 - disabled={copied} 68 - onClick={copyToClipboard} 69 - className={clsx( 70 - "h-min w-full self-end rounded-md bg-indigo-500 px-4 py-1.5 font-semibold text-white duration-150 hover:bg-indigo-600 md:w-max a11y-focus", 71 - copied ? "disabled:bg-green-500" : undefined, 72 - )} 73 - > 74 - {copied ? t("copiedText") : t("copyText")} 75 - </button> 76 - <button 77 - type="button" 78 - className="h-min w-full self-end rounded-md border border-red-300 bg-red-100 px-4 py-1.5 text-red-900 duration-150 hover:bg-red-200 md:w-max a11y-focus" 79 - onClick={handleReset} 80 - > 81 - {t("resetText")} 82 - </button> 83 </div> 84 </div> 85 <div
··· 1 + import { Link, useParams, createFileRoute } from "@tanstack/react-router"; 2 import clsx from "clsx"; 3 import { t } from "i18next"; 4 import { Suspense } from "react"; 5 import Skill from "./components/Skill"; 6 import { useSkillTree } from "@/hooks/useSkillTree"; 7 + import { CopyButton, ResetButton } from "./components/action-buttons"; 8 9 export const Route = createFileRoute("/c/$class")({ 10 component: SkillTree, ··· 62 /> 63 </div> 64 </div> 65 + <CopyButton copied={copied} copyToClipboard={copyToClipboard} /> 66 + <ResetButton handleReset={handleReset} /> 67 </div> 68 </div> 69 <div