add hidename switch

This commit is contained in:
SethBurkart123
2024-04-07 15:13:55 +10:00
parent b7e7c24727
commit 7c9896a128
3 changed files with 23 additions and 4 deletions
+4 -1
View File
@@ -61,7 +61,10 @@ export const ThemeCover: React.FC<ThemeCoverProps> = ({
className="absolute inset-0 z-0 object-cover" className="absolute inset-0 z-0 object-cover"
/> />
} }
<div className="z-10">{theme.name}</div> {
theme.hideThemeName ? <></> :
<div className="z-10">{theme.name}</div>
}
</div> </div>
</button> </button>
); );
+18 -3
View File
@@ -10,6 +10,7 @@ import { CustomTheme, CustomThemeBase64 } from '../types/CustomThemes';
import browser from 'webextension-polyfill'; import browser from 'webextension-polyfill';
function ThemeCreator() { function ThemeCreator() {
// default settings for new themes
const [theme, setTheme] = useState<CustomTheme>({ const [theme, setTheme] = useState<CustomTheme>({
id: uuidv4(), id: uuidv4(),
name: '', name: '',
@@ -20,7 +21,8 @@ function ThemeCreator() {
CustomCSS: '', CustomCSS: '',
CustomImages: [], CustomImages: [],
coverImage: null, coverImage: null,
isEditable: true isEditable: true,
hideThemeName: false,
}); });
useEffect(() => { useEffect(() => {
@@ -204,16 +206,29 @@ function ThemeCreator() {
} }
}} className="absolute inset-0 z-10 w-full h-full opacity-0 cursor-pointer" /> }} className="absolute inset-0 z-10 w-full h-full opacity-0 cursor-pointer" />
{ {
theme.coverImage && ( !theme.hideThemeName && theme.coverImage ?
<div className="absolute z-30">{theme.name}</div> : <></>
}
{
theme.coverImage &&
<> <>
<div className="absolute z-20 w-full h-full transition-opacity opacity-0 pointer-events-none group-hover:opacity-100 bg-black/20"></div> <div className="absolute z-20 w-full h-full transition-opacity opacity-0 pointer-events-none group-hover:opacity-100 bg-black/20"></div>
<img src={URL.createObjectURL(theme.coverImage as Blob)} alt='Cover Image' className="absolute z-0 object-cover w-full h-full rounded" /> <img src={URL.createObjectURL(theme.coverImage as Blob)} alt='Cover Image' className="absolute z-0 object-cover w-full h-full rounded" />
</> </>
)
} }
</div> </div>
<div className='flex items-center justify-between pt-4'> <div className='flex items-center justify-between pt-4'>
<div>
<div className='pr-2 text-sm font-semibold'>Hide Name</div>
<div className='pr-2 text-[11px]'>Useful when your cover image contains text</div>
</div>
<Switch state={theme.hideThemeName} onChange={value => setTheme({ ...theme, hideThemeName: value })} />
</div>
<Divider />
<div className='flex items-center justify-between'>
<div> <div>
<div className='pr-2 text-sm font-semibold'>Custom Theme Colour</div> <div className='pr-2 text-sm font-semibold'>Custom Theme Colour</div>
<div className='pr-2 text-[11px]'>Allow users to change the theme colour</div> <div className='pr-2 text-[11px]'>Allow users to change the theme colour</div>
+1
View File
@@ -9,6 +9,7 @@ export type CustomTheme = {
CustomImages: CustomImage[]; CustomImages: CustomImage[];
coverImage: Blob | string | null; coverImage: Blob | string | null;
isEditable: boolean; isEditable: boolean;
hideThemeName: boolean;
} }
export type CustomImage = { export type CustomImage = {