Skip to content

Commit

Permalink
Merge pull request #220 from hiddenest/minor/issue-9-optimize-font
Browse files Browse the repository at this point in the history
chore: Optimize font #9
  • Loading branch information
BrandonRomano authored Jan 7, 2025
2 parents 0bf0e14 + 7372720 commit 2565fe5
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
17 changes: 11 additions & 6 deletions src/components/link/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from "classnames";
import { SquareArrowOutUpRight } from "lucide-react";
import NextLink from "next/link";
import { pretendardVariable } from "../text";
import { pretendardStdVariable } from "../text";
import s from "./Link.module.css";

export interface SimpleLink {
Expand Down Expand Up @@ -30,11 +30,16 @@ export default function Link({
return (
<NextLink
onClick={onClick}
className={classNames(s.link, pretendardVariable.className, className, {
[s.weightLight]: weight === "light",
[s.weightRegular]: weight === "regular",
[s.weightMedium]: weight === "medium",
})}
className={classNames(
s.link,
pretendardStdVariable.className,
className,
{
[s.weightLight]: weight === "light",
[s.weightRegular]: weight === "regular",
[s.weightMedium]: weight === "medium",
},
)}
href={href}
target={isExternal ? "_blank" : ""}
>
Expand Down
Binary file not shown.
Binary file removed src/components/text/font/pretendard-variable.woff2
Binary file not shown.
11 changes: 6 additions & 5 deletions src/components/text/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { JetBrains_Mono } from "next/font/google";
import { forwardRef, UIEventHandler } from "react";
import s from "./Text.module.css";

// https://github.com/orioncactus/pretendard
export const pretendardVariable = localFont({
src: "./font/pretendard-variable.woff2",
// https://github.com/orioncactus/pretendard/tree/main/packages/pretendard-std
export const pretendardStdVariable = localFont({
src: "./font/pretendard-std-variable.woff2",
display: "auto",
variable: "--pretendard-variable",
variable: "--pretendard-std-variable",
});

export const jetbrainsMono = JetBrains_Mono({
Expand Down Expand Up @@ -48,7 +48,8 @@ const Text = forwardRef<HTMLElement, TextProps>(function Text(
ref={ref as any}
onScroll={onScroll}
className={classNames(s.text, className, {
[pretendardVariable.className]: font === "display" || font === "body",
[pretendardStdVariable.className]:
font === "display" || font === "body",
[jetbrainsMono.className]: font === "code",
[s.weightLight]: weight === "light",
[s.weightRegular]: weight === "regular",
Expand Down
2 changes: 1 addition & 1 deletion src/layouts/root-layout/RootLayout.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.rootLayout {
font-family: var(--pretendard-variable);
font-family: var(--pretendard-std-variable);

& a {
color: var(--gray-9);
Expand Down
4 changes: 2 additions & 2 deletions src/layouts/root-layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { jetbrainsMono, pretendardVariable } from "@/components/text";
import { jetbrainsMono, pretendardStdVariable } from "@/components/text";
import classNames from "classnames";
import Head from "next/head";
import s from "./RootLayout.module.css";
Expand All @@ -23,7 +23,7 @@ export default function RootLayout({
<div
className={classNames(
s.rootLayout,
pretendardVariable.variable,
pretendardStdVariable.variable,
jetbrainsMono.variable,
className,
)}
Expand Down

0 comments on commit 2565fe5

Please sign in to comment.