|
1 | | -import { ref, computed } from "vue"; |
| 1 | +import { ref, computed, type App } from "vue"; |
2 | 2 | import { darkTheme, lightTheme } from "naive-ui"; |
| 3 | +import { ConfigProviderInjection } from "naive-ui/es/config-provider/src/internal-interface.js"; |
3 | 4 |
|
4 | | -import useDarkTheme from "./useDarkTheme.ts"; |
| 5 | +import isDark from "./useDarkTheme.ts"; |
| 6 | +import baseFontSize from "./useBaseFontSize.ts"; |
5 | 7 |
|
6 | | -const useConfigProvider = (app) => { |
| 8 | +/** |
| 9 | + * I'm trying to mimic the design of original Naive UI, which can be found by |
| 10 | + * checking default theme variables or inspecting Naive UI website. |
| 11 | + * |
| 12 | + * https://www.naiveui.com/en-US/docs/theme |
| 13 | + */ |
| 14 | + |
| 15 | +const themeOverrides = computed(() => ({ |
| 16 | + common: { |
| 17 | + fontSize: baseFontSize.value, // regular text - 16px |
| 18 | + fontSizeMedium: baseFontSize.value, // default buttons - 16px |
| 19 | + }, |
| 20 | +})); |
| 21 | + |
| 22 | +const useConfigProvider = (app: App) => { |
7 | 23 | // Manually inject n-config-provider context |
8 | | - const isDark = useDarkTheme(); |
9 | 24 | app.provide("n-config-provider", { |
10 | 25 | mergedThemeRef: computed(() => (isDark.value ? darkTheme : lightTheme)), // required |
11 | | - mergedThemeOverridesRef: ref({}), // required |
| 26 | + mergedThemeOverridesRef: themeOverrides, // required |
12 | 27 | mergedClsPrefixRef: ref("n"), // required for styles |
13 | | - }); |
| 28 | + } as Partial<ConfigProviderInjection>); |
14 | 29 | }; |
15 | 30 |
|
16 | 31 | export default useConfigProvider; |
0 commit comments