forked from jd-solanki/anu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(theme): add new colors,
useAnu
composable, Theming improvements
- Loading branch information
1 parent
f70d632
commit e340271
Showing
26 changed files
with
450 additions
and
149 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# useAnu | ||
|
||
`useAnu` composable provides API for interactive with Anu. | ||
|
||
## Basic | ||
|
||
`useAnu` provides following reactive variables: | ||
|
||
- `themes: ConfigThemes` => Registered themes. You can modify colors & CSS variables at runtime 😍 | ||
- `activeThemeName: string` => Name of the active theme in your app | ||
- `activeTheme: ({ name: string, theme: ThemeOptions })` => Convenient computed property to get details of active theme. Don't modify it 🙅🏻♂️ | ||
|
||
```ts | ||
import { useAnu } from 'anu-vue'; | ||
|
||
const { themes, activeThemeName, activeTheme } = useAnu() | ||
``` | ||
|
||
## Changing Active Theme | ||
|
||
You can change the active theme at runtime by modifying the `activeThemeName` ref. | ||
|
||
```ts{5} | ||
import { useAnu } from 'anu-vue'; | ||
const { activeThemeName } = useAnu() | ||
activeThemeName.value = 'dark' | ||
``` | ||
|
||
## Active Theme Details | ||
|
||
Use `activeTheme` computed property to get the details of active theme. | ||
|
||
```ts{6-7} | ||
import { computed } from 'vue'; | ||
import { useAnu } from 'anu-vue'; | ||
const { activeTheme } = useAnu() | ||
const activeThemeName = computed(() => activeTheme.value.name) | ||
const primaryColor = computed(() => activeTheme.value.theme.colors.primary) | ||
``` | ||
|
||
:::warning | ||
Modifying `activeTheme` computed property won't do anything so never mutate this computed property. | ||
::: | ||
|
||
## Modifying Themes | ||
|
||
You can modify any theme at runtime via `theme` ref. | ||
|
||
```ts{8,12} | ||
import { useAnu } from 'anu-vue'; | ||
const { themes } = useAnu() | ||
// Change primary color for all themes | ||
for (const themeName in themes.value) { | ||
const theme = themes.value[themeName] | ||
theme.colors.primary = '235, 97.7%, 66.3%' | ||
} | ||
// Or you can also change the primary color for single theme | ||
themes.value.light.colors.primary = '235, 97.7%, 66.3%' | ||
``` | ||
|
||
<br> | ||
|
||
--- | ||
|
||
<br> | ||
|
||
Related documentation: | ||
|
||
- [Theme](/guide/features/theme.md) | ||
- [Colors](/guide/getting-started/customization.html#color) |
This file contains 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
This file contains 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
Oops, something went wrong.