enhancement: update thumbnail chat width option setting (#4284)

This commit is contained in:
Faisal Amir 2024-12-19 11:02:44 +08:00 committed by GitHub
parent 9c5bda758d
commit d12408cd83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 42 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -6,6 +6,8 @@ import { fs, joinPath } from '@janhq/core'
import { Button, Select, Switch } from '@janhq/joi' import { Button, Select, Switch } from '@janhq/joi'
import { useAtom, useAtomValue } from 'jotai' import { useAtom, useAtomValue } from 'jotai'
import { twMerge } from 'tailwind-merge'
import { import {
chatWidthAtom, chatWidthAtom,
janThemesPathAtom, janThemesPathAtom,
@ -19,7 +21,7 @@ import {
export default function AppearanceOptions() { export default function AppearanceOptions() {
const [selectedIdTheme, setSelectedIdTheme] = useAtom(selectedThemeIdAtom) const [selectedIdTheme, setSelectedIdTheme] = useAtom(selectedThemeIdAtom)
const themeOptions = useAtomValue(themesOptionsAtom) const themeOptions = useAtomValue(themesOptionsAtom)
const { setTheme } = useTheme() const { setTheme, theme } = useTheme()
const janThemesPath = useAtomValue(janThemesPathAtom) const janThemesPath = useAtomValue(janThemesPathAtom)
const [themeData, setThemeData] = useAtom(themeDataAtom) const [themeData, setThemeData] = useAtom(themeDataAtom)
const [reduceTransparent, setReduceTransparent] = useAtom( const [reduceTransparent, setReduceTransparent] = useAtom(
@ -29,11 +31,17 @@ export default function AppearanceOptions() {
const [chatWidth, setChatWidth] = useAtom(chatWidthAtom) const [chatWidth, setChatWidth] = useAtom(chatWidthAtom)
const chatWidthOption = [ const chatWidthOption = [
{ name: 'Full Width', value: 'full', img: 'images/full-width.png' }, {
name: 'Full Width',
value: 'full',
img: 'images/full-width.png',
darkImg: 'images/full-width-dark.png',
},
{ {
name: 'Compact Width', name: 'Compact Width',
value: 'compact', value: 'compact',
img: 'images/compact-width.png', img: 'images/compact-width.png',
darkImg: 'images/compact-width-dark.png',
}, },
] ]
@ -123,26 +131,44 @@ export default function AppearanceOptions() {
<label <label
className="relative cursor-pointer" className="relative cursor-pointer"
htmlFor={option.name} htmlFor={option.name}
onClick={() => setChatWidth(option.value)}
> >
<img <img
src={option.img} src={theme === 'dark' ? option.darkImg : option.img}
alt={option.value} alt={option.value}
width={140} width={140}
className="rounded-lg" className={twMerge(
'rounded-lg border-2 border-[hsla(var(--app-border))] bg-[hsla(var(--secondary-bg))] transition-all',
chatWidth === option.value &&
'border-[hsla(var(--primary-bg))]'
)}
/> />
<p className="my-2 font-medium">{option.name}</p> <p className="my-2 font-medium">{option.name}</p>
<div className="relative"> {chatWidth === option.value && (
<input <div className="absolute right-2 top-2 ">
name="chatWidth" <svg
value={option.value} width="24"
checked={chatWidth === option.value} height="24"
onChange={() => setChatWidth(option.value)} viewBox="0 0 16 16"
type="radio" fill="none"
className="peer h-5 w-5 cursor-pointer appearance-none rounded-full border border-[hsla(var(--app-border))] transition-all checked:border-[hsla(var(--primary-bg))]" xmlns="http://www.w3.org/2000/svg"
id={option.name} >
<rect
width="16"
height="16"
rx="8"
className="fill-[hsla(var(--primary-bg))]"
/> />
<span className="absolute left-1/2 top-1/2 -mt-[3px] h-3 w-3 -translate-x-1/2 -translate-y-1/2 transform rounded-full bg-[hsla(var(--primary-bg))] opacity-0 transition-opacity duration-200 peer-checked:opacity-100"></span> <path
d="M11.1111 5.66699L6.83333 9.94477L4.88889 8.00033"
stroke="white"
strokeWidth="0.886667"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</div> </div>
)}
</label> </label>
</div> </div>
) )