瀏覽代碼

refactor: changed theme variable names from lowercase to uppercase and renamed the close icon function to improve readability

nian 1 月之前
父節點
當前提交
96c63cc7ce
共有 2 個文件被更改,包括 27 次插入27 次删除
  1. 12 12
      src/theme/dark.ts
  2. 15 15
      src/theme/light.ts

+ 12 - 12
src/theme/dark.ts

@@ -3,7 +3,7 @@ import twc from '@/utils/tailwindColor'
 
 import type { GlobalThemeOverrides } from 'naive-ui'
 
-const dark = {
+const DARK = {
   baseColor: twc.neutral[250],
   textColorBase: twc.neutral[250],
   textColor1: twc.neutral[350],
@@ -12,7 +12,7 @@ const dark = {
   borderColor: twc.neutral[800],
 }
 
-const closeIcon = (primaryColor: string) => {
+const closeIconColor = (primaryColor: string) => {
   return {
     closeIconColorSuccess: twc.lime[600],
     closeIconColorInfo: twc.sky[600],
@@ -50,19 +50,19 @@ const closeIcon = (primaryColor: string) => {
 export function baseDarkThemeOverrides(primaryColor = ''): GlobalThemeOverrides {
   return {
     common: {
-      baseColor: dark.baseColor,
+      baseColor: DARK.baseColor,
 
-      textColorBase: dark.textColorBase,
+      textColorBase: DARK.textColorBase,
 
-      textColor1: dark.textColor1,
+      textColor1: DARK.textColor1,
 
-      textColor2: dark.textColor2,
+      textColor2: DARK.textColor2,
 
-      textColor3: dark.textColor3,
+      textColor3: DARK.textColor3,
 
       bodyColor: twc.neutral[950],
 
-      borderColor: dark.borderColor,
+      borderColor: DARK.borderColor,
 
       cardColor: twc.neutral[900],
 
@@ -101,7 +101,7 @@ export function baseDarkThemeOverrides(primaryColor = ''): GlobalThemeOverrides
       errorColorSuppl: twc.pink[650],
     },
     Alert: {
-      ...closeIcon(primaryColor),
+      ...closeIconColor(primaryColor),
     },
     Button: {
       textColorSuccess: twc.lime[50],
@@ -113,10 +113,10 @@ export function baseDarkThemeOverrides(primaryColor = ''): GlobalThemeOverrides
       textColorError: twc.pink[50],
     },
     Card: {
-      borderColor: dark.borderColor,
+      borderColor: DARK.borderColor,
     },
     DataTable: {
-      borderColor: dark.borderColor,
+      borderColor: DARK.borderColor,
       tdColor: twc.neutral[900],
       tdColorHover: cbh(twc.neutral[850], 0.06),
       thColor: twc.neutral[850],
@@ -150,7 +150,7 @@ export function baseDarkThemeOverrides(primaryColor = ''): GlobalThemeOverrides
       colorError: cmh(twc.neutral[750], twc.pink[950], 0.06),
       colorLoading: cmh(twc.neutral[750], primaryColor, 0.01),
 
-      ...closeIcon(primaryColor),
+      ...closeIconColor(primaryColor),
     },
     Modal: {
       peers: {

+ 15 - 15
src/theme/light.ts

@@ -3,7 +3,7 @@ import twc from '@/utils/tailwindColor'
 
 import type { GlobalThemeOverrides } from 'naive-ui'
 
-const light = {
+const LIGHT = {
   textColorBase: twc.neutral[800],
   textColor1: twc.neutral[750],
   textColor2: twc.neutral[700],
@@ -11,7 +11,7 @@ const light = {
   borderColor: twc.neutral[150],
 }
 
-const closeIcon = (primaryColor: string) => {
+const closeIconColor = (primaryColor: string) => {
   return {
     closeIconColorSuccess: twc.lime[500],
     closeIconColorInfo: twc.sky[500],
@@ -49,17 +49,17 @@ const closeIcon = (primaryColor: string) => {
 export function baseLightThemeOverrides(primaryColor = ''): GlobalThemeOverrides {
   return {
     common: {
-      textColorBase: light.textColorBase,
+      textColorBase: LIGHT.textColorBase,
 
-      textColor1: light.textColor1,
+      textColor1: LIGHT.textColor1,
 
-      textColor2: light.textColor2,
+      textColor2: LIGHT.textColor2,
 
-      textColor3: light.textColor3,
+      textColor3: LIGHT.textColor3,
 
       bodyColor: twc.neutral[25],
 
-      borderColor: light.borderColor,
+      borderColor: LIGHT.borderColor,
 
       cardColor: twc.neutral[25],
 
@@ -98,7 +98,7 @@ export function baseLightThemeOverrides(primaryColor = ''): GlobalThemeOverrides
       errorColorSuppl: twc.pink[500],
     },
     Alert: {
-      ...closeIcon(primaryColor),
+      ...closeIconColor(primaryColor),
     },
     Button: {
       textColorSuccess: twc.lime[25],
@@ -110,20 +110,20 @@ export function baseLightThemeOverrides(primaryColor = ''): GlobalThemeOverrides
       textColorError: twc.pink[25],
     },
     Card: {
-      borderColor: light.borderColor,
+      borderColor: LIGHT.borderColor,
     },
     Checkbox: {
       colorDisabled: twc.neutral[100],
     },
     DataTable: {
-      borderColor: light.borderColor,
+      borderColor: LIGHT.borderColor,
       tdColor: twc.neutral[25],
       tdColorHover: cdh(twc.neutral[100], 0.06),
       thColor: twc.neutral[100],
     },
     Drawer: {
-      footerBorderTop: `1px solid ${light.borderColor}`,
-      headerBorderBottom: `1px solid ${light.borderColor}`,
+      footerBorderTop: `1px solid ${LIGHT.borderColor}`,
+      headerBorderBottom: `1px solid ${LIGHT.borderColor}`,
       peers: {
         Scrollbar: {
           color: twc.neutral[300],
@@ -147,7 +147,7 @@ export function baseLightThemeOverrides(primaryColor = ''): GlobalThemeOverrides
       colorError: cbh(twc.pink[25], 0.3),
       colorLoading: cmh(twc.neutral[25], primaryColor, 0.01),
 
-      ...closeIcon(primaryColor),
+      ...closeIconColor(primaryColor),
     },
     Modal: {
       peers: {
@@ -167,11 +167,11 @@ export function baseLightThemeOverrides(primaryColor = ''): GlobalThemeOverrides
     },
     Popover: {
       color: twc.neutral[25],
-      textColor: light.textColor2,
+      textColor: LIGHT.textColor2,
     },
     Slider: {
       indicatorColor: twc.neutral[25],
-      indicatorTextColor: light.textColor2,
+      indicatorTextColor: LIGHT.textColor2,
     },
     Select: {
       peers: {