Skip to content

Commit

Permalink
♻️ refactor: main layout
Browse files Browse the repository at this point in the history
  • Loading branch information
andrehadianto committed Jul 29, 2024
1 parent 00b324d commit 8989387
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 115 deletions.
5 changes: 5 additions & 0 deletions common/components/CoreLayout/CoreLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { PropsWithChildren } from "react";

export const CoreLayout = ({ children }: PropsWithChildren) => {
return <div className="h-screen-safe relative">{children}</div>;
};
1 change: 1 addition & 0 deletions common/components/CoreLayout/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./CoreLayout";
1 change: 1 addition & 0 deletions common/fonts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './inter';
6 changes: 6 additions & 0 deletions common/fonts/inter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Inter } from "next/font/google";

export const inter = Inter({
subsets: ["latin"],
variable: "--font-inter",
});
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
"prettier": "prettier --write 'src/**/*.{js,jsx,ts,tsx,scss}'"
},
"dependencies": {
"clsx": "^2.1.1",
"next": "14.2.5",
"react": "^18",
"react-dom": "^18",
"sass": "^1.77.8"
"sass": "^1.77.8",
"tailwind-merge": "^2.4.0",
"tailwind-variants": "^0.2.1"
},
"devDependencies": {
"@types/node": "^20",
Expand Down
24 changes: 22 additions & 2 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
import "@/styles/globals.scss";
import { CoreLayout } from "@/common/components/CoreLayout";
import { inter } from "@/common/fonts";

import type { AppProps } from "next/app";

import "@/styles/globals.scss";

export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />;
const Layout = (Component as any).layout
? (Component as any).layout
: CoreLayout;

return (
<>
{/* This is required for fonts to work in Portal too */}
<style global jsx>{`
:root {
--font-inter: ${inter.style.fontFamily};
}
`}</style>
<Layout>
<Component {...pageProps} />
</Layout>
</>
);
}
Loading

0 comments on commit 8989387

Please sign in to comment.