@iobroker/gui-components 10.0.5 → 10.0.7

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.
package/build/Theme.d.ts CHANGED
@@ -1,4 +1,38 @@
1
- import type { IobTheme, ThemeName } from './types';
1
+ import { type CSSProperties } from 'react';
2
+ import { type PaletteOptions as PaletteOptionsMui, type ThemeOptions as ThemeOptionsMui } from '@mui/material/styles';
3
+ import type { IobTheme, ThemeName, ThemeType } from './types';
4
+ export interface PaletteOptions extends PaletteOptionsMui {
5
+ mode: ThemeType;
6
+ expert: string;
7
+ nonAck?: string;
8
+ grey?: {
9
+ main?: string;
10
+ dark?: string;
11
+ 50?: string;
12
+ 100?: string;
13
+ 200?: string;
14
+ 300?: string;
15
+ 400?: string;
16
+ 500?: string;
17
+ 600?: string;
18
+ 700?: string;
19
+ 800?: string;
20
+ 900?: string;
21
+ A100?: string;
22
+ A200?: string;
23
+ A400?: string;
24
+ A700?: string;
25
+ };
26
+ }
27
+ export interface ThemeOptions extends ThemeOptionsMui {
28
+ name: ThemeName;
29
+ palette?: PaletteOptions;
30
+ toolbar?: CSSProperties;
31
+ saveToolbar?: {
32
+ background: string;
33
+ button: CSSProperties;
34
+ };
35
+ }
2
36
  /**
3
37
  * The theme creation factory function.
4
38
  */
package/build/Theme.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { createTheme, alpha, } from '@mui/material/styles';
2
2
  import { orange, grey } from '@mui/material/colors';
3
+ import { getModernTheme } from './ThemeModern';
3
4
  const step = (16 - 5) / 23 / 100;
