From 671022a9662e3dd3ecc4e6e48f5b587a4e8a3ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Sun, 31 May 2020 18:55:32 +0200 Subject: [PATCH] improvement: media queries level 5 compliance --- packages/web-api-hooks/CHANGELOG.md | 7 +------ packages/web-api-hooks/README.md | 2 +- packages/web-api-hooks/src/ssr.test.tsx | 2 +- packages/web-api-hooks/src/useColorSchemePreference.ts | 9 ++------- 4 files changed, 5 insertions(+), 15 deletions(-) diff --git a/packages/web-api-hooks/CHANGELOG.md b/packages/web-api-hooks/CHANGELOG.md index 3e9d304..46fc4b5 100644 --- a/packages/web-api-hooks/CHANGELOG.md +++ b/packages/web-api-hooks/CHANGELOG.md @@ -5,14 +5,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ## [3.0.1](https://github.com/kripod/react-hooks/compare/web-api-hooks@3.0.0...web-api-hooks@3.0.1) (2020-03-30) - ### Bug Fixes -* bundle NetworkInformation properly ([2839251](https://github.com/kripod/react-hooks/commit/2839251e37ae6165bb3def0fea2d8f702cb86b86)) - - - - +- bundle NetworkInformation properly ([2839251](https://github.com/kripod/react-hooks/commit/2839251e37ae6165bb3def0fea2d8f702cb86b86)) # [3.0.0](https://github.com/kripod/react-hooks/compare/web-api-hooks@2.2.2...web-api-hooks@3.0.0) (2020-03-30) diff --git a/packages/web-api-hooks/README.md b/packages/web-api-hooks/README.md index c355458..7f3bc12 100644 --- a/packages/web-api-hooks/README.md +++ b/packages/web-api-hooks/README.md @@ -77,7 +77,7 @@ function Component() { } ``` -Returns **(`"no-preference"` \| `"light"` \| `"dark"`)** Preferred color scheme. +Returns **(`"light"` \| `"dark"`)** Preferred color scheme. #### useDeviceMotion diff --git a/packages/web-api-hooks/src/ssr.test.tsx b/packages/web-api-hooks/src/ssr.test.tsx index 61dc40c..af3d4dd 100644 --- a/packages/web-api-hooks/src/ssr.test.tsx +++ b/packages/web-api-hooks/src/ssr.test.tsx @@ -13,7 +13,7 @@ function Hook({ callback }: HookProps): JSX.Element { return <>{JSON.stringify(callback())}; } -function renderHookToString(callback: () => T): string { +function renderHookToString(callback: () => unknown): string { return renderToString(); } diff --git a/packages/web-api-hooks/src/useColorSchemePreference.ts b/packages/web-api-hooks/src/useColorSchemePreference.ts index 45089ec..41f7fd6 100644 --- a/packages/web-api-hooks/src/useColorSchemePreference.ts +++ b/packages/web-api-hooks/src/useColorSchemePreference.ts @@ -11,14 +11,9 @@ import useMedia from './useMedia'; * // ... * } */ -export default function useColorSchemePreference(): - | 'no-preference' - | 'light' - | 'dark' { - const isLight = useMedia('(prefers-color-scheme: light)'); +export default function useColorSchemePreference(): 'light' | 'dark' { const isDark = useMedia('(prefers-color-scheme: dark)'); - if (isLight) return 'light'; if (isDark) return 'dark'; - return 'no-preference'; + return 'light'; }