|
10 | 10 |
|
11 | 11 | import * as React from 'react'; |
12 | 12 | import { ChangeEvent, FunctionComponent, ReactElement, ReactNode, useContext, useEffect, useState, useRef } from 'react'; |
13 | | -import { Typography, Box, Theme, Container, Link, Avatar, Paper, Badge, SxProps, Tabs, Tab, Stack, useTheme, PaletteMode } from '@mui/material'; |
| 13 | +import { |
| 14 | + Typography, Box, Theme, Container, Link, Avatar, Paper, Badge, SxProps, Tabs, Tab, Stack, useTheme, PaletteMode, |
| 15 | + decomposeColor |
| 16 | +} from '@mui/material'; |
14 | 17 | import { Link as RouteLink, useNavigate, useParams } from 'react-router-dom'; |
15 | 18 | import SaveAltIcon from '@mui/icons-material/SaveAlt'; |
16 | 19 | import VerifiedUserIcon from '@mui/icons-material/VerifiedUser'; |
@@ -217,8 +220,19 @@ export const ExtensionDetail: FunctionComponent = () => { |
217 | 220 | const renderExtension = (extension: Extension): ReactNode => { |
218 | 221 | const tab = versionPointsToTab(version) ? version as string : 'overview'; |
219 | 222 | const themeType = (extension.galleryTheme || pageSettings.themeType) ?? 'light'; |
220 | | - const headerColor = extension.galleryColor || theme.palette.neutral[themeType] as string; |
| 223 | + const fallbackColor = theme.palette.neutral[themeType] as string; |
| 224 | + let headerColor = extension.galleryColor || fallbackColor; |
| 225 | + |
| 226 | + try { |
| 227 | + // check if the color string can be decomposed, i.e. if mui understands it, otherwise |
| 228 | + // fall back to the neutral color of the used palette. |
| 229 | + decomposeColor(headerColor); |
| 230 | + } catch (error) { |
| 231 | + headerColor = fallbackColor; |
| 232 | + } |
| 233 | + |
221 | 234 | const headerTextColor = theme.palette.getContrastText(headerColor); |
| 235 | + |
222 | 236 | return <> |
223 | 237 | <Box |
224 | 238 | sx={{ |
|
0 commit comments