Shell
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
const App = ({ children }) => (
|
||||||
|
<div className="flex h-screen flex-col">
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default App;
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
const Content = ({ className, children }) => (
|
||||||
|
<div
|
||||||
|
className={`${className} flex-1 overflow-auto"`}
|
||||||
|
style={{
|
||||||
|
paddingTop: `calc(env(safe-area-inset-top, 0px) + 16px)`, // Care for the notch
|
||||||
|
}}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export default Content;
|
||||||
+1
-1
@@ -6,7 +6,7 @@ const Nav = ({ page }) => {
|
|||||||
const [showMobileMenu, setShowMobileMenu] = useState(false);
|
const [showMobileMenu, setShowMobileMenu] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className="bg-gray-800 fixed w-full" id="nav">
|
<nav className="bg-gray-800 w-full flex-0 h-auto">
|
||||||
<div className="max-w-7xl mx-auto px-2 sm:px-6 lg:px-8">
|
<div className="max-w-7xl mx-auto px-2 sm:px-6 lg:px-8">
|
||||||
<div className="relative flex items-center justify-between h-16">
|
<div className="relative flex items-center justify-between h-16">
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
const TabBar = ({ children }) => (
|
const TabBar = ({ children }) => (
|
||||||
|
<nav
|
||||||
<nav id="tab-bar" className="h-16 bg-white fixed bottom-0 w-full flex justify-center items-center bg-gray-50">
|
id="tab-bar"
|
||||||
|
className="py-2 h-16 bg-white bottom-0 w-full flex justify-center items-start bg-gray-50"
|
||||||
|
style={{
|
||||||
|
height: `calc(env(safe-area-inset-bottom, 0px) + 56px)`
|
||||||
|
}}>
|
||||||
{children}
|
{children}
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
export default TabBar;
|
export default TabBar;
|
||||||
@@ -1,13 +1,14 @@
|
|||||||
import { homeItems } from "../../data";
|
import { homeItems } from "../../data";
|
||||||
import PostCard from "../Card";
|
import PostCard from "../Card";
|
||||||
|
import Content from "../Content";
|
||||||
|
|
||||||
const Home = () => {
|
const Home = () => {
|
||||||
return (
|
return (
|
||||||
<div class="py-32">
|
<Content>
|
||||||
{homeItems.map(i => (
|
{homeItems.map(i => (
|
||||||
<PostCard {...i} />
|
<PostCard {...i} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</Content>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { homeItems } from "../../data";
|
import { homeItems } from "../../data";
|
||||||
|
import Content from "../Content";
|
||||||
|
|
||||||
const Profile = () => {
|
const Profile = () => {
|
||||||
return (
|
return (
|
||||||
<div class="py-32">
|
<Content>
|
||||||
<h2>Profile</h2>
|
<h2>Profile</h2>
|
||||||
</div>
|
</Content>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
import Content from "../Content";
|
||||||
|
|
||||||
const Settings = () => {
|
const Settings = () => {
|
||||||
return (
|
return (
|
||||||
<div class="py-32">
|
<Content className="p-4">
|
||||||
<h2>Settings</h2>
|
<h2>Settings</h2>
|
||||||
</div>
|
</Content>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
|
||||||
import Card from '../components/Card';
|
import App from '../components/App';
|
||||||
import Nav from '../components/Nav';
|
import Nav from '../components/Nav';
|
||||||
import Home from '../components/pages/Home';
|
import Home from '../components/pages/Home';
|
||||||
import Profile from '../components/pages/Profile';
|
import Profile from '../components/pages/Profile';
|
||||||
@@ -23,7 +23,7 @@ export default function Index() {
|
|||||||
const [page, setPage] = useState(pages[0]);
|
const [page, setPage] = useState(pages[0]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<App>
|
||||||
<Nav page={page} />
|
<Nav page={page} />
|
||||||
<CurrentPage page={page} />
|
<CurrentPage page={page} />
|
||||||
<TabBar>
|
<TabBar>
|
||||||
@@ -31,6 +31,6 @@ export default function Index() {
|
|||||||
<Tab key={p.id} {...p} onClick={() => setPage(p)} selected={p.id === page.id} />
|
<Tab key={p.id} {...p} onClick={() => setPage(p)} selected={p.id === page.id} />
|
||||||
))}
|
))}
|
||||||
</TabBar>
|
</TabBar>
|
||||||
</>
|
</App>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-9
@@ -1,10 +1,3 @@
|
|||||||
:root {
|
body {
|
||||||
/* Safe area contains how much space I should leave from the top and returns 0 if it's not supported */
|
overflow: hidden;
|
||||||
--safe-area-inset-top: env(safe-area-inset-top);
|
|
||||||
/* A replacement for 100vh */
|
|
||||||
--screen-height: calc(100vh - var(--safe-area-inset-top));
|
|
||||||
}
|
|
||||||
|
|
||||||
#nav {
|
|
||||||
padding-top: var(--safe-area-inset-top);
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user