diff --git a/docs/adding_new_components.md b/docs/adding_new_components.md index 130d106b10..cd4f490fc2 100644 --- a/docs/adding_new_components.md +++ b/docs/adding_new_components.md @@ -68,7 +68,7 @@ There is a significant difference between thinking about the component props in ### Common Components in `react-uswds` - Components that apply uswds styles to a standard HTMLElement - `Button`, `Table` -- Components that encapsulate user interaction flows - `Accordion`, `Modal` +- Components that encapsulate user interaction flows - `Accordion` - Components for a common gov tech use case - `Search`, `SocialLinks` - Components that render children - `Card`, `Header`, `Footer` - Components related to forms, especially form inputs - `DateInput`, `TextInput` `Checkbox`, `Label` diff --git a/example/package.json b/example/package.json index 07dbd1f93f..cc2dae13a0 100644 --- a/example/package.json +++ b/example/package.json @@ -10,9 +10,7 @@ "formik": "^2.2.6", "react": "^17.0.2", "react-dom": "^17.0.2", - "react-redux": "^7.2.4", "react-router-dom": "^5.2.0", - "redux": "^4.0.5", "yup": "^0.32.9" }, "scripts": { @@ -43,7 +41,6 @@ "@types/node": "^14.14.31", "@types/react": "^17.0.4", "@types/react-dom": "^17.0.3", - "@types/react-redux": "^7.1.16", "@types/react-router-dom": "^5.1.7", "@types/yup": "^0.29.11", "customize-cra": "^1.0.0", diff --git a/example/src/App.test.tsx b/example/src/App.test.tsx index 7877c9a9d7..e2b3e8a017 100644 --- a/example/src/App.test.tsx +++ b/example/src/App.test.tsx @@ -5,5 +5,5 @@ import App from './App'; // TODO Add additional app testing test('renders the app without error', () => { const { getByText } = render() - expect(getByText('Modals')).toBeInTheDocument() + expect(getByText('Examples')).toBeInTheDocument() }) diff --git a/example/src/App.tsx b/example/src/App.tsx index 071559aa87..c4402f5144 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -20,7 +20,6 @@ import { import HomePage from './pages/Home' import ExamplePage from './pages/Example' -import ModalsPage from './pages/Modals' import FormsPage from './pages/Forms' import IconsPage from './pages/Icons' import { Routes } from './routes' @@ -29,7 +28,7 @@ import './App.css' const App = () => { const [mobileNavOpen, setMobileNavOpen] = useState(false) - const { HOME_PAGE, EXAMPLES_PAGE, MODALS_PAGE, FORMS_PAGE, ICONS_PAGE } = Routes + const { HOME_PAGE, EXAMPLES_PAGE, FORMS_PAGE, ICONS_PAGE } = Routes const toggleMobileNav = (): void => { setMobileNavOpen((prevOpen) => !prevOpen) @@ -42,9 +41,6 @@ const App = () => { Examples , - - Modals - , Icons , @@ -81,9 +77,6 @@ const App = () => { - - - diff --git a/example/src/index.tsx b/example/src/index.tsx index 88f21ba999..ef8ef4099b 100644 --- a/example/src/index.tsx +++ b/example/src/index.tsx @@ -3,19 +3,11 @@ import ReactDOM from 'react-dom' import './index.css' import App from './App' import * as serviceWorker from './serviceWorker' -import { createStore } from 'redux' -import { Provider } from 'react-redux' - -import { rootReducer } from './redux/reducers' - -const store = createStore(rootReducer) ReactDOM.render( - - - , + , document.getElementById('root') ) diff --git a/example/src/pages/Example.tsx b/example/src/pages/Example.tsx index 95bed21871..d049b2822f 100644 --- a/example/src/pages/Example.tsx +++ b/example/src/pages/Example.tsx @@ -20,11 +20,11 @@ const ExamplePage = (): React.ReactElement => (
  • - Modals + Icons
  • diff --git a/example/src/pages/Modals.tsx b/example/src/pages/Modals.tsx deleted file mode 100644 index 6a33f3823d..0000000000 --- a/example/src/pages/Modals.tsx +++ /dev/null @@ -1,98 +0,0 @@ -import React from 'react' -import { - Modal, - Button, - connectModal, - ConnectedModalProps, - useModal -} from '@trussworks/react-uswds' -import { connect, ConnectedProps } from 'react-redux' - -import { openModalAction, closeModalAction } from './../redux/actions' -import { AppState, ModalState } from './../redux/types' - - -interface TestModalProps extends ConnectedModalProps { - modalKey?: string - children: React.ReactNode -} - -const TestModal = ({ onClose, children }: TestModalProps): React.ReactElement => ( - Test Modal} - actions={ - <> - - - - }> - { children } - -) - -/** Example of Modal Component Using Redux */ -const ConnectedTestModal = connectModal(TestModal) - -const mapStateToProps = (state: AppState): ModalState => ({ - openModalKey: state.modalState.openModalKey, -}) - -const mapDispatchToProps = { - openModalAction: openModalAction, - closeModalAction: closeModalAction, -} - -const connector = connect(mapStateToProps, mapDispatchToProps) -/** End of Example of Modal Component Using Redux */ - -const ExamplePage = ({ - openModalKey, - openModalAction, - closeModalAction, -}: ConnectedProps): React.ReactElement => { - - /** Example of Modal Component Using Hooks */ - const { isOpen, openModal, closeModal } = useModal() - /** End of Example of Modal Component Using Hooks */ - - return ( -
    -

    Modals

    - -

    - This page provides examples of how modals may be used within an - application. -

    - -
    - - {/* Example of modal using redux for state management */} - closeModalAction('testModal')}> -

    This is a modal that uses redux!

    -
    -
    -
    - - {/* Example of modal using hooks for state management */} - -

    This is a modal that uses hooks!

    -
    -
    -
    - ) -} - -const ConnectedExamplePage = connector(ExamplePage) - -export default ConnectedExamplePage diff --git a/example/src/redux/actions.test.ts b/example/src/redux/actions.test.ts deleted file mode 100644 index 3f86f57364..0000000000 --- a/example/src/redux/actions.test.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { - CLOSE_MODAL, - OPEN_MODAL, -} from './types' -import { - closeModalAction, - openModalAction, -} from './actions' - -describe('Modal actions', () => { - describe('closeModal Action', () => { - it('returns the CLOSE_MODAL action type', () => { - const expectedAction = { - type: CLOSE_MODAL, - payload: 'testkey' - } - expect(closeModalAction('testkey')).toEqual(expectedAction) - }) - }) - - describe('openModal Action', () => { - it('returns the OPEN_MODAL action type', () => { - const expectedAction = { - type: OPEN_MODAL, - payload: 'testkey' - } - expect(openModalAction('testkey')).toEqual(expectedAction) - }) - }) -}) diff --git a/example/src/redux/actions.tsx b/example/src/redux/actions.tsx deleted file mode 100644 index d6861b0919..0000000000 --- a/example/src/redux/actions.tsx +++ /dev/null @@ -1,16 +0,0 @@ - -import { OPEN_MODAL, CLOSE_MODAL } from "./types"; - -export function openModalAction( modalKey: string) { - return { - type: OPEN_MODAL, - payload: modalKey - }; -} - -export function closeModalAction(modalKey: string) { - return { - type: CLOSE_MODAL, - payload: modalKey - }; -} diff --git a/example/src/redux/reducer.test.ts b/example/src/redux/reducer.test.ts deleted file mode 100644 index 013a4f009f..0000000000 --- a/example/src/redux/reducer.test.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { initialState, rootReducer } from './reducers' -import { OpenModalAction, CloseModalAction, AppState } from './types' - -describe('rootReducer', () => { - it('should set the openModalKey state', () => { - const openModalAction: OpenModalAction = { - type: 'OPEN_MODAL', - payload: 'testModal', - } - - const expectedState : AppState = { - modalState : { - openModalKey: 'testModal' - } - } - - expect(rootReducer(initialState, openModalAction)).toEqual(expectedState) - }) - - it('should set the openModalKey state', () => { - const closeModalAction: CloseModalAction = { - type: 'CLOSE_MODAL', - payload: 'testModal', - } - - const expectedState : AppState = { - modalState : { - openModalKey: '' - } - } - - expect(rootReducer(initialState, closeModalAction)).toEqual(expectedState) - }) -}) diff --git a/example/src/redux/reducers.ts b/example/src/redux/reducers.ts deleted file mode 100644 index 44cb238879..0000000000 --- a/example/src/redux/reducers.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { - OPEN_MODAL, - CLOSE_MODAL, - ModalActionTypes, - AppState -} from "./types"; - -export const initialState: AppState = { - modalState : { - openModalKey: '' - } -}; - -export function rootReducer ( - state = initialState, - action: ModalActionTypes -): AppState { - switch (action.type) { - case OPEN_MODAL: - return { - ...state, - modalState: { - openModalKey: action.payload - } - } - case CLOSE_MODAL: - return { - ...state, - modalState: { - openModalKey: '' - } - } - default: - return state - } -} \ No newline at end of file diff --git a/example/src/redux/types.ts b/example/src/redux/types.ts deleted file mode 100644 index bd67c164d5..0000000000 --- a/example/src/redux/types.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** Modal Types */ -export interface ModalState { - // string is the key of the open modal. This only allows a single modal to be open in the app at any time. - openModalKey: string -} - -export const OPEN_MODAL = "OPEN_MODAL"; -export const CLOSE_MODAL = "CLOSE_MODAL"; - -export interface OpenModalAction { - type: typeof OPEN_MODAL; - payload: string; -} - -export interface CloseModalAction { - type: typeof CLOSE_MODAL; - payload: string; -} - -export type ModalActionTypes = OpenModalAction | CloseModalAction; - -export interface AppState { - modalState: ModalState -} \ No newline at end of file diff --git a/example/src/routes.js b/example/src/routes.js index 235be0862e..892ba5f002 100644 --- a/example/src/routes.js +++ b/example/src/routes.js @@ -2,7 +2,6 @@ const Routes = { HOME_PAGE: '/', EXAMPLES_PAGE: '/examples', FORMS_PAGE: '/forms', - MODALS_PAGE: '/modals', ICONS_PAGE: '/icons', } diff --git a/example/yarn.lock b/example/yarn.lock index df01392694..77298c9de6 100644 --- a/example/yarn.lock +++ b/example/yarn.lock @@ -2449,7 +2449,7 @@ "@babel/runtime" "^7.12.5" "@trussworks/react-uswds@file:./..": - version "1.16.0" + version "1.17.0" "@types/anymatch@*": version "1.3.1" @@ -2539,14 +2539,6 @@ resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.6.tgz#ed8fc802c45b8e8f54419c2d054e55c9ea344356" integrity sha512-GRTZLeLJ8ia00ZH8mxMO8t0aC9M1N9bN461Z2eaRurJo6Fpa+utgCwLzI4jQHcrdzuzp5WPN9jRwpsCQ1VhJ5w== -"@types/hoist-non-react-statics@^3.3.0": - version "3.3.1" - resolved "https://registry.yarnpkg.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz#1124aafe5118cb591977aeb1ceaaed1070eb039f" - integrity sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA== - dependencies: - "@types/react" "*" - hoist-non-react-statics "^3.3.0" - "@types/html-minifier-terser@^5.0.0": version "5.1.1" resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz#3c9ee980f1a10d6021ae6632ca3e79ca2ec4fb50" @@ -2646,16 +2638,6 @@ dependencies: "@types/react" "*" -"@types/react-redux@^7.1.16": - version "7.1.16" - resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-7.1.16.tgz#0fbd04c2500c12105494c83d4a3e45c084e3cb21" - integrity sha512-f/FKzIrZwZk7YEO9E1yoxIuDNRiDducxkFlkw/GNMGEnK9n4K8wJzlJBghpSuOVDgEUHoDkDF7Gi9lHNQR4siw== - dependencies: - "@types/hoist-non-react-statics" "^3.3.0" - "@types/react" "*" - hoist-non-react-statics "^3.3.0" - redux "^4.0.0" - "@types/react-router-dom@^5.1.7": version "5.1.7" resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.1.7.tgz#a126d9ea76079ffbbdb0d9225073eb5797ab7271" @@ -6415,7 +6397,7 @@ hmac-drbg@^1.0.1: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2: +hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== @@ -10038,7 +10020,7 @@ react-fast-compare@^2.0.1: resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-2.0.4.tgz#e84b4d455b0fec113e0402c329352715196f81f9" integrity sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw== -react-is@^16.13.1, react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1: +react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== @@ -10048,18 +10030,6 @@ react-is@^17.0.1: resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.1.tgz#5b3531bd76a645a4c9fb6e693ed36419e3301339" integrity sha512-NAnt2iGDXohE5LI7uBnLnqvLQMtzhkiAOLXTmv+qnF9Ky7xAPcX8Up/xWIhxvLVGJvuLiNc4xQLtuqDRzb4fSA== -react-redux@^7.2.4: - version "7.2.4" - resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-7.2.4.tgz#1ebb474032b72d806de2e0519cd07761e222e225" - integrity sha512-hOQ5eOSkEJEXdpIKbnRyl04LhaWabkDPV+Ix97wqQX3T3d2NQ8DUblNXXtNMavc7DpswyQM6xfaN4HQDKNY2JA== - dependencies: - "@babel/runtime" "^7.12.1" - "@types/react-redux" "^7.1.16" - hoist-non-react-statics "^3.3.2" - loose-envify "^1.4.0" - prop-types "^15.7.2" - react-is "^16.13.1" - react-refresh@^0.8.3: version "0.8.3" resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.8.3.tgz#721d4657672d400c5e3c75d063c4a85fb2d5d68f" @@ -10257,14 +10227,6 @@ redent@^3.0.0: indent-string "^4.0.0" strip-indent "^3.0.0" -redux@^4.0.0, redux@^4.0.5: - version "4.0.5" - resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.5.tgz#4db5de5816e17891de8a80c424232d06f051d93f" - integrity sha512-VSz1uMAH24DM6MF72vcojpYPtrTUu3ByVWfPL1nPfVRb5mZVTve5GnNCUV53QM/BZ66xfWrm0CTWoM+Xlz8V1w== - dependencies: - loose-envify "^1.4.0" - symbol-observable "^1.2.0" - regenerate-unicode-properties@^8.2.0: version "8.2.0" resolved "https://registry.yarnpkg.com/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz#e5de7111d655e7ba60c057dbe9ff37c87e65cdec" @@ -11428,11 +11390,6 @@ svgo@^1.0.0, svgo@^1.2.2: unquote "~1.1.1" util.promisify "~1.0.0" -symbol-observable@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" - integrity sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ== - symbol-tree@^3.2.4: version "3.2.4" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.4.tgz#430637d248ba77e078883951fb9aa0eed7c63fa2" diff --git a/src/components/Modal/Modal.module.scss b/src/components/Modal/Modal.module.scss deleted file mode 100644 index 057802de11..0000000000 --- a/src/components/Modal/Modal.module.scss +++ /dev/null @@ -1,53 +0,0 @@ -.title { - h2 { - margin: 0; - } -} - -.actions { - text-align: right; -} - -.title + .content, -.content + .actions { - @include u-border-top(1px); - @include u-border-top($theme-color-base-lighter); -} - -.modal { - @include u-bg('white'); - @include u-shadow(3); - @include u-radius('sm'); - - // TODO - adapt these for different screen sizes/modal sizes? - max-width: 630px; - min-width: 400px; - - .title, - .content, - .actions { - padding: units(2); - } -} - -.overlay { - background-color: rgba(0, 0, 0, 0.3); - height: 100vh; - left: 0; - position: fixed; - top: 0; - width: 100vw; - z-index: 999; -} - -.modalContainer { - align-items: center; - display: flex; - height: 100vh; - justify-content: center; - left: 0; - position: fixed; - top: 0; - width: 100vw; - z-index: 1000; -} diff --git a/src/components/Modal/Modal.stories.tsx b/src/components/Modal/Modal.stories.tsx deleted file mode 100644 index d5cf51439c..0000000000 --- a/src/components/Modal/Modal.stories.tsx +++ /dev/null @@ -1,154 +0,0 @@ -import React from 'react' - -import { Button } from '../Button/Button' - -import { Modal, Overlay, ModalContainer, connectModal, useModal } from './Modal' - -export default { - title: 'Other/Modal', - component: Modal, - parameters: { - docs: { - description: { - component: ` -Truss-designed component - -**Note:** This component has been deprecated and is scheduled for removal. -`, - }, - }, - }, -} - -const testTitle =

    My Modal

    - -const testActions = ( - <> - - - -) - -export const basic = (): React.ReactElement => ( -
    - -

    This is a basic modal!

    -
    -
    -) - -export const withTitle = (): React.ReactElement => ( -
    - -

    This is a basic modal!

    -
    -
    -) - -export const withActions = (): React.ReactElement => ( -
    - -

    This is a basic modal!

    -
    -
    -) - -export const withTitleAndActions = (): React.ReactElement => ( -
    - -

    This is a basic modal!

    -
    -
    -) - -export const closeCaseModal = (): React.ReactElement => ( -
    - Close case?} - actions={ - <> - - - - }> -

    - This will close your investigative work for{' '} - Case #590381450 and forward the case to adjudication. -

    -
    -
    -) - -export const withOverlay = (): React.ReactElement => ( -
    - - - Close case?} - actions={ - <> - - - - }> -

    - This will close your investigative work for{' '} - Case #590381450 and forward the case to adjudication. -

    -
    -
    -
    -) - -export const fullExample = (): React.ReactElement => { - const { isOpen, openModal, closeModal } = useModal() - - const TestModal = (): React.ReactElement => ( - Test Modal} - actions={ - <> - - - - }> -

    This is a test modal!

    -
    - ) - - const ConnectedTestModal = connectModal(TestModal) - - return ( -
    - - -
    - ) -} diff --git a/src/components/Modal/Modal.test.tsx b/src/components/Modal/Modal.test.tsx deleted file mode 100644 index 11cb35d9ec..0000000000 --- a/src/components/Modal/Modal.test.tsx +++ /dev/null @@ -1,74 +0,0 @@ -import React from 'react' -import { render } from '@testing-library/react' -import { renderHook, act } from '@testing-library/react-hooks' - -jest.mock('../../deprecation') -import { deprecationWarning } from '../../deprecation' -import { Modal, connectModal, useModal } from './Modal' - -describe('Modal component', () => { - it('renders without errors', () => { - const { queryByTestId } = render(My Modal) - expect(queryByTestId('modal')).toBeInTheDocument() - expect(deprecationWarning).toHaveBeenCalledTimes(1) - }) -}) - -const TestModal = (): React.ReactElement =>
    My Modal
    - -describe('connectModal', () => { - beforeEach(() => { - jest.clearAllMocks() - }) - const mockClose = jest.fn() - - describe('if isOpen is false', () => { - it('does not render its children', () => { - const TestConnectedModal = connectModal(TestModal) - const { queryByText } = render( - - ) - expect(queryByText('My Modal')).not.toBeInTheDocument() - expect(deprecationWarning).toHaveBeenCalledTimes(1) - }) - }) - - describe('if isOpen is true', () => { - it('renders its children', () => { - const TestConnectedModal = connectModal(TestModal) - const { queryByText } = render( - - ) - expect(queryByText('My Modal')).toBeInTheDocument() - expect(deprecationWarning).toHaveBeenCalledTimes(2) - }) - }) -}) - -describe('useModal', () => { - beforeEach(() => { - jest.clearAllMocks() - }) - - it('provides state and functions for opening/closing a modal', () => { - const { result } = renderHook(() => useModal()) - expect(deprecationWarning).toHaveBeenCalledTimes(1) - expect(result.current.isOpen).toEqual(false) - expect(typeof result.current.openModal).toBe('function') - expect(typeof result.current.closeModal).toBe('function') - - act(() => { - result.current.openModal() - }) - - expect(result.current.isOpen).toEqual(true) - expect(deprecationWarning).toHaveBeenCalledTimes(2) - - act(() => { - result.current.closeModal() - }) - - expect(result.current.isOpen).toEqual(false) - expect(deprecationWarning).toHaveBeenCalledTimes(3) - }) -}) diff --git a/src/components/Modal/Modal.tsx b/src/components/Modal/Modal.tsx deleted file mode 100644 index 751a085edb..0000000000 --- a/src/components/Modal/Modal.tsx +++ /dev/null @@ -1,106 +0,0 @@ -import React, { useState } from 'react' -import classnames from 'classnames' - -import styles from './Modal.module.scss' -import { deprecationWarning } from '../../deprecation' - -type ModalProps = { - title?: React.ReactNode - children: React.ReactNode - actions?: React.ReactNode - className?: string -} - -/** Modal UI component */ -export const Modal = ({ - title, - children, - actions, - className, -}: ModalProps): React.ReactElement => { - const classes = classnames(styles.modal, className) - - deprecationWarning( - 'Modal is deprecated. Modal will be removed from react-uswds alongside all other Modal related components and functions in the next major release.' - ) - - return ( -
    -
    {title}
    -
    {children}
    -
    {actions}
    -
    - ) -} - -/** Overlay UI component (grey background) */ -export const Overlay = (): React.ReactElement => ( -
    -) - -/** Modal positioning component */ -export const ModalContainer = ({ - children, -}: { - children: React.ReactNode -}): React.ReactElement => { - deprecationWarning( - 'Modal is deprecated. ModalContainer will be removed from react-uswds alongside all other Modal related components and functions in the next major release.' - ) - - return
    {children}
    -} - -/** connectModal and useModal package the logic & state of opening/closing a modal */ -export interface ConnectedModalProps { - isOpen: boolean - onClose: () => void -} - -export const connectModal = function

    ( - Component: React.FunctionComponent

    | React.ComponentType

    -): React.FunctionComponent

    { - const ConnectedModal = ({ - isOpen, - ...props - }: P): React.ReactElement | null => { - deprecationWarning( - "Modal is deprecated. 'connectModal' will be removed from react-uswds alongside all other Modal related components and functions in the next major release." - ) - - if (!isOpen) return null - return ( - <> - - - - - - ) - } - - return ConnectedModal -} - -export type ModalHook = { - isOpen: boolean - openModal: () => void - closeModal: () => void -} - -export const useModal = (): ModalHook => { - deprecationWarning( - 'Modal is deprecated. The useModal hook will be removed from react-uswds alongside all other Modal related components and functions in the next major release.' - ) - - const [isOpen, setIsOpen] = useState(false) - - const openModal = (): void => { - setIsOpen(true) - } - const closeModal = (): void => { - setIsOpen(false) - } - - return { isOpen, openModal, closeModal } -} diff --git a/src/index.ts b/src/index.ts index d2bb8e85b7..7a79e04d6d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -109,15 +109,3 @@ export { ProcessListItem } from './components/ProcessList/ProcessListItem/Proces export { ProcessListHeading } from './components/ProcessList/ProcessListHeading/ProcessListHeading' export { SiteAlert } from './components/SiteAlert/SiteAlert' - -/** Truss-designed components */ -export { - Modal, - Overlay, - ModalContainer, - connectModal, - useModal, -} from './components/Modal/Modal' - -// Types and interfaces should be exported separately -export type { ConnectedModalProps, ModalHook } from './components/Modal/Modal'