4
5
  /**
5
6
  * Convert hex color in the format '#rrggbb' or '#rgb' to an RGB object.
@@ -67,7 +68,12 @@ function getElevations(color, overlay) {
67
68
  export function Theme(type, overrides) {
68
69
  let options;
69
70
  let localOverrides;
70
- if (type === 'dark') {
71
+ if (type === 'modernDark' || type === 'modernLight') {
72
+ const modern = getModernTheme(type, type === 'modernDark' ? 'dark' : 'light');
73
+ options = modern.options;
74
+ localOverrides = modern.components;
75
+ }
76
+ else if (type === 'dark') {
71
77
  localOverrides = {
72
78
  MuiAppBar: {
73
79
  colorDefault: {
@@ -325,10 +331,10 @@ export function Theme(type, overrides) {
325
331
  },
326
332
  };
327
333
  }
328
- options.toolbar = {
334
+ options.toolbar ||= {
329
335
  height: 48,
330
336
  };
331
- options.saveToolbar = {
337
+ options.saveToolbar ||= {
332
338
  background: options.palette?.primary?.main,
333
339
  button: {
334
340
  borderRadius: 3,
@@ -348,7 +354,10 @@ export function Theme(type, overrides) {
348
354
  components: {
349
355
  ...localOverrides,
350
356
  MuiButton: {
357
+ // do not lose the button overrides of the theme itself (e.g. of the "modern*" themes)
358
+ ...(localOverrides.MuiButton || undefined),
351
359
  variants: [
360
+ ...(localOverrides.MuiButton?.variants || []),
352
361
  {
353
362
  props: { variant: 'contained', color: 'grey' },
354
363
  style: {
@@ -1 +1 @@
1
- {"version":3,"file":"Theme.js","sourceRoot":"./src/","sources":["Theme.tsx"],"names":[],"mappings":"AACA,OAAO,EACH,WAAW,EACX,KAAK,GAIR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAIpD,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC;AAEjC;;GAEG;AACH,SAAS,KAAK,CAAC,GAAW;IACtB,MAAM,GAAG,GAAwC;QAC7C,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,CAAC;KACP,CAAC;IAEF,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1C,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CA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AAW,EACP,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,2BAA2B;gCAClF,eAAe,EAAE,KAAK,CAClB,OAAO,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAC3B,OAAO,CAAC,MAAM,EAAE,YAAY,IAAI,IAAI,CACvC;6BACJ;yBACJ;qBACJ;oBACD;wBACI,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;wBACzC,KAAK,EAAE;4BACH,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO;4BAC5B,SAAS,EAAE;gCACP,eAAe,EAAE,KAAK,CAClB,OAAO,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAC3B,OAAO,CAAC,MAAM,EAAE,YAAY,IAAI,IAAI,CACvC;6BACJ;yBACJ;qBACJ;iBACJ;aACJ;YACD,GAAG,CAAC,SAAS,EAAE,UAAU,IAAI,SAAS,CAAC;SAC1C;KACJ,CAAa,CAAC;AACnB,CAAC","sourcesContent":["import { type CSSProperties } from 'react';\nimport {\n createTheme,\n alpha,\n type PaletteOptions as PaletteOptionsMui,\n type SimplePaletteColorOptions,\n type ThemeOptions as ThemeOptionsMui,\n} from '@mui/material/styles';\nimport { orange, grey } from '@mui/material/colors';\n\nimport type { IobTheme, ThemeName, ThemeType } from './types';\n\nconst step = (16 - 5) / 23 / 100;\n\n/**\n * Convert hex color in the format '#rrggbb' or '#rgb' to an RGB object.\n */\nfunction toInt(hex: string): { r: number; g: number; b: number } {\n const rgb: { r: number; g: number; b: number } = {\n r: 0,\n g: 0,\n b: 0,\n };\n\n if (hex.length === 7) {\n rgb.r = parseInt(hex.substring(1, 3), 16);\n rgb.g = parseInt(hex.substring(3, 5), 16);\n rgb.b = parseInt(hex.substring(5, 7), 16);\n } else if (hex.length === 4) {\n const r = hex[1];\n const g = hex[2];\n const b = hex[3];\n\n rgb.r = parseInt(r + r, 16);\n rgb.g = parseInt(g + g, 16);\n rgb.b = parseInt(b + b, 16);\n }\n\n return rgb;\n}\n\n/**\n * Convert an RGB object to a hex color string in the format '#rrggbb'.\n */\nfunction toHex(int: { r: number; g: number; b: number }): string {\n return `#${Math.round(int.r).toString(16).padStart(2, '0')}${Math.round(int.g).toString(16).padStart(2, '0')}${Math.round(int.b).toString(16).padStart(2, '0')}`;\n}\n\n/** Returns the hex color string in the format '#rrggbb' */\nfunction getElevation(\n /** color in the format '#rrggbb' or '#rgb' */\n color: string,\n /** overlay color in the format '#rrggbb' or '#rgb' */\n overlayColor: string,\n /** elevation as an integer starting with 1 */\n elevation: number,\n): string {\n const rgb: { r: number; g: number; b: number } = toInt(color);\n const overlay: { r: number; g: number; b: number } = toInt(overlayColor);\n\n rgb.r += overlay.r * (0.05 + step * (elevation - 1));\n rgb.g += overlay.g * (0.05 + step * (elevation - 1));\n rgb.b += overlay.b * (0.05 + step * (elevation - 1));\n\n return toHex(rgb);\n}\n\n/**\n * Get all 24 elevations of the given color and overlay.\n *\n * @param color color in the format '#rrggbb' or '#rgb'\n * @param overlay overlay color in the format '#rrggbb' or '#rgb'\n */\nfunction getElevations(color: string, overlay: string): Record<string, CSSProperties> {\n const elevations: Record<string, CSSProperties> = {};\n\n for (let i = 1; i <= 24; i++) {\n elevations[`elevation${i}`] = {\n backgroundColor: getElevation(color, overlay, i),\n };\n }\n\n return elevations;\n}\n\n// const buttonsPalette = () => ({\n// palette: {\n// // mode: \"dark\",\n// grey: {\n// main: grey[300],\n// dark: grey[400],\n// },\n// },\n// });\n\n// const buttonsTheme = theme => ({\n// components: {\n// MuiButton: {\n// variants: [\n// {\n// props: { variant: 'contained', color: 'grey' },\n// style: {\n// color: theme.palette.getContrastText(theme.palette.grey[300]),\n// },\n// },\n// {\n// props: { variant: 'outlined', color: 'grey' },\n// style: {\n// color: theme.palette.text.primary,\n// borderColor:\n// theme.palette.mode === 'light'\n// ? 'rgba(0, 0, 0, 0.23)'\n// : 'rgba(255, 255, 255, 0.23)',\n// '&.Mui-disabled': {\n// border: `1px solid ${theme.palette.action.disabledBackground}`,\n// },\n// '&:hover': {\n// borderColor:\n// theme.palette.mode === 'light'\n// ? 'rgba(0, 0, 0, 0.23)'\n// : 'rgba(255, 255, 255, 0.23)',\n// backgroundColor: alpha(\n// theme.palette.text.primary,\n// theme.palette.action.hoverOpacity,\n// ),\n// },\n// },\n// },\n// {\n// props: { color: 'grey', variant: 'text' },\n// style: {\n// color: 'black',\n// '&:hover': {\n// backgroundColor: alpha(\n// theme.palette.text.primary,\n// theme.palette.action.hoverOpacity,\n// ),\n// },\n// },\n// },\n// ],\n// },\n// },\n// });\n\ninterface PaletteOptions extends PaletteOptionsMui {\n mode: ThemeType;\n expert: string;\n nonAck?: string;\n grey?: {\n main?: string;\n dark?: string;\n 50?: string;\n 100?: string;\n 200?: string;\n 300?: string;\n 400?: string;\n 500?: string;\n 600?: string;\n 700?: string;\n 800?: string;\n 900?: string;\n A100?: string;\n A200?: string;\n A400?: string;\n A700?: string;\n };\n}\n\ninterface ThemeOptions extends ThemeOptionsMui {\n name: ThemeName;\n palette?: PaletteOptions;\n toolbar?: CSSProperties;\n saveToolbar?: {\n background: string;\n button: CSSProperties;\n };\n}\n\n/**\n * The theme creation factory function.\n */\nexport function Theme(type: ThemeName, overrides?: Record<string, any>): IobTheme {\n let options: ThemeOptions;\n let localOverrides: Record<string, any>;\n\n if (type === 'dark') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#272727',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[200],\n '&:hover': {\n color: orange[100],\n },\n },\n },\n MuiPaper: getElevations('#121212', '#fff'),\n };\n\n options = {\n name: type,\n palette: {\n mode: 'dark',\n background: {\n paper: '#121212',\n default: '#121212',\n },\n primary: {\n main: '#4dabf5',\n },\n secondary: {\n main: '#436a93',\n },\n expert: '#14bb00',\n text: {\n primary: '#ffffff',\n secondary: '#ffffff',\n },\n },\n };\n } else if (type === 'blue') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#3399CC',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n };\n\n options = {\n name: type,\n palette: {\n mode: 'dark',\n background: {\n paper: '#151d21',\n default: '#151d21',\n },\n primary: {\n main: '#4dabf5',\n },\n secondary: {\n main: '#436a93',\n },\n expert: '#14bb00',\n text: {\n primary: '#ffffff',\n secondary: '#ffffff',\n },\n },\n };\n } else if (type === 'colored') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#2a3135',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[200],\n '&:hover': {\n color: orange[100],\n },\n },\n },\n MuiPaper: getElevations('#151d21', '#fff'),\n };\n\n options = {\n name: type,\n palette: {\n mode: 'light',\n primary: {\n main: '#3399CC',\n },\n secondary: {\n main: '#164477',\n },\n expert: '#96fc96',\n },\n };\n } else if (type === 'PT') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#0F99DE',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n };\n\n options = {\n name: type,\n palette: {\n mode: 'light',\n primary: {\n main: '#0F99DE',\n },\n secondary: {\n main: '#88A536',\n },\n expert: '#BD1B24',\n },\n };\n } else if (type === 'NW') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#272727',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n MuiPaper: getElevations('#121212', '#fff'),\n };\n\n options = {\n name: type,\n palette: {\n mode: 'dark',\n background: {\n paper: '#121212',\n default: '#121212',\n },\n primary: {\n main: '#00af78',\n },\n secondary: {\n main: '#005a40',\n },\n expert: '#14bb00',\n text: {\n primary: '#ffffff',\n secondary: '#ffffff',\n },\n },\n };\n } else if (type === 'HA') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#272727',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: '#db0a33',\n '&:hover': {\n color: '#FF0a33',\n },\n },\n },\n MuiPaper: getElevations('#121212', '#fff'),\n };\n\n options = {\n name: type,\n palette: {\n mode: 'dark',\n background: {\n paper: '#121212',\n default: '#121212',\n },\n primary: {\n main: '#970720',\n },\n secondary: {\n main: '#db0a33',\n },\n expert: '#db0a33',\n nonAck: '#ffe96a',\n text: {\n primary: '#ffffff',\n secondary: '#ffffff',\n },\n },\n };\n } else {\n localOverrides = {\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n };\n\n options = {\n name: type,\n palette: {\n mode: 'light',\n primary: {\n main: '#3399CC',\n dark: '#256c97',\n light: '#76d0fd',\n },\n secondary: {\n main: '#164477',\n },\n expert: '#14bb00',\n },\n };\n }\n\n options.toolbar = {\n height: 48,\n };\n\n options.saveToolbar = {\n background: (options.palette?.primary as SimplePaletteColorOptions)?.main,\n button: {\n borderRadius: 3,\n height: 32,\n },\n };\n\n if (options.palette) {\n options.palette.grey = {\n main: grey[300],\n dark: grey[400],\n };\n }\n\n const theme: IobTheme = createTheme(options) as IobTheme;\n\n const palette: PaletteOptions = theme.palette;\n\n return createTheme(theme, {\n ...(overrides || undefined),\n components: {\n ...localOverrides,\n MuiButton: {\n variants: [\n {\n props: { variant: 'contained', color: 'grey' },\n style: {\n backgroundColor: palette.grey?.[300],\n color:\n palette.getContrastText && palette.grey?.[300]\n ? palette.getContrastText(palette.grey[300])\n : undefined,\n },\n },\n {\n props: { variant: 'outlined', color: 'grey' },\n style: {\n color: palette.text?.primary,\n borderColor: palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)',\n '&.Mui-disabled': {\n border: `1px solid ${palette.action?.disabledBackground}`,\n },\n '&:hover': {\n borderColor:\n palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)',\n backgroundColor: alpha(\n palette.text?.primary || '',\n palette.action?.hoverOpacity || 0.04,\n ),\n },\n },\n },\n {\n props: { variant: 'text', color: 'grey' },\n style: {\n color: palette.text?.primary,\n '&:hover': {\n backgroundColor: alpha(\n palette.text?.primary || '',\n palette.action?.hoverOpacity || 0.04,\n ),\n },\n },\n },\n ],\n },\n ...(overrides?.components || undefined),\n },\n }) as IobTheme;\n}\n"]}
1
+ {"version":3,"file":"Theme.js","sourceRoot":"./src/","sources":["Theme.tsx"],"names":[],"mappings":"AACA,OAAO,EACH,WAAW,EACX,KAAK,GAIR,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,IAAI,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,GAAG,CAAC;AAEjC;;GAEG;AACH,SAAS,KAAK,CAAC,GAAW;IACtB,MAAM,GAAG,GAAwC;QAC7C,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,CAAC;KACP,CAAC;IAEF,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC1C,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,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5C,CAAC,CAAC,SAAS;yBACtB;qBACJ;oBACD;wBACI,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE;wBAC7C,KAAK,EAAE;4BACH,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO;4BAC5B,WAAW,EAAE,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,2BAA2B;4BAC3F,gBAAgB,EAAE;gCACd,MAAM,EAAE,aAAa,OAAO,CAAC,MAAM,EAAE,kBAAkB,EAAE;6BAC5D;4BACD,SAAS,EAAE;gCACP,WAAW,EACP,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,2BAA2B;gCAClF,eAAe,EAAE,KAAK,CAClB,OAAO,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAC3B,OAAO,CAAC,MAAM,EAAE,YAAY,IAAI,IAAI,CACvC;6BACJ;yBACJ;qBACJ;oBACD;wBACI,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE;wBACzC,KAAK,EAAE;4BACH,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO;4BAC5B,SAAS,EAAE;gCACP,eAAe,EAAE,KAAK,CAClB,OAAO,CAAC,IAAI,EAAE,OAAO,IAAI,EAAE,EAC3B,OAAO,CAAC,MAAM,EAAE,YAAY,IAAI,IAAI,CACvC;6BACJ;yBACJ;qBACJ;iBACJ;aACJ;YACD,GAAG,CAAC,SAAS,EAAE,UAAU,IAAI,SAAS,CAAC;SAC1C;KACJ,CAAa,CAAC;AACnB,CAAC","sourcesContent":["import { type CSSProperties } from 'react';\nimport {\n createTheme,\n alpha,\n type PaletteOptions as PaletteOptionsMui,\n type SimplePaletteColorOptions,\n type ThemeOptions as ThemeOptionsMui,\n} from '@mui/material/styles';\nimport { orange, grey } from '@mui/material/colors';\n\nimport type { IobTheme, ThemeName, ThemeType } from './types';\nimport { getModernTheme } from './ThemeModern';\n\nconst step = (16 - 5) / 23 / 100;\n\n/**\n * Convert hex color in the format '#rrggbb' or '#rgb' to an RGB object.\n */\nfunction toInt(hex: string): { r: number; g: number; b: number } {\n const rgb: { r: number; g: number; b: number } = {\n r: 0,\n g: 0,\n b: 0,\n };\n\n if (hex.length === 7) {\n rgb.r = parseInt(hex.substring(1, 3), 16);\n rgb.g = parseInt(hex.substring(3, 5), 16);\n rgb.b = parseInt(hex.substring(5, 7), 16);\n } else if (hex.length === 4) {\n const r = hex[1];\n const g = hex[2];\n const b = hex[3];\n\n rgb.r = parseInt(r + r, 16);\n rgb.g = parseInt(g + g, 16);\n rgb.b = parseInt(b + b, 16);\n }\n\n return rgb;\n}\n\n/**\n * Convert an RGB object to a hex color string in the format '#rrggbb'.\n */\nfunction toHex(int: { r: number; g: number; b: number }): string {\n return `#${Math.round(int.r).toString(16).padStart(2, '0')}${Math.round(int.g).toString(16).padStart(2, '0')}${Math.round(int.b).toString(16).padStart(2, '0')}`;\n}\n\n/** Returns the hex color string in the format '#rrggbb' */\nfunction getElevation(\n /** color in the format '#rrggbb' or '#rgb' */\n color: string,\n /** overlay color in the format '#rrggbb' or '#rgb' */\n overlayColor: string,\n /** elevation as an integer starting with 1 */\n elevation: number,\n): string {\n const rgb: { r: number; g: number; b: number } = toInt(color);\n const overlay: { r: number; g: number; b: number } = toInt(overlayColor);\n\n rgb.r += overlay.r * (0.05 + step * (elevation - 1));\n rgb.g += overlay.g * (0.05 + step * (elevation - 1));\n rgb.b += overlay.b * (0.05 + step * (elevation - 1));\n\n return toHex(rgb);\n}\n\n/**\n * Get all 24 elevations of the given color and overlay.\n *\n * @param color color in the format '#rrggbb' or '#rgb'\n * @param overlay overlay color in the format '#rrggbb' or '#rgb'\n */\nfunction getElevations(color: string, overlay: string): Record<string, CSSProperties> {\n const elevations: Record<string, CSSProperties> = {};\n\n for (let i = 1; i <= 24; i++) {\n elevations[`elevation${i}`] = {\n backgroundColor: getElevation(color, overlay, i),\n };\n }\n\n return elevations;\n}\n\n// const buttonsPalette = () => ({\n// palette: {\n// // mode: \"dark\",\n// grey: {\n// main: grey[300],\n// dark: grey[400],\n// },\n// },\n// });\n\n// const buttonsTheme = theme => ({\n// components: {\n// MuiButton: {\n// variants: [\n// {\n// props: { variant: 'contained', color: 'grey' },\n// style: {\n// color: theme.palette.getContrastText(theme.palette.grey[300]),\n// },\n// },\n// {\n// props: { variant: 'outlined', color: 'grey' },\n// style: {\n// color: theme.palette.text.primary,\n// borderColor:\n// theme.palette.mode === 'light'\n// ? 'rgba(0, 0, 0, 0.23)'\n// : 'rgba(255, 255, 255, 0.23)',\n// '&.Mui-disabled': {\n// border: `1px solid ${theme.palette.action.disabledBackground}`,\n// },\n// '&:hover': {\n// borderColor:\n// theme.palette.mode === 'light'\n// ? 'rgba(0, 0, 0, 0.23)'\n// : 'rgba(255, 255, 255, 0.23)',\n// backgroundColor: alpha(\n// theme.palette.text.primary,\n// theme.palette.action.hoverOpacity,\n// ),\n// },\n// },\n// },\n// {\n// props: { color: 'grey', variant: 'text' },\n// style: {\n// color: 'black',\n// '&:hover': {\n// backgroundColor: alpha(\n// theme.palette.text.primary,\n// theme.palette.action.hoverOpacity,\n// ),\n// },\n// },\n// },\n// ],\n// },\n// },\n// });\n\nexport interface PaletteOptions extends PaletteOptionsMui {\n mode: ThemeType;\n expert: string;\n nonAck?: string;\n grey?: {\n main?: string;\n dark?: string;\n 50?: string;\n 100?: string;\n 200?: string;\n 300?: string;\n 400?: string;\n 500?: string;\n 600?: string;\n 700?: string;\n 800?: string;\n 900?: string;\n A100?: string;\n A200?: string;\n A400?: string;\n A700?: string;\n };\n}\n\nexport interface ThemeOptions extends ThemeOptionsMui {\n name: ThemeName;\n palette?: PaletteOptions;\n toolbar?: CSSProperties;\n saveToolbar?: {\n background: string;\n button: CSSProperties;\n };\n}\n\n/**\n * The theme creation factory function.\n */\nexport function Theme(type: ThemeName, overrides?: Record<string, any>): IobTheme {\n let options: ThemeOptions;\n let localOverrides: Record<string, any>;\n\n if (type === 'modernDark' || type === 'modernLight') {\n const modern = getModernTheme(type, type === 'modernDark' ? 'dark' : 'light');\n options = modern.options;\n localOverrides = modern.components;\n } else if (type === 'dark') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#272727',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[200],\n '&:hover': {\n color: orange[100],\n },\n },\n },\n MuiPaper: getElevations('#121212', '#fff'),\n };\n\n options = {\n name: type,\n palette: {\n mode: 'dark',\n background: {\n paper: '#121212',\n default: '#121212',\n },\n primary: {\n main: '#4dabf5',\n },\n secondary: {\n main: '#436a93',\n },\n expert: '#14bb00',\n text: {\n primary: '#ffffff',\n secondary: '#ffffff',\n },\n },\n };\n } else if (type === 'blue') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#3399CC',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n };\n\n options = {\n name: type,\n palette: {\n mode: 'dark',\n background: {\n paper: '#151d21',\n default: '#151d21',\n },\n primary: {\n main: '#4dabf5',\n },\n secondary: {\n main: '#436a93',\n },\n expert: '#14bb00',\n text: {\n primary: '#ffffff',\n secondary: '#ffffff',\n },\n },\n };\n } else if (type === 'colored') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#2a3135',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[200],\n '&:hover': {\n color: orange[100],\n },\n },\n },\n MuiPaper: getElevations('#151d21', '#fff'),\n };\n\n options = {\n name: type,\n palette: {\n mode: 'light',\n primary: {\n main: '#3399CC',\n },\n secondary: {\n main: '#164477',\n },\n expert: '#96fc96',\n },\n };\n } else if (type === 'PT') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#0F99DE',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n };\n\n options = {\n name: type,\n palette: {\n mode: 'light',\n primary: {\n main: '#0F99DE',\n },\n secondary: {\n main: '#88A536',\n },\n expert: '#BD1B24',\n },\n };\n } else if (type === 'NW') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#272727',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n MuiPaper: getElevations('#121212', '#fff'),\n };\n\n options = {\n name: type,\n palette: {\n mode: 'dark',\n background: {\n paper: '#121212',\n default: '#121212',\n },\n primary: {\n main: '#00af78',\n },\n secondary: {\n main: '#005a40',\n },\n expert: '#14bb00',\n text: {\n primary: '#ffffff',\n secondary: '#ffffff',\n },\n },\n };\n } else if (type === 'HA') {\n localOverrides = {\n MuiAppBar: {\n colorDefault: {\n backgroundColor: '#272727',\n },\n },\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: '#db0a33',\n '&:hover': {\n color: '#FF0a33',\n },\n },\n },\n MuiPaper: getElevations('#121212', '#fff'),\n };\n\n options = {\n name: type,\n palette: {\n mode: 'dark',\n background: {\n paper: '#121212',\n default: '#121212',\n },\n primary: {\n main: '#970720',\n },\n secondary: {\n main: '#db0a33',\n },\n expert: '#db0a33',\n nonAck: '#ffe96a',\n text: {\n primary: '#ffffff',\n secondary: '#ffffff',\n },\n },\n };\n } else {\n localOverrides = {\n MuiLink: {\n root: {\n textTransform: 'uppercase',\n transition: 'color .3s ease',\n color: orange[400],\n '&:hover': {\n color: orange[300],\n },\n },\n },\n };\n\n options = {\n name: type,\n palette: {\n mode: 'light',\n primary: {\n main: '#3399CC',\n dark: '#256c97',\n light: '#76d0fd',\n },\n secondary: {\n main: '#164477',\n },\n expert: '#14bb00',\n },\n };\n }\n\n options.toolbar ||= {\n height: 48,\n };\n\n options.saveToolbar ||= {\n background: (options.palette?.primary as SimplePaletteColorOptions)?.main,\n button: {\n borderRadius: 3,\n height: 32,\n },\n };\n\n if (options.palette) {\n options.palette.grey = {\n main: grey[300],\n dark: grey[400],\n };\n }\n\n const theme: IobTheme = createTheme(options) as IobTheme;\n\n const palette: PaletteOptions = theme.palette;\n\n return createTheme(theme, {\n ...(overrides || undefined),\n components: {\n ...localOverrides,\n MuiButton: {\n // do not lose the button overrides of the theme itself (e.g. of the \"modern*\" themes)\n ...(localOverrides.MuiButton || undefined),\n variants: [\n ...(localOverrides.MuiButton?.variants || []),\n {\n props: { variant: 'contained', color: 'grey' },\n style: {\n backgroundColor: palette.grey?.[300],\n color:\n palette.getContrastText && palette.grey?.[300]\n ? palette.getContrastText(palette.grey[300])\n : undefined,\n },\n },\n {\n props: { variant: 'outlined', color: 'grey' },\n style: {\n color: palette.text?.primary,\n borderColor: palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)',\n '&.Mui-disabled': {\n border: `1px solid ${palette.action?.disabledBackground}`,\n },\n '&:hover': {\n borderColor:\n palette.mode === 'light' ? 'rgba(0, 0, 0, 0.23)' : 'rgba(255, 255, 255, 0.23)',\n backgroundColor: alpha(\n palette.text?.primary || '',\n palette.action?.hoverOpacity || 0.04,\n ),\n },\n },\n },\n {\n props: { variant: 'text', color: 'grey' },\n style: {\n color: palette.text?.primary,\n '&:hover': {\n backgroundColor: alpha(\n palette.text?.primary || '',\n palette.action?.hoverOpacity || 0.04,\n ),\n },\n },\n },\n ],\n },\n ...(overrides?.components || undefined),\n },\n }) as IobTheme;\n}\n"]}
@@ -0,0 +1,53 @@
1
+ import type { ThemeName, ThemeType } from './types';
2
+ import type { ThemeOptions } from './Theme';
3
+ /**
4
+ * Flat design tokens of the "modern" themes.
5
+ * Everything that is used more than once in the theme definition below is listed here,
6
+ * so a new variation can be created by copying this object only.
7
+ */
8
+ export interface ModernTokens {
9
+ /** Background of the page (behind the cards) */
10
+ background: string;
11
+ /** Background of cards, tables and dialogs */
12
+ paper: string;
13
+ /** Background of the left navigation */
14
+ sidebar: string;
15
+ /** Background of menus, popovers and dialogs (one step above `paper`) */
16
+ elevated: string;
17
+ /** Color of the dividers inside of the cards (table rows, lists) */
18
+ border: string;
19
+ /** Border of the cards. In the dark theme the cards are separated by the background, not by a border */
20
+ cardBorder: string;
21
+ textPrimary: string;
22
+ textSecondary: string;
23
+ textDisabled: string;
24
+ primary: string;
25
+ primaryDark: string;
26
+ primaryLight: string;
27
+ secondary: string;
28
+ /** Background of the selected navigation item */
29
+ gradient: string;
30
+ /** Background of the selected navigation item if hovered */
31
+ gradientHover: string;
32
+ success: string;
33
+ warning: string;
34
+ error: string;
35
+ info: string;
36
+ /** Color of the expert-mode elements */
37
+ expert: string;
38
+ /** Color of the not acknowledged values in the object browser */
39
+ nonAck: string;
40
+ /** Background of the hovered rows and list items */
41
+ hover: string;
42
+ /** Background of the selected rows and list items */
43
+ selected: string;
44
+ }
45
+ export declare const MODERN_DARK: ModernTokens;
46
+ export declare const MODERN_LIGHT: ModernTokens;
47
+ /**
48
+ * Options and component overrides of the "modern" themes (`modernDark` and `modernLight`).
49
+ */
50
+ export declare function getModernTheme(name: ThemeName, type: ThemeType): {
51
+ options: ThemeOptions;
52
+ components: Record<string, any>;
53
+ };