-
-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(organizations): add theming/story for Mantine Modal TASK-1423 (#…
…5432) ### 📣 Summary Theming for Mantine's Modal was added to match Kobo's current KoboModal used for general purpose. ### 📖 Description * Co-authored by @duvld - We don't have a direct reference of an existing Kobo component, so we've came up a middle ground between the existing modals using though the application. - We have added a Story with a big set of configurations to showcase the possibilities of the Modal - The story also displays a way of - We added a theme and style to the Modal component - Title is using the default heading weight ### 👀 Preview steps - Use storybook to check the visual of the component.
- Loading branch information
1 parent
2091624
commit 45e01f4
Showing
5 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import type {ModalProps} from '@mantine/core'; | ||
import {Button, Center, Modal, Stack, Text, Group} from '@mantine/core'; | ||
import type {Meta, StoryObj} from '@storybook/react'; | ||
import {useArgs} from '@storybook/preview-api'; | ||
|
||
const RenderModal = ({...args}: ModalProps) => { | ||
const [{opened}, updateArgs] = useArgs(); | ||
|
||
return ( | ||
<Center w={400} h={80}> | ||
<Button onClick={() => updateArgs({opened: !opened})}>Open modal</Button> | ||
<Modal {...args} onClose={() => updateArgs({opened: !opened})}> | ||
<Stack> | ||
<Text p='md'> | ||
Example modal content. Press esc, click outside or close button to | ||
close. | ||
</Text> | ||
<Group justify='flex-end'> | ||
<Button variant='danger'>Won't close</Button> | ||
<Button onClick={() => updateArgs({opened: false})}>Close</Button> | ||
</Group> | ||
</Stack> | ||
</Modal> | ||
</Center> | ||
); | ||
}; | ||
|
||
/** | ||
* Mantine [Modal](https://mantine.dev/core/modal/) component stories. | ||
*/ | ||
const meta: Meta<typeof Modal> = { | ||
title: 'Common/Modal', | ||
component: Modal, | ||
render: RenderModal, | ||
argTypes: { | ||
opened: { | ||
description: 'Modal opened state', | ||
type: 'boolean', | ||
}, | ||
size: { | ||
description: 'Modal size - influences the width of the modal, height depends on the content', | ||
type: 'string', | ||
control: { | ||
type: 'select', | ||
}, | ||
options: ['auto', 'xs', 'sm', 'md', 'lg', 'xl', '50%', '75%', '100%'], | ||
}, | ||
fullScreen: { | ||
description: 'Modal fullscreen state', | ||
type: 'boolean', | ||
}, | ||
centered: { | ||
description: 'Center modal vertically on the viewport', | ||
type: 'boolean', | ||
}, | ||
withCloseButton: { | ||
description: 'Render close button', | ||
type: 'boolean', | ||
}, | ||
title: { | ||
description: 'Modal title', | ||
type: 'string', | ||
}, | ||
}, | ||
args: { | ||
opened: false, | ||
closeOnClickOutside: true, | ||
withCloseButton: true, | ||
title: 'Modal title', | ||
centered: false, | ||
size: 'md', | ||
fullScreen: false, | ||
}, | ||
}; | ||
|
||
type Story = StoryObj<typeof Modal>; | ||
|
||
export const Basic: Story = { | ||
args: {}, | ||
}; | ||
|
||
export default meta; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.close { | ||
color: var(--mantine-color-gray-4); | ||
background-color: transparent; | ||
|
||
&:hover { | ||
color: var(--mantine-color-gray-2); | ||
background-color: transparent; | ||
} | ||
} | ||
|
||
.title { | ||
font-size: var(--mantine-font-size-xl); | ||
font-weight: var(--mantine-heading-font-weight); | ||
color: var(--mantine-color-gray-0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import {Modal} from '@mantine/core'; | ||
import Icon from 'jsapp/js/components/common/icon'; | ||
import classes from './Modal.module.css'; | ||
|
||
export const ModalThemeKobo = Modal.extend({ | ||
defaultProps: { | ||
closeButtonProps: { | ||
icon: <Icon name='close' />, | ||
}, | ||
overlayProps: { | ||
backgroundOpacity: 0.5, | ||
color: 'var(--mantine-color-blue-9)', | ||
zIndex: 3000, | ||
}, | ||
zIndex: 4000, | ||
}, | ||
classNames: classes, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters