diff --git a/client/src/components/Settings/GeneralSettings/CustomQueries/CustomQueries.module.css b/client/src/components/Settings/GeneralSettings/CustomQueries/CustomQueries.module.css deleted file mode 100644 index 73297cc..0000000 --- a/client/src/components/Settings/GeneralSettings/CustomQueries/CustomQueries.module.css +++ /dev/null @@ -1,30 +0,0 @@ -.QueriesGrid { - display: grid; - grid-template-columns: repeat(3, 1fr); -} - -.QueriesGrid span { - color: var(--color-primary); -} - -.QueriesGrid span:last-child { - margin-bottom: 10px; -} - -.ActionIcons { - display: flex; -} - -.ActionIcons svg { - width: 20px; -} - -.ActionIcons svg:hover { - cursor: pointer; -} - -.Separator { - grid-column: 1 / 4; - border-bottom: 1px solid var(--color-primary); - margin: 10px 0; -} diff --git a/client/src/components/Settings/GeneralSettings/CustomQueries/CustomQueries.tsx b/client/src/components/Settings/GeneralSettings/CustomQueries/CustomQueries.tsx index 747be3b..8340308 100644 --- a/client/src/components/Settings/GeneralSettings/CustomQueries/CustomQueries.tsx +++ b/client/src/components/Settings/GeneralSettings/CustomQueries/CustomQueries.tsx @@ -9,11 +9,8 @@ import { actionCreators } from '../../../../store'; // Typescript import { Query } from '../../../../interfaces'; -// CSS -import classes from './CustomQueries.module.css'; - // UI -import { Modal, Icon, Button } from '../../../UI'; +import { Modal, Icon, Button, CompactTable, ActionIcons } from '../../../UI'; // Components import { QueriesForm } from './QueriesForm'; @@ -67,33 +64,25 @@ export const CustomQueries = (): JSX.Element => { )} -
-
- {customQueries.length > 0 && ( - - Name - Prefix - Actions - -
-
- )} - - {customQueries.map((q: Query, idx) => ( - - {q.name} - {q.prefix} - - updateHandler(q)}> - - - deleteHandler(q)}> - - - - - ))} -
+
+ {customQueries.length && ( + + {customQueries.map((q: Query, idx) => ( + + {q.name} + {q.prefix} + + updateHandler(q)}> + + + deleteHandler(q)}> + + + + + ))} + + )} -
+ ); }; diff --git a/client/src/components/Settings/Themer/ThemeBuilder/ThemeCreator.tsx b/client/src/components/Settings/Themer/ThemeBuilder/ThemeCreator.tsx index 0d696e6..e6526ce 100644 --- a/client/src/components/Settings/Themer/ThemeBuilder/ThemeCreator.tsx +++ b/client/src/components/Settings/Themer/ThemeBuilder/ThemeCreator.tsx @@ -1,17 +1,27 @@ -import { ChangeEvent, FormEvent, useState } from 'react'; -import { useDispatch } from 'react-redux'; +import { ChangeEvent, FormEvent, useState, useEffect } from 'react'; + +// Redux +import { useDispatch, useSelector } from 'react-redux'; import { bindActionCreators } from 'redux'; import { actionCreators } from '../../../../store'; -import { Theme } from '../../../../interfaces'; -import { Button, InputGroup, ModalForm } from '../../../UI'; +import { State } from '../../../../store/reducers'; +// UI +import { Button, InputGroup, ModalForm } from '../../../UI'; import classes from './ThemeCreator.module.css'; +// Other +import { Theme } from '../../../../interfaces'; + interface Props { modalHandler: () => void; } export const ThemeCreator = ({ modalHandler }: Props): JSX.Element => { + const { + theme: { activeTheme }, + } = useSelector((state: State) => state); + const { addTheme } = bindActionCreators(actionCreators, useDispatch()); const [formData, setFormData] = useState({ @@ -24,6 +34,10 @@ export const ThemeCreator = ({ modalHandler }: Props): JSX.Element => { }, }); + useEffect(() => { + setFormData({ ...formData, colors: activeTheme.colors }); + }, [activeTheme]); + const inputChangeHandler = (e: ChangeEvent) => { const { name, value } = e.target; diff --git a/client/src/components/UI/Icons/ActionIcons/ActionIcons.module.css b/client/src/components/UI/Icons/ActionIcons/ActionIcons.module.css new file mode 100644 index 0000000..d502f2e --- /dev/null +++ b/client/src/components/UI/Icons/ActionIcons/ActionIcons.module.css @@ -0,0 +1,11 @@ +.ActionIcons { + display: flex; +} + +.ActionIcons svg { + width: 20px; +} + +.ActionIcons svg:hover { + cursor: pointer; +} diff --git a/client/src/components/UI/Icons/ActionIcons/ActionIcons.tsx b/client/src/components/UI/Icons/ActionIcons/ActionIcons.tsx new file mode 100644 index 0000000..7b53035 --- /dev/null +++ b/client/src/components/UI/Icons/ActionIcons/ActionIcons.tsx @@ -0,0 +1,10 @@ +import { ReactNode } from 'react'; +import styles from './ActionIcons.module.css'; + +interface Props { + children: ReactNode; +} + +export const ActionIcons = ({ children }: Props): JSX.Element => { + return {children}; +}; diff --git a/client/src/components/UI/Tables/CompactTable/CompactTable.module.css b/client/src/components/UI/Tables/CompactTable/CompactTable.module.css new file mode 100644 index 0000000..1eeaa99 --- /dev/null +++ b/client/src/components/UI/Tables/CompactTable/CompactTable.module.css @@ -0,0 +1,16 @@ +.CompactTable { + display: grid; +} + +.CompactTable span { + color: var(--color-primary); +} + +.CompactTable span:last-child { + margin-bottom: 10px; +} + +.Separator { + border-bottom: 1px solid var(--color-primary); + margin: 10px 0; +} diff --git a/client/src/components/UI/Tables/CompactTable/CompactTable.tsx b/client/src/components/UI/Tables/CompactTable/CompactTable.tsx new file mode 100644 index 0000000..a5ae10a --- /dev/null +++ b/client/src/components/UI/Tables/CompactTable/CompactTable.tsx @@ -0,0 +1,27 @@ +import { ReactNode } from 'react'; +import classes from './CompactTable.module.css'; + +interface Props { + headers: string[]; + children?: ReactNode; +} + +export const CompactTable = ({ headers, children }: Props): JSX.Element => { + return ( +
+ {headers.map((h, idx) => ( + {h} + ))} + +
+ + {children} +
+ ); +}; diff --git a/client/src/components/UI/Table/Table.module.css b/client/src/components/UI/Tables/Table/Table.module.css similarity index 100% rename from client/src/components/UI/Table/Table.module.css rename to client/src/components/UI/Tables/Table/Table.module.css diff --git a/client/src/components/UI/Table/Table.tsx b/client/src/components/UI/Tables/Table/Table.tsx similarity index 100% rename from client/src/components/UI/Table/Table.tsx rename to client/src/components/UI/Tables/Table/Table.tsx diff --git a/client/src/components/UI/index.ts b/client/src/components/UI/index.ts index 23d5f73..179d982 100644 --- a/client/src/components/UI/index.ts +++ b/client/src/components/UI/index.ts @@ -1,10 +1,12 @@ -export * from './Table/Table'; +export * from './Tables/Table/Table'; +export * from './Tables/CompactTable/CompactTable'; export * from './Spinner/Spinner'; export * from './Notification/Notification'; export * from './Modal/Modal'; export * from './Layout/Layout'; export * from './Icons/Icon/Icon'; export * from './Icons/WeatherIcon/WeatherIcon'; +export * from './Icons/ActionIcons/ActionIcons'; export * from './Headlines/Headline/Headline'; export * from './Headlines/SectionHeadline/SectionHeadline'; export * from './Headlines/SettingsHeadline/SettingsHeadline';