Skip to content

Commit

Permalink
add copy to clipboard for craft names
Browse files Browse the repository at this point in the history
  • Loading branch information
cohenaj194 committed Jul 11, 2024
1 parent c06b557 commit 967994b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
32 changes: 31 additions & 1 deletion app/routes/ffxiv.craftsim._index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { PageWrapper } from '~/components/Common'
import NoResults from '~/components/Common/NoResults'
import SmallTable from '~/components/WoWResults/FullScan/SmallTable'
import CheckBox from '~/components/form/CheckBox'
import { ClipboardIcon } from '@heroicons/react/outline'
import { InputWithLabel } from '~/components/form/InputWithLabel'
import SmallFormContainer from '~/components/form/SmallFormContainer'
import ItemsFilter from '~/components/form/ffxiv/ItemsFilter'
Expand Down Expand Up @@ -46,6 +47,25 @@ import {
import { SubmitButton } from '~/components/form/SubmitButton'
import { dOHOptions } from '~/consts'

const CopyButton = ({ text }: { text: string }) => {
const handleCopy = async () => {
try {
await navigator.clipboard.writeText(text)
alert('Copied to clipboard!')
} catch (err) {
alert('Failed to copy text')
}
}

return (
<button
onClick={handleCopy}
className="text-blue-500 hover:text-blue-700 focus:outline-none">
<ClipboardIcon className="h-5 w-5 inline" />
</button>
)
}

// Overwrite default meta in the root.tsx
export const meta: MetaFunction = () => {
return {
Expand Down Expand Up @@ -208,6 +228,7 @@ type ActionResponse =
})
| { exception: string }
| {}

export default function Index() {
const loaderData = useLoaderData<typeof defaultFormValues>()
const actionData = useActionData<ActionResponse>()
Expand Down Expand Up @@ -450,7 +471,16 @@ const mobileColumnList = [
]

const columnList: Array<ColumnList<FlatCraftingList>> = [
{ columnId: 'itemName', header: 'Item Name' },
{
columnId: 'itemName',
header: 'Item Name',
accessor: ({ row: { itemName } }) => (
<div className="flex items-center justify-between">
<span>{itemName}</span>
<CopyButton text={itemName} />
</div>
)
},
{
columnId: 'profitEst',
header: 'Profit Est per Craft.',
Expand Down
5 changes: 5 additions & 0 deletions app/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -2503,6 +2503,11 @@ select {
color: rgb(255 255 255 / var(--tw-text-opacity));
}

.hover\:text-blue-700:hover {
--tw-text-opacity: 1;
color: rgb(29 78 216 / var(--tw-text-opacity));
}

.hover\:underline:hover {
text-decoration-line: underline;
}
Expand Down

0 comments on commit 967994b

Please sign in to comment.