Separated theme components

This commit is contained in:
Paweł Malak 2022-03-23 13:02:32 +01:00
parent baac78021a
commit ee0b435493
7 changed files with 44 additions and 17 deletions

View file

@ -164,7 +164,7 @@ export const GeneralSettings = (): JSX.Element => {
</select> </select>
</InputGroup> </InputGroup>
{/* SEARCH SETTINGS */} {/* === SEARCH OPTIONS === */}
<SettingsHeadline text="Search" /> <SettingsHeadline text="Search" />
<InputGroup> <InputGroup>
<label htmlFor="defaultSearchProvider">Default search provider</label> <label htmlFor="defaultSearchProvider">Default search provider</label>

View file

@ -0,0 +1,3 @@
export const ThemeBuilder = (): JSX.Element => {
return <h1>theme builder</h1>;
};

View file

@ -0,0 +1,30 @@
// Redux
import { useDispatch } from 'react-redux';
import { bindActionCreators } from 'redux';
import { actionCreators } from '../../../../store';
// Components
import { ThemePreview } from '../ThemePreview/ThemePreview';
// Other
import { Theme } from '../../../../interfaces';
import classes from './ThemeGrid.module.css';
interface Props {
themes: Theme[];
}
export const ThemeGrid = ({ themes }: Props): JSX.Element => {
const dispatch = useDispatch();
const { setTheme } = bindActionCreators(actionCreators, dispatch);
return (
<div className={classes.ThemerGrid}>
{themes.map(
(theme: Theme, idx: number): JSX.Element => (
<ThemePreview key={idx} theme={theme} applyTheme={setTheme} />
)
)}
</div>
);
};

View file

@ -1,4 +1,4 @@
import { Theme } from '../../../interfaces/Theme'; import { Theme } from '../../../../interfaces/Theme';
import classes from './ThemePreview.module.css'; import classes from './ThemePreview.module.css';
interface Props { interface Props {

View file

@ -9,11 +9,11 @@ import { actionCreators } from '../../../store';
import { Theme, ThemeSettingsForm } from '../../../interfaces'; import { Theme, ThemeSettingsForm } from '../../../interfaces';
// Components // Components
import { ThemePreview } from './ThemePreview';
import { Button, InputGroup, SettingsHeadline } from '../../UI'; import { Button, InputGroup, SettingsHeadline } from '../../UI';
import { ThemeBuilder } from './ThemeBuilder/ThemeBuilder';
import { ThemeGrid } from './ThemeGrid/ThemeGrid';
// Other // Other
import classes from './Themer.module.css';
import { themes } from './themes.json'; import { themes } from './themes.json';
import { State } from '../../../store/reducers'; import { State } from '../../../store/reducers';
import { inputHandler, themeSettingsTemplate } from '../../../utility'; import { inputHandler, themeSettingsTemplate } from '../../../utility';
@ -25,10 +25,7 @@ export const Themer = (): JSX.Element => {
} = useSelector((state: State) => state); } = useSelector((state: State) => state);
const dispatch = useDispatch(); const dispatch = useDispatch();
const { setTheme, updateConfig } = bindActionCreators( const { updateConfig } = bindActionCreators(actionCreators, dispatch);
actionCreators,
dispatch
);
// Initial state // Initial state
const [formData, setFormData] = useState<ThemeSettingsForm>( const [formData, setFormData] = useState<ThemeSettingsForm>(
@ -65,14 +62,11 @@ export const Themer = (): JSX.Element => {
return ( return (
<Fragment> <Fragment>
<SettingsHeadline text="Set theme" /> <SettingsHeadline text="App themes" />
<div className={classes.ThemerGrid}> <ThemeGrid themes={themes} />
{themes.map(
(theme: Theme, idx: number): JSX.Element => ( <SettingsHeadline text="User themes" />
<ThemePreview key={idx} theme={theme} applyTheme={setTheme} /> <ThemeBuilder />
)
)}
</div>
{isAuthenticated && ( {isAuthenticated && (
<form onSubmit={formSubmitHandler}> <form onSubmit={formSubmitHandler}>