diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-02 08:59:06 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-03-02 08:59:06 +0700 |
| commit | b7979c2c0c5443b4f7e1d970ab0422c19f49d4ad (patch) | |
| tree | bd4b2ca869c78a9644755862268f9f9625e671fc /src/core | |
| parent | b24897aa630312959acb36be4465eaf99d09e550 (diff) | |
Add mobile view and desktop view component
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/components/views/DesktopView.jsx | 14 | ||||
| -rw-r--r-- | src/core/components/views/MobileView.jsx | 14 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/core/components/views/DesktopView.jsx b/src/core/components/views/DesktopView.jsx new file mode 100644 index 00000000..31a67936 --- /dev/null +++ b/src/core/components/views/DesktopView.jsx @@ -0,0 +1,14 @@ +import isMobile from 'is-mobile' +import { useEffect, useState } from 'react' + +const DesktopView = ({ children }) => { + const [view, setView] = useState(<></>) + + useEffect(() => { + if (!isMobile()) setView(children) + }, [children]) + + return view +} + +export default DesktopView diff --git a/src/core/components/views/MobileView.jsx b/src/core/components/views/MobileView.jsx new file mode 100644 index 00000000..be8aa293 --- /dev/null +++ b/src/core/components/views/MobileView.jsx @@ -0,0 +1,14 @@ +import isMobile from 'is-mobile' +import { useEffect, useState } from 'react' + +const MobileView = ({ children }) => { + const [view, setView] = useState(<></>) + + useEffect(() => { + if (isMobile()) setView(children) + }, [children]) + + return view +} + +export default MobileView |
