From b94b9b41f113da17f232a7d1044dedadd87e0c89 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 14 Apr 2022 19:43:35 +0200 Subject: chore: add a SearchModal component --- .../organisms/modals/search-modal.module.scss | 11 +++++++ .../organisms/modals/search-modal.stories.tsx | 16 ++++++++++ .../organisms/modals/search-modal.test.tsx | 9 ++++++ src/components/organisms/modals/search-modal.tsx | 34 ++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 src/components/organisms/modals/search-modal.module.scss create mode 100644 src/components/organisms/modals/search-modal.stories.tsx create mode 100644 src/components/organisms/modals/search-modal.test.tsx create mode 100644 src/components/organisms/modals/search-modal.tsx (limited to 'src') 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; + +const Template: ComponentStory = (args) => ( + + + +); + +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(); + 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 = ({ className }) => { + const intl = useIntl(); + const modalTitle = intl.formatMessage({ + defaultMessage: 'Search', + description: 'SearchModal: modal title', + id: 'G+Twgm', + }); + + return ( + + + + ); +}; + +export default SearchModal; -- cgit v1.2.3