mirror of
https://github.com/pawelmalak/flame.git
synced 2025-06-28 01:06:33 -04:00
Fixed visual bug with custom theme editor modal. Added Mint theme
This commit is contained in:
parent
0f6d79683e
commit
2c0491a5b0
7 changed files with 55 additions and 17 deletions
|
@ -2,6 +2,7 @@
|
||||||
- Added custom theme editor ([#246](https://github.com/pawelmalak/flame/issues/246))
|
- Added custom theme editor ([#246](https://github.com/pawelmalak/flame/issues/246))
|
||||||
- Fixed bug where pressing Enter with empty search bar would redirect to search results ([#325](https://github.com/pawelmalak/flame/issues/325))
|
- Fixed bug where pressing Enter with empty search bar would redirect to search results ([#325](https://github.com/pawelmalak/flame/issues/325))
|
||||||
- Fixed bug where user could create empty app or bookmark which was causing page to go blank ([#332](https://github.com/pawelmalak/flame/issues/332))
|
- Fixed bug where user could create empty app or bookmark which was causing page to go blank ([#332](https://github.com/pawelmalak/flame/issues/332))
|
||||||
|
- Added new theme: Mint
|
||||||
|
|
||||||
### v2.2.2 (2022-03-21)
|
### v2.2.2 (2022-03-21)
|
||||||
- Added option to get user location directly from the app ([#287](https://github.com/pawelmalak/flame/issues/287))
|
- Added option to get user location directly from the app ([#287](https://github.com/pawelmalak/flame/issues/287))
|
||||||
|
|
|
@ -41,7 +41,11 @@ export const ThemeBuilder = ({ themes }: Props): JSX.Element => {
|
||||||
return (
|
return (
|
||||||
<div className={classes.ThemeBuilder}>
|
<div className={classes.ThemeBuilder}>
|
||||||
{/* MODALS */}
|
{/* MODALS */}
|
||||||
<Modal isOpen={showModal} setIsOpen={() => toggleShowModal(!showModal)}>
|
<Modal
|
||||||
|
isOpen={showModal}
|
||||||
|
setIsOpen={() => toggleShowModal(!showModal)}
|
||||||
|
cb={() => editTheme(null)}
|
||||||
|
>
|
||||||
{isInEdit ? (
|
{isInEdit ? (
|
||||||
<ThemeEditor modalHandler={() => toggleShowModal(!showModal)} />
|
<ThemeEditor modalHandler={() => toggleShowModal(!showModal)} />
|
||||||
) : (
|
) : (
|
||||||
|
@ -65,7 +69,7 @@ export const ThemeBuilder = ({ themes }: Props): JSX.Element => {
|
||||||
Create new theme
|
Create new theme
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{themes.length && (
|
{themes.length ? (
|
||||||
<Button
|
<Button
|
||||||
click={() => {
|
click={() => {
|
||||||
toggleIsInEdit(true);
|
toggleIsInEdit(true);
|
||||||
|
@ -74,6 +78,8 @@ export const ThemeBuilder = ({ themes }: Props): JSX.Element => {
|
||||||
>
|
>
|
||||||
Edit user themes
|
Edit user themes
|
||||||
</Button>
|
</Button>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -22,7 +22,7 @@ export const ThemeCreator = ({ modalHandler }: Props): JSX.Element => {
|
||||||
theme: { activeTheme, themeInEdit },
|
theme: { activeTheme, themeInEdit },
|
||||||
} = useSelector((state: State) => state);
|
} = useSelector((state: State) => state);
|
||||||
|
|
||||||
const { addTheme, updateTheme } = bindActionCreators(
|
const { addTheme, updateTheme, editTheme } = bindActionCreators(
|
||||||
actionCreators,
|
actionCreators,
|
||||||
useDispatch()
|
useDispatch()
|
||||||
);
|
);
|
||||||
|
@ -68,6 +68,11 @@ export const ThemeCreator = ({ modalHandler }: Props): JSX.Element => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const closeModal = () => {
|
||||||
|
editTheme(null);
|
||||||
|
modalHandler();
|
||||||
|
};
|
||||||
|
|
||||||
const formHandler = (e: FormEvent) => {
|
const formHandler = (e: FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
|
@ -78,14 +83,14 @@ export const ThemeCreator = ({ modalHandler }: Props): JSX.Element => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// close modal
|
// close modal
|
||||||
modalHandler();
|
closeModal();
|
||||||
|
|
||||||
// clear theme name
|
// clear theme name
|
||||||
setFormData({ ...formData, name: '' });
|
setFormData({ ...formData, name: '' });
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalForm formHandler={formHandler} modalHandler={modalHandler}>
|
<ModalForm formHandler={formHandler} modalHandler={closeModal}>
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<label htmlFor="name">Theme name</label>
|
<label htmlFor="name">Theme name</label>
|
||||||
<input
|
<input
|
||||||
|
|
|
@ -64,19 +64,19 @@ export const Themer = (): JSX.Element => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const customThemesEl = (
|
||||||
|
<Fragment>
|
||||||
|
<SettingsHeadline text="User themes" />
|
||||||
|
<ThemeBuilder themes={userThemes} />
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<SettingsHeadline text="App themes" />
|
<SettingsHeadline text="App themes" />
|
||||||
{!themes.length ? <Spinner /> : <ThemeGrid themes={themes} />}
|
{!themes.length ? <Spinner /> : <ThemeGrid themes={themes} />}
|
||||||
|
|
||||||
{!userThemes.length ? (
|
{!userThemes.length ? isAuthenticated && customThemesEl : customThemesEl}
|
||||||
isAuthenticated && 'auth and empty'
|
|
||||||
) : (
|
|
||||||
<Fragment>
|
|
||||||
<SettingsHeadline text="User themes" />
|
|
||||||
<ThemeBuilder themes={userThemes} />
|
|
||||||
</Fragment>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{isAuthenticated && (
|
{isAuthenticated && (
|
||||||
<form onSubmit={formSubmitHandler}>
|
<form onSubmit={formSubmitHandler}>
|
||||||
|
|
|
@ -6,24 +6,32 @@ interface Props {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
setIsOpen: Function;
|
setIsOpen: Function;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
|
cb?: Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Modal = (props: Props): JSX.Element => {
|
export const Modal = ({
|
||||||
|
isOpen,
|
||||||
|
setIsOpen,
|
||||||
|
children,
|
||||||
|
cb,
|
||||||
|
}: Props): JSX.Element => {
|
||||||
const modalRef = useRef(null);
|
const modalRef = useRef(null);
|
||||||
const modalClasses = [
|
const modalClasses = [
|
||||||
classes.Modal,
|
classes.Modal,
|
||||||
props.isOpen ? classes.ModalOpen : classes.ModalClose,
|
isOpen ? classes.ModalOpen : classes.ModalClose,
|
||||||
].join(' ');
|
].join(' ');
|
||||||
|
|
||||||
const clickHandler = (e: MouseEvent) => {
|
const clickHandler = (e: MouseEvent) => {
|
||||||
if (e.target === modalRef.current) {
|
if (e.target === modalRef.current) {
|
||||||
props.setIsOpen(false);
|
setIsOpen(false);
|
||||||
|
|
||||||
|
if (cb) cb();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={modalClasses} onClick={clickHandler} ref={modalRef}>
|
<div className={modalClasses} onClick={clickHandler} ref={modalRef}>
|
||||||
{props.children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -174,6 +174,15 @@
|
||||||
"accent": "#98c379"
|
"accent": "#98c379"
|
||||||
},
|
},
|
||||||
"isCustom": false
|
"isCustom": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "mint",
|
||||||
|
"colors": {
|
||||||
|
"background": "#282525",
|
||||||
|
"primary": "#d9d9d9",
|
||||||
|
"accent": "#50fbc2"
|
||||||
|
},
|
||||||
|
"isCustom": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -134,6 +134,15 @@
|
||||||
"accent": "#98c379"
|
"accent": "#98c379"
|
||||||
},
|
},
|
||||||
"isCustom": false
|
"isCustom": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "mint",
|
||||||
|
"colors": {
|
||||||
|
"background": "#282525",
|
||||||
|
"primary": "#d9d9d9",
|
||||||
|
"accent": "#50fbc2"
|
||||||
|
},
|
||||||
|
"isCustom": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue