Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: ui fixes

DarkPhoenix2704eb1becb69a28
diff --git a/packages/nc-gui/app.vue b/packages/nc-gui/app.vue
index f3fb0ac458..35ba298c76 100644
--- a/packages/nc-gui/app.vue
+++ b/packages/nc-gui/app.vue
@@ -11,6 +11,8 @@ const { isExperimentalFeatureModalOpen, initializeFeatures, isFeatureEnabled } =
initializeFeatures()
+useAntDvTheme()
+
const isDarkModeEnabled = computed(() => isFeatureEnabled(FEATURE_FLAG.DARK_MODE))
if (isDarkModeEnabled.value) {
diff --git a/packages/nc-gui/composables/useAntDvTheme.ts b/packages/nc-gui/composables/useAntDvTheme.ts
new file mode 100644
index 0000000000..841b28a445
--- /dev/null
+++ b/packages/nc-gui/composables/useAntDvTheme.ts
@@ -0,0 +1,43 @@
+import { ConfigProvider } from 'ant-design-vue'
+import tinycolor from 'tinycolor2'
+
+export const useAntDvTheme = createGlobalState((config?: Partial<ThemeConfig>) => {
+ const primaryColor = useCssVar('--color-primary', typeof document !== 'undefined' ? document.documentElement : null)
+ const accentColor = useCssVar('--color-accent', typeof document !== 'undefined' ? document.documentElement : null)
+ const defaultTheme = {
+ primaryColor: themeV2Colors['royal-blue'].DEFAULT,
+ accentColor: themeV2Colors.pink['500'],
+ }
+
+ /** current theme config */
+ const currentTheme = ref(defaultTheme)
+
+ /** set initial config */
+ setTheme(config ?? currentTheme.value)
+
+ /** set theme */
+ function setTheme(theme?: Partial<ThemeConfig>) {
+ const themePrimary = theme?.primaryColor ? tinycolor(theme.primaryColor) : tinycolor(themeV2Colors['royal-blue'].DEFAULT)
+ const themeAccent = theme?.accentColor ? tinycolor(theme.accentColor) : tinycolor(themeV2Colors.pink['500'])
+
+ // convert hex colors to rgb values
+ primaryColor.value = themePrimary.isValid()
+ ? hexToRGB(themePrimary.toHex8String())
+ : hexToRGB(themeV2Colors['royal-blue'].DEFAULT)
+ accentColor.value = themeAccent.isValid() ? hexToRGB(themeAccent.toHex8String()) : hexToRGB(themeV2Colors.pink['500'])
+
+ currentTheme.value = {
+ primaryColor: themePrimary.toHex8String().toUpperCase().slice(0, -2),
+ accentColor: themeAccent.toHex8String().toUpperCase().slice(0, -2),
+ }
+
+ ConfigProvider.config({
+ theme: currentTheme.value,
+ })
+ }
+
+ return {
+ currentTheme,
+ setTheme,
+ }
+})