This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // reason: package provided by our components library | |
| // eslint-disable-next-line import/no-extraneous-dependencies | |
| import MobileDetect from 'mobile-detect'; | |
| import { Viewport } from '@lib/types'; | |
| /** server-side script for guessing user Viewport if its Mobile/Tablet or others. This initial Viewport is used in our ViewportProvider which then runs the Viewport detection client-side */ | |
| export const getViewportFromUserAgent = ( | |
| userAgent: string | null | |
| ): Viewport.lg | Viewport.sm | Viewport.md => { | |
| // corporate firewalls or users who like to stay unknown |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function middleware(req: NextRequest) { | |
| const { pathname } = req.nextUrl; | |
| // public static stuff | |
| if (pathname.startsWith('/images') || pathname.startsWith('/fonts')) { | |
| return undefined; | |
| } | |
| // api/static/client routes NextJS stuff | |
| if (pathname.includes('.') || pathname.startsWith('/api')) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function App({ Component, pageProps }: AppProps) { | |
| const { i18n } = useTranslation(); | |
| const { locale, viewport } = pageProps; | |
| if (locale !== i18n.language) { | |
| i18n.changeLanguage(locale); | |
| } | |
| return ( | |
| <I18nProvider> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { | |
| FC, | |
| ReactNode, | |
| useState, | |
| useEffect, | |
| createContext, | |
| useContext, | |
| useCallback, | |
| } from 'react'; | |
| import { Viewport } from '@lib/types'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { ReactNode } from 'react'; | |
| import { Viewport } from '@lib/types'; | |
| import { ViewportContext } from '../hooks/use-viewport/use-viewport'; | |
| type TMockedViewportProps = { | |
| children: ReactNode; | |
| viewport?: Viewport; | |
| }; | |
| const MockedViewportProvider = ({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import { Viewport } from '@lib/types'; | |
| import { | |
| screen, | |
| render, | |
| renderHook, | |
| waitFor, | |
| } from '../../__tests__/test-utils'; | |
| import { MockedViewportProvider } from '../../__mocks__/mock-viewport-provider'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export enum Viewport { | |
| xs = 'xs', | |
| sm = 'sm', | |
| md = 'md', | |
| lg = 'lg', | |
| xl = 'xl', | |
| '2xl' = '2xl', | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "@maapteh/types-api-animals", | |
| "version": "1.0.0", | |
| "typings": "index.d.ts" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Imports of types for `index.d.ts` | |
| /// <reference path="./pet-store.d.ts" /> | |
| /// <reference path="./wild-cats.d.ts" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* eslint-disable */ | |
| /* auto generated by yarn workspace @maapteh/types tooling:generate-types */ | |
| declare namespace PetStoreRaw { | |
| /** | |
| * This file was auto-generated by openapi-typescript. | |
| * Do not make direct changes to the file. | |
| */ | |
| export interface paths { | |
| '/pet': { |