-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
103 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/components/forms/SelectBackgroundImage/SelectBackgroundImage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { useSettingsAtom } from "@/atom/useSettingsAtom"; | ||
import { Button } from "@/components/ui/button"; | ||
import { useBackgroundImageList } from "@/hooks/useBgImage"; | ||
import { twMerge } from "tailwind-merge"; | ||
import { tv } from "tailwind-variants"; | ||
|
||
export const BackgroundImageList = () => { | ||
const { settings, updateSettingAtom } = useSettingsAtom(); | ||
const { backgroundImageList } = useBackgroundImageList(); | ||
|
||
const selectImageVariants = tv({ | ||
base: "relative w-20 h-20 mx-2 rounded-2xl", | ||
variants: { | ||
selected: { | ||
true: "border-2 border-white", | ||
false: "border border-gray-500", | ||
}, | ||
}, | ||
}); | ||
|
||
return ( | ||
<div className="flex py-3"> | ||
{backgroundImageList.length > 0 && ( | ||
<Button | ||
className={twMerge( | ||
selectImageVariants({ | ||
selected: !settings.selectedBackgroundImg, | ||
}), | ||
"flex items-center justify-center bg-zinc-300 dark:bg-gray-800 hover:bg-zinc-200 dark:hover:bg-gray-900", | ||
)} | ||
onClick={() => { | ||
updateSettingAtom("selectedBackgroundImg", null); | ||
}} | ||
> | ||
{} | ||
</Button> | ||
)} | ||
|
||
{backgroundImageList | ||
.slice() | ||
.reverse() | ||
.map((image) => ( | ||
<button | ||
key={image.fileId} | ||
type="button" | ||
className={twMerge( | ||
selectImageVariants({ | ||
selected: settings.selectedBackgroundImg === image.fileId, | ||
}), | ||
"overflow-hidden", | ||
)} | ||
onClick={() => | ||
updateSettingAtom("selectedBackgroundImg", image.fileId) | ||
} | ||
> | ||
<img | ||
src={image.imageData} | ||
alt={`background image: ${image.fileId}`} | ||
className="object-cover w-full h-full" | ||
/> | ||
</button> | ||
))} | ||
</div> | ||
); | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters