diff --git a/src/components/app/app.js b/src/components/app/app.js index de0eb10..9ed9efe 100644 --- a/src/components/app/app.js +++ b/src/components/app/app.js @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react'; import Restaurants from '../restaurants'; import Header from '../header'; +import Basket from '../basket'; export default class App extends PureComponent { render() { diff --git a/src/components/basket/icons/minus.svg b/src/components/basket/icons/minus.svg new file mode 100644 index 0000000..d038dac --- /dev/null +++ b/src/components/basket/icons/minus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/components/basket/icons/plus.svg b/src/components/basket/icons/plus.svg new file mode 100644 index 0000000..36b641f --- /dev/null +++ b/src/components/basket/icons/plus.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/hocs/popup.js b/src/hocs/popup.js new file mode 100644 index 0000000..6c32655 --- /dev/null +++ b/src/hocs/popup.js @@ -0,0 +1,7 @@ +import React from 'react'; +import usePopup from '../hooks/use-popup'; + +export default (WrappedComponent) => ({ initialState, ...props }) => { + const popupProps = usePopup(initialState); + return ; +}; diff --git a/src/hooks/use-popup.js b/src/hooks/use-popup.js new file mode 100644 index 0000000..0e6c01c --- /dev/null +++ b/src/hooks/use-popup.js @@ -0,0 +1,9 @@ +import { useState } from 'react'; + +export default function usePopup(initialState = false) { + const [isOpenBasket, toggleBasket] = useState(initialState); + const hideBasket = () => toggleBasket(false); + const openBasket = () => toggleBasket(true); + + return { isOpenBasket, hideBasket, openBasket }; +}