diff options
Diffstat (limited to 'src/components/molecules/modals')
| -rw-r--r-- | src/components/molecules/modals/modal.stories.tsx | 13 | ||||
| -rw-r--r-- | src/components/molecules/modals/modal.tsx | 22 | ||||
| -rw-r--r-- | src/components/molecules/modals/tooltip.stories.tsx | 23 | ||||
| -rw-r--r-- | src/components/molecules/modals/tooltip.tsx | 15 |
4 files changed, 63 insertions, 10 deletions
diff --git a/src/components/molecules/modals/modal.stories.tsx b/src/components/molecules/modals/modal.stories.tsx index b68a24b..bd7d9f4 100644 --- a/src/components/molecules/modals/modal.stories.tsx +++ b/src/components/molecules/modals/modal.stories.tsx @@ -15,6 +15,19 @@ export default { required: true, }, }, + className: { + control: { + type: 'text', + }, + description: 'Set additional classnames to the modal.', + table: { + category: 'Styles', + }, + type: { + name: 'string', + required: false, + }, + }, icon: { control: { type: 'select', diff --git a/src/components/molecules/modals/modal.tsx b/src/components/molecules/modals/modal.tsx index 4dc3b0a..ce12e7a 100644 --- a/src/components/molecules/modals/modal.tsx +++ b/src/components/molecules/modals/modal.tsx @@ -1,17 +1,29 @@ import Heading from '@components/atoms/headings/heading'; +import { CogProps } from '@components/atoms/icons/cog'; +import { MagnifyingGlassProps } from '@components/atoms/icons/magnifying-glass'; import dynamic from 'next/dynamic'; -import { FC, ReactNode } from 'react'; +import { FC } from 'react'; import styles from './modal.module.scss'; export type Icons = 'cogs' | 'search'; export type ModalProps = { + /** + * Set additional classnames. + */ + className?: string; + /** + * A icon to illustrate the modal. + */ icon?: Icons; + /** + * The modal title. + */ title?: string; }; -const CogIcon = dynamic<ReactNode>(() => import('@components/atoms/icons/cog')); -const SearchIcon = dynamic<ReactNode>( +const CogIcon = dynamic<CogProps>(() => import('@components/atoms/icons/cog')); +const SearchIcon = dynamic<MagnifyingGlassProps>( () => import('@components/atoms/icons/magnifying-glass') ); @@ -20,7 +32,7 @@ const SearchIcon = dynamic<ReactNode>( * * Render a modal component with an optional title and icon. */ -const Modal: FC<ModalProps> = ({ children, icon, title }) => { +const Modal: FC<ModalProps> = ({ children, className = '', icon, title }) => { const getIcon = (id: Icons) => { switch (id) { case 'cogs': @@ -33,7 +45,7 @@ const Modal: FC<ModalProps> = ({ children, icon, title }) => { }; return ( - <div className={styles.wrapper}> + <div className={`${styles.wrapper} ${className}`}> {title && ( <Heading isFake={true} level={3}> {icon && <span className={styles.icon}>{getIcon(icon)}</span>} diff --git a/src/components/molecules/modals/tooltip.stories.tsx b/src/components/molecules/modals/tooltip.stories.tsx index a57cf34..63fc71d 100644 --- a/src/components/molecules/modals/tooltip.stories.tsx +++ b/src/components/molecules/modals/tooltip.stories.tsx @@ -5,6 +5,19 @@ export default { title: 'Molecules/Modals', component: TooltipComponent, argTypes: { + className: { + control: { + type: 'text', + }, + description: 'Set additional classnames to the tooltip.', + table: { + category: 'Styles', + }, + type: { + name: 'string', + required: false, + }, + }, content: { control: { type: 'text', @@ -15,6 +28,16 @@ export default { required: true, }, }, + icon: { + control: { + type: 'text', + }, + description: 'The tooltip icon.', + type: { + name: 'string', + required: true, + }, + }, title: { control: { type: 'text', diff --git a/src/components/molecules/modals/tooltip.tsx b/src/components/molecules/modals/tooltip.tsx index ceb0b14..73f36e7 100644 --- a/src/components/molecules/modals/tooltip.tsx +++ b/src/components/molecules/modals/tooltip.tsx @@ -1,12 +1,12 @@ import List, { type ListItem } from '@components/atoms/lists/list'; -import { FC, ReactNode } from 'react'; +import { ReactNode, VFC } from 'react'; import styles from './tooltip.module.scss'; export type TooltipProps = { /** - * Set additional classes to the tooltip wrapper. + * Set additional classnames to the tooltip wrapper. */ - classes?: string; + className?: string; /** * The tooltip body. */ @@ -26,7 +26,12 @@ export type TooltipProps = { * * Render a tooltip modal. */ -const Tooltip: FC<TooltipProps> = ({ classes = '', content, icon, title }) => { +const Tooltip: VFC<TooltipProps> = ({ + className = '', + content, + icon, + title, +}) => { /** * Format an array of strings to an array of object with id and value. * @@ -40,7 +45,7 @@ const Tooltip: FC<TooltipProps> = ({ classes = '', content, icon, title }) => { }; return ( - <div className={`${styles.wrapper} ${classes}`}> + <div className={`${styles.wrapper} ${className}`}> <div className={styles.title}> <span className={styles.icon}>{icon}</span> {title} |
