1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-21 20:39:36 +02:00
flame/client/src/components/Settings/Themer/ThemeBuilder/ThemeEditor.tsx

52 lines
1.4 KiB
TypeScript
Raw Normal View History

import { Fragment } from 'react';
// Redux
import { useSelector, useDispatch } from 'react-redux';
import { bindActionCreators } from 'redux';
import { Theme } from '../../../../interfaces';
import { actionCreators } from '../../../../store';
import { State } from '../../../../store/reducers';
// Other
import { ActionIcons, CompactTable, Icon, ModalForm } from '../../../UI';
2022-03-24 16:07:14 +01:00
interface Props {
modalHandler: () => void;
}
export const ThemeEditor = (props: Props): JSX.Element => {
const {
theme: { userThemes },
} = useSelector((state: State) => state);
const { deleteTheme } = bindActionCreators(actionCreators, useDispatch());
const updateHandler = (theme: Theme) => {};
const deleteHandler = (theme: Theme) => {
if (window.confirm(`Are you sure you want to delete this theme?`)) {
deleteTheme(theme.name);
}
};
2022-03-24 16:07:14 +01:00
return (
<ModalForm formHandler={() => {}} modalHandler={props.modalHandler}>
<CompactTable headers={['Name', 'Actions']}>
{userThemes.map((t, idx) => (
<Fragment key={idx}>
<span>{t.name}</span>
<ActionIcons>
<span onClick={() => updateHandler(t)}>
<Icon icon="mdiPencil" />
</span>
<span onClick={() => deleteHandler(t)}>
<Icon icon="mdiDelete" />
</span>
</ActionIcons>
</Fragment>
))}
</CompactTable>
2022-03-24 16:07:14 +01:00
</ModalForm>
);
};