@blocklet/pages-kit 0.7.21 → 0.7.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ exports.isBrowserEnv = isBrowserEnv;
13
13
  */
14
14
  function isMuiColorKey(value) {
15
15
  // special case
16
- if (value === 'transparent' || value === 'divider' || value === 'auto') {
16
+ if (value === 'transparent' || value === 'divider' || value === 'auto' || value === 'grey25') {
17
17
  return true;
18
18
  }
19
19
  return /^(primary|secondary|error|warning|info|success|grey|background|text|action|common)\.[a-zA-Z0-9]+$/.test(value);
@@ -3,6 +3,7 @@ import { useTheme } from '@mui/material/styles';
3
3
  import get from 'lodash/get';
4
4
  import { useCallback, useMemo } from 'react';
5
5
  import { isMuiColorKey, colorConvert, gradientFromPrimary, isGradient } from '../utils/style';
6
+ const grey25 = { light: '#F8FAFC', dark: 'rgba(255, 255, 255, 0.05)' }; // 扩展 grey25 颜色
6
7
  /**
7
8
  * Hook 用于获取和操作 MUI 主题色
8
9
  */
@@ -23,7 +24,7 @@ export function useMuiColorPalette() {
23
24
  // 特殊颜色组
24
25
  {
25
26
  type: 'special',
26
- keys: ['transparent', 'auto'],
27
+ keys: ['transparent', 'auto', 'grey25'],
27
28
  variants: null,
28
29
  format: (key) => key,
29
30
  accessor: (key) => ({ [key]: key }),
@@ -112,7 +113,15 @@ export function useMuiColorPalette() {
112
113
  const alternateColorValue = get(alternateTheme, `palette.${colorKey}`, '');
113
114
  if (paletteObj && typeof paletteObj === 'object') {
114
115
  const colorValue = String(paletteObj[variant ?? key] || '');
115
- if (colorValue) {
116
+ if (key === 'grey25') {
117
+ colors.push({
118
+ colorKey,
119
+ colorValue: grey25[theme.palette.mode],
120
+ group: config.type,
121
+ alternateColorValue: grey25[alternateTheme.palette.mode],
122
+ });
123
+ }
124
+ else if (colorValue) {
116
125
  colors.push({ colorKey, colorValue, group: config.type, alternateColorValue });
117
126
  }
118
127
  }
@@ -185,20 +194,18 @@ export function useColorConvert() {
185
194
  }, [theme, colorConvert]);
186
195
  }
187
196
  export function useBackgroundColorStyle() {
188
- const getBackgroundColor = useCallback((color = '') => {
189
- if (color === 'auto') {
190
- return gradientFromPrimary();
191
- }
192
- return color;
193
- }, []);
197
+ const theme = useTheme();
194
198
  const getBackgroundColorStyle = useCallback((color = '') => {
195
199
  if (color === 'auto') {
196
200
  return { backgroundImage: gradientFromPrimary() };
197
201
  }
202
+ if (color === 'grey25') {
203
+ return { bgcolor: grey25[theme.palette.mode] };
204
+ }
198
205
  if (isGradient(color)) {
199
206
  return { backgroundImage: color };
200
207
  }
201
208
  return { bgcolor: color };
202
- }, []);
203
- return { getBackgroundColorStyle, getBackgroundColor };
209
+ }, [theme]);
210
+ return { getBackgroundColorStyle };
204
211
  }