This commit is contained in:
Max Lynch
2020-12-20 23:02:27 -06:00
parent fdef2842ef
commit 8b2df11c87
9 changed files with 41 additions and 23 deletions
+7
View File
@@ -0,0 +1,7 @@
const App = ({ children }) => (
<div className="flex h-screen flex-col">
{children}
</div>
);
export default App;
+11
View File
@@ -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
View File
@@ -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
+6 -3
View File
@@ -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;
+3 -2
View File
@@ -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>
) )
} }
+3 -2
View File
@@ -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>
) )
} }
+4 -2
View File
@@ -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
View File
@@ -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
View File
@@ -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);
} }