diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-04-14 19:43:35 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-04-14 19:43:35 +0200 |
| commit | b94b9b41f113da17f232a7d1044dedadd87e0c89 (patch) | |
| tree | 3b589c7b3b18e9cf6c9d62339f647aad33609ba5 /src/components/organisms/modals | |
| parent | 70b4e5c311999501cd6eff632ddbcac6e75ff035 (diff) | |
chore: add a SearchModal component
Diffstat (limited to 'src/components/organisms/modals')
4 files changed, 70 insertions, 0 deletions
diff --git a/src/components/organisms/modals/search-modal.module.scss b/src/components/organisms/modals/search-modal.module.scss new file mode 100644 index 0000000..aba0593 --- /dev/null +++ b/src/components/organisms/modals/search-modal.module.scss @@ -0,0 +1,11 @@ +@use "@styles/abstracts/mixins" as mix; + +.wrapper { + padding-bottom: var(--spacing-md); + + @include mix.media("screen") { + @include mix.dimensions("sm") { + max-width: 40ch; + } + } +} diff --git a/src/components/organisms/modals/search-modal.stories.tsx b/src/components/organisms/modals/search-modal.stories.tsx new file mode 100644 index 0000000..b35c841 --- /dev/null +++ b/src/components/organisms/modals/search-modal.stories.tsx @@ -0,0 +1,16 @@ +import { ComponentMeta, ComponentStory } from '@storybook/react'; +import { IntlProvider } from 'react-intl'; +import SearchModalComponent from './search-modal'; + +export default { + title: 'Organisms/Modals', + component: SearchModalComponent, +} as ComponentMeta<typeof SearchModalComponent>; + +const Template: ComponentStory<typeof SearchModalComponent> = (args) => ( + <IntlProvider locale="en"> + <SearchModalComponent {...args} /> + </IntlProvider> +); + +export const SearchModal = Template.bind({}); diff --git a/src/components/organisms/modals/search-modal.test.tsx b/src/components/organisms/modals/search-modal.test.tsx new file mode 100644 index 0000000..249c523 --- /dev/null +++ b/src/components/organisms/modals/search-modal.test.tsx @@ -0,0 +1,9 @@ +import { render, screen } from '@test-utils'; +import SearchModal from './search-modal'; + +describe('SearchModal', () => { + it('renders a search modal', () => { + render(<SearchModal />); + expect(screen.getByText('Search')).toBeInTheDocument(); + }); +}); diff --git a/src/components/organisms/modals/search-modal.tsx b/src/components/organisms/modals/search-modal.tsx new file mode 100644 index 0000000..883b783 --- /dev/null +++ b/src/components/organisms/modals/search-modal.tsx @@ -0,0 +1,34 @@ +import Modal from '@components/molecules/modals/modal'; +import { VFC } from 'react'; +import { useIntl } from 'react-intl'; +import SearchForm from '../forms/search-form'; +import styles from './search-modal.module.scss'; + +export type SearchModalProps = { + /** + * Set additional classnames to modal wrapper. + */ + className?: string; +}; + +/** + * SearchModal + * + * Render a search form modal. + */ +const SearchModal: VFC<SearchModalProps> = ({ className }) => { + const intl = useIntl(); + const modalTitle = intl.formatMessage({ + defaultMessage: 'Search', + description: 'SearchModal: modal title', + id: 'G+Twgm', + }); + + return ( + <Modal title={modalTitle} className={`${styles.wrapper} ${className}`}> + <SearchForm hideLabel={true} /> + </Modal> + ); +}; + +export default SearchModal; |
