Skip to content

Commit

Permalink
Merge pull request #22 from BirthdayyBot/feat/use-nextjs-font
Browse files Browse the repository at this point in the history
feat: ✨ Implement `next/font` for using fonts
  • Loading branch information
nikolaischunk authored Sep 25, 2023
2 parents e607dbf + 10d08c9 commit 3de13f5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Navbar from '@components/navbar';
import AuthProvider from '@lib/provider/auth';
import JotaiProvider from '@lib/provider/jotai';
import '@styles/globals.css';
import { hindVadodaraFont, ralewayFont, rubikFont } from '@styles/theme/fonts';
import type { Metadata } from 'next';

export const metadata: Metadata = {
Expand All @@ -13,7 +14,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
return (
<JotaiProvider>
<AuthProvider>
<html lang="en" data-theme="birthdayy">
<html lang="en" data-theme="birthdayy" className={`${hindVadodaraFont.variable} ${rubikFont.variable} ${ralewayFont.variable}`}>
<body>
<Navbar />
<div className="main container mx-auto">{children}</div>
Expand Down
8 changes: 3 additions & 5 deletions src/styles/theme/_fonts.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
@import url('https://fonts.googleapis.com/css2?family=Hind+Vadodara&family=Raleway:wght@400;800&family=Rubik:wght@500;800&display=swap');

$header-font: 'Rubik', sans-serif;
$sub-header-font: 'Raleway', sans-serif;
$body-font: 'Hind Vadodara', sans-serif;
$header-font: 'var(--font-rubik)', sans-serif;
$sub-header-font: 'var(--font-raleway)', sans-serif;
$body-font: 'var(--font-hind-vadodara)', sans-serif;

$family-primary: $body-font;
$family-secondary: $header-font;
Expand Down
22 changes: 22 additions & 0 deletions src/styles/theme/fonts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Define your fonts
import { Hind_Vadodara, Raleway, Rubik } from 'next/font/google';

export const rubikFont = Rubik({
subsets: ['latin'],
variable: '--font-rubik',
weight: ['500', '800'],
display: 'swap'
});
export const ralewayFont = Raleway({
subsets: ['latin'],
variable: '--font-raleway',
weight: ['400', '800'],
display: 'swap'
});
export const hindVadodaraFont = Hind_Vadodara({
subsets: ['latin'],
variable: '--font-hind-vadodara',
weight: ['400'],
display: 'swap',
preload: true
});
8 changes: 4 additions & 4 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const TailwindConfig = {
}
},
fontFamily: {
heading: ['Rubik'],
'sub-heading': ['Raleway', 'sans-serif'],
body: ['"Hind Vadodara"', 'sans-serif'],
sans: ['"Hind Vadodara"', 'sans-serif']
heading: ['var(--font-rubik)', 'sans-serif'],
'sub-heading': ['var(--font-raleway)', 'sans-serif'],
body: ['var(--font-hind-vadodara)', 'sans-serif'],
sans: ['var(--font-hind-vadodara)', 'sans-serif']
}
},
plugins: [require('@tailwindcss/typography'), require('daisyui')],
Expand Down

0 comments on commit 3de13f5

Please sign in to comment.