Skip to content

Commit

Permalink
improvement: media queries level 5 compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
kripod committed May 31, 2020
1 parent a6af6a2 commit 671022a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 15 deletions.
7 changes: 1 addition & 6 deletions packages/web-api-hooks/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion packages/web-api-hooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function Component() {
}
```

Returns **(`"no-preference"` \| `"light"` \| `"dark"`)** Preferred color scheme.
Returns **(`"light"` \| `"dark"`)** Preferred color scheme.

#### useDeviceMotion

Expand Down
2 changes: 1 addition & 1 deletion packages/web-api-hooks/src/ssr.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Hook<T>({ callback }: HookProps<T>): JSX.Element {
return <>{JSON.stringify(callback())}</>;
}

function renderHookToString<T>(callback: () => T): string {
function renderHookToString(callback: () => unknown): string {
return renderToString(<Hook callback={callback} />);
}

Expand Down
9 changes: 2 additions & 7 deletions packages/web-api-hooks/src/useColorSchemePreference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

0 comments on commit 671022a

Please sign in to comment.