Skip to content

Commit 8c3b481

Browse files
authored
Merge pull request #13852 from ethereum/refactor-screens-config
Refactor: reuse `screens` config file
2 parents f645fa3 + 7b0083f commit 8c3b481

File tree

6 files changed

+14
-22
lines changed

6 files changed

+14
-22
lines changed

src/hooks/useBreakpointValue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { screens } from "../../tailwind/screens"
1+
import { screens } from "@/lib/utils/screen"
22

33
import { useMediaQuery } from "./useMediaQuery"
44

src/lib/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import type { SimulatorNav } from "@/components/Simulator/interfaces"
2323
import allQuizData from "@/data/quizzes"
2424
import allQuestionData from "@/data/quizzes/questionBank"
2525

26+
import { screens } from "./utils/screen"
2627
import { WALLETS_FILTERS_DEFAULT } from "./constants"
2728

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

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

861-
export type BreakpointKey = keyof typeof twConfig.theme.screens
861+
export type BreakpointKey = keyof typeof screens

src/lib/utils/screen.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
import type { ScreensConfig } from "tailwindcss/types/config"
2+
13
import type { BreakpointKey } from "../types"
24

3-
import twConfig from "@/styles/config"
5+
export const screens = {
6+
sm: "480px",
7+
md: "768px",
8+
lg: "992px",
9+
xl: "1280px",
10+
"2xl": "1536px",
11+
} satisfies ScreensConfig
412

5-
export const breakpointAsNumber = Object.entries(twConfig.theme.screens).reduce(
13+
export const breakpointAsNumber = Object.entries(screens).reduce(
614
(acc, curr) => {
715
const [breakpoint, value] = curr
816
acc[breakpoint] = +value.split("px")[0]

src/styles/config.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

tailwind.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Config } from "tailwindcss"
22
import plugin from "tailwindcss/plugin"
33

4-
import { screens } from "./tailwind/screens"
4+
import { screens } from "./src/lib/utils/screen"
55

66
const config = {
77
// TODO: Move to "class" strategy after removing Chakra

tailwind/screens.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)