Skip to content

Commit

Permalink
reuse the screens file instead of importing the entire tw config file
Browse files Browse the repository at this point in the history
  • Loading branch information
pettinarip committed Sep 12, 2024
1 parent 489eebc commit 7b0083f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/hooks/useBreakpointValue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { screens } from "../../tailwind/screens"
import { screens } from "@/lib/utils/screen"

import { useMediaQuery } from "./useMediaQuery"

Expand Down
4 changes: 2 additions & 2 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import type { SimulatorNav } from "@/components/Simulator/interfaces"
import allQuizData from "@/data/quizzes"
import allQuestionData from "@/data/quizzes/questionBank"

import { screens } from "./utils/screen"
import { WALLETS_FILTERS_DEFAULT } from "./constants"

import { layoutMapping } from "@/pages/[...slug]"
import twConfig from "@/styles/config"

// Credit: https://stackoverflow.com/a/52331580
export type Unpacked<T> = T extends (infer U)[] ? U : T
Expand Down Expand Up @@ -858,4 +858,4 @@ export type EventCardProps = {
imageUrl?: string
}

export type BreakpointKey = keyof typeof twConfig.theme.screens
export type BreakpointKey = keyof typeof screens
12 changes: 10 additions & 2 deletions src/lib/utils/screen.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import type { ScreensConfig } from "tailwindcss/types/config"

import type { BreakpointKey } from "../types"

import twConfig from "@/styles/config"
export const screens = {
sm: "480px",
md: "768px",
lg: "992px",
xl: "1280px",
"2xl": "1536px",
} satisfies ScreensConfig

export const breakpointAsNumber = Object.entries(twConfig.theme.screens).reduce(
export const breakpointAsNumber = Object.entries(screens).reduce(
(acc, curr) => {
const [breakpoint, value] = curr
acc[breakpoint] = +value.split("px")[0]
Expand Down
7 changes: 0 additions & 7 deletions src/styles/config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion tailwind.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Config } from "tailwindcss"
import plugin from "tailwindcss/plugin"

import { screens } from "./tailwind/screens"
import { screens } from "./src/lib/utils/screen"

const config = {
// TODO: Move to "class" strategy after removing Chakra
Expand Down
9 changes: 0 additions & 9 deletions tailwind/screens.ts

This file was deleted.

0 comments on commit 7b0083f

Please sign in to comment.