Skip to content

Commit

Permalink
tweak: move isMobile to separate utility file along with DeviceType
Browse files Browse the repository at this point in the history
  • Loading branch information
hannahpurcell committed Oct 9, 2024
1 parent 7e603ff commit efac010
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
3 changes: 2 additions & 1 deletion assets/src/components/detours/diversionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ import { timeAgoLabel } from "../../util/dateTime"
import { DetourStatus, timestampLabelFromStatus } from "../detoursTable"
import { ActivateDetour } from "./activateDetourModal"
import { DeactivateDetourModal } from "./deactivateDetourModal"
import useScreenSize, { isMobile } from "../../hooks/useScreenSize"
import useScreenSize from "../../hooks/useScreenSize"
import Drawer from "../drawer"
import { isMobile } from "../../util/screenSize"

const displayFieldsFromRouteAndPattern = (
route: Route,
Expand Down
5 changes: 1 addition & 4 deletions assets/src/hooks/useScreenSize.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react"
import { DeviceType } from "../skate"
import { DeviceType } from "../util/screenSize"

const maxMobileWidth = 480
const minMobileLandscapeTabletPortraitWidth = maxMobileWidth + 1
Expand Down Expand Up @@ -37,7 +37,4 @@ const useScreenSize = (): DeviceType => {
}
}

export const isMobile = (deviceType: string) =>
deviceType === "mobile" || deviceType === "mobile_landscape_tablet_portrait"

export default useScreenSize
6 changes: 0 additions & 6 deletions assets/src/skate.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,3 @@ declare global {
}

export type UserToken = string

export type DeviceType =
| "mobile"
| "mobile_landscape_tablet_portrait"
| "tablet"
| "desktop"
8 changes: 8 additions & 0 deletions assets/src/util/screenSize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type DeviceType = "mobile" |
"mobile_landscape_tablet_portrait" |
"tablet" |
"desktop";


export const isMobile = (deviceType: string) =>
deviceType === "mobile" || deviceType === "mobile_landscape_tablet_portrait"
2 changes: 1 addition & 1 deletion assets/tests/components/viewHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ViewHeader from "../../src/components/viewHeader"
import userEvent from "@testing-library/user-event"
import useScreenSize from "../../src/hooks/useScreenSize"
import { OpenView } from "../../src/state/pagePanelState"
import { DeviceType } from "../../src/skate"
import { DeviceType } from "../../src/util/screenSize"

jest.mock("../../src/hooks/useScreenSize", () => ({
__esModule: true,
Expand Down
2 changes: 1 addition & 1 deletion assets/tests/testHelpers/mockHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { jest } from "@jest/globals"
import React, { useReducer, useState } from "react"
import usePatternsByIdForRoute from "../../src/hooks/usePatternsByIdForRoute"
import useScreenSize from "../../src/hooks/useScreenSize"
import { DeviceType } from "../../src/skate"
import { DeviceType } from "../../src/util/screenSize"
import { VehicleInScheduledService, Ghost } from "../../src/realtime"
import { routePatternFactory } from "../factories/routePattern"
import { stopFactory } from "../factories/stop"
Expand Down

0 comments on commit efac010

Please sign in to comment.