From efaaa3dd99153102eaec6a2be8f36880e6061ad6 Mon Sep 17 00:00:00 2001 From: Marcus-Rise Date: Tue, 26 Jul 2022 14:15:49 +0400 Subject: [PATCH] ci: docs --- README.md | 80 +------------------ .../docs/src/stories/Introduction.stories.mdx | 2 +- packages/theme/README.md | 80 ++++++++++++++++++- 3 files changed, 81 insertions(+), 81 deletions(-) mode change 100644 => 120000 README.md mode change 120000 => 100644 packages/theme/README.md diff --git a/README.md b/README.md deleted file mode 100644 index c19bf68..0000000 --- a/README.md +++ /dev/null @@ -1,79 +0,0 @@ -# React theme - -Handle system color scheme and user preferences. - -## Install - -using `npm` - -```bash -npm install @marcus-rise/react-theme -``` - -or using `yarn` - -```bash -yarn add @marcus-rise/react-theme -``` - -## Usage - -First of all, we need to initialize `ThemeProvider` context, and after this we can get access with -hook `useTheme`. - -```tsx -import {ThemeProvider, useTheme} from "@marcus-rise/react-theme"; - -const ThemeToggle = () => { - const {isDarkTheme, preferences, toggleTheme} = useTheme(); - - return ( - <> - -
- preferences: {preferences} -
- isDarkTheme: {isDarkTheme ? "yes" : "no"} - - ) -} - -const App = () => ( - - - -) -``` - -## API - -### Context provider `ThemeProvider` - -To set custom localStorage key set `preferencesStorageKey` property for user preferences - -```tsx - -``` - -### Hook `useTheme` - -- `isDarkTheme` is a`boolean` what color scheme is selected, basing on user preferences and system - settings -- `preferences` is a `string` form `enum` - -```ts -enum ThemePreference { - DARK = "dark", - LIGHT = "light", - SYSTEM = "system", -} -``` - -you can import this enum directly - -```ts -import {ThemeProvider} from "@marcus-rise/react-theme"; -``` - -- `toggleTheme` is a `function`, that toggle preferences from `system` -> `light` -> `dark` - diff --git a/README.md b/README.md new file mode 120000 index 0000000..2b9ab7c --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +packages/theme/README.md \ No newline at end of file diff --git a/packages/docs/src/stories/Introduction.stories.mdx b/packages/docs/src/stories/Introduction.stories.mdx index 0d7048b..e3bcacc 100644 --- a/packages/docs/src/stories/Introduction.stories.mdx +++ b/packages/docs/src/stories/Introduction.stories.mdx @@ -1,4 +1,4 @@ -import Readme from '../../../../README.md' +import Readme from '@marcus-rise/react-theme/README.md' import {Canvas, Meta} from '@storybook/addon-docs'; import {Description} from '@storybook/addon-docs/blocks'; import {App} from "../components/simple-example.component"; diff --git a/packages/theme/README.md b/packages/theme/README.md deleted file mode 120000 index fe84005..0000000 --- a/packages/theme/README.md +++ /dev/null @@ -1 +0,0 @@ -../../README.md \ No newline at end of file diff --git a/packages/theme/README.md b/packages/theme/README.md new file mode 100644 index 0000000..c19bf68 --- /dev/null +++ b/packages/theme/README.md @@ -0,0 +1,79 @@ +# React theme + +Handle system color scheme and user preferences. + +## Install + +using `npm` + +```bash +npm install @marcus-rise/react-theme +``` + +or using `yarn` + +```bash +yarn add @marcus-rise/react-theme +``` + +## Usage + +First of all, we need to initialize `ThemeProvider` context, and after this we can get access with +hook `useTheme`. + +```tsx +import {ThemeProvider, useTheme} from "@marcus-rise/react-theme"; + +const ThemeToggle = () => { + const {isDarkTheme, preferences, toggleTheme} = useTheme(); + + return ( + <> + +
+ preferences: {preferences} +
+ isDarkTheme: {isDarkTheme ? "yes" : "no"} + + ) +} + +const App = () => ( + + + +) +``` + +## API + +### Context provider `ThemeProvider` + +To set custom localStorage key set `preferencesStorageKey` property for user preferences + +```tsx + +``` + +### Hook `useTheme` + +- `isDarkTheme` is a`boolean` what color scheme is selected, basing on user preferences and system + settings +- `preferences` is a `string` form `enum` + +```ts +enum ThemePreference { + DARK = "dark", + LIGHT = "light", + SYSTEM = "system", +} +``` + +you can import this enum directly + +```ts +import {ThemeProvider} from "@marcus-rise/react-theme"; +``` + +- `toggleTheme` is a `function`, that toggle preferences from `system` -> `light` -> `dark` +