@backstage/theme 0.3.0 → 0.4.0-next.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @backstage/theme
2
2
 
3
+ ## 0.4.0-next.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1fd38bc4141a: **MUI v5 Support:** Adding platform-wide support for MUI v5 allowing a transition phase for migrating central plugins & components over. We still support v4 instances & plugins by adding a
8
+
9
+ To allow the future support of plugins & components using MUI v5 you want to upgrade your `AppTheme`'s to using the `UnifiedThemeProvider`
10
+
11
+ ```diff
12
+ Provider: ({ children }) => (
13
+ - <ThemeProvider theme={lightTheme}>
14
+ - <CssBaseline>{children}</CssBaseline>
15
+ - </ThemeProvider>
16
+ + <UnifiedThemeProvider theme={builtinThemes.light} children={children} />
17
+ ),
18
+ ```
19
+
3
20
  ## 0.3.0
4
21
 
5
22
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -1,6 +1,21 @@
1
- import { Theme, ThemeOptions } from '@material-ui/core';
2
- import { Palette, PaletteOptions } from '@material-ui/core/styles/createPalette';
3
1
  import { Overrides } from '@material-ui/core/styles/overrides';
2
+ import { ComponentsProps } from '@material-ui/core/styles/props';
3
+ import { Theme, ThemeOptions, PaletteOptions as PaletteOptions$1 } from '@mui/material/styles';
4
+ import { ThemeOptions as ThemeOptions$1 } from '@material-ui/core/styles';
5
+ import { PaletteOptions, Palette } from '@material-ui/core/styles/createPalette';
6
+ import { ReactNode } from 'react';
7
+ import * as _material_ui_core from '@material-ui/core';
8
+ import { ThemeOptions as ThemeOptions$2, Theme as Theme$1 } from '@material-ui/core';
9
+
10
+ /**
11
+ * Transform MUI v5 component themes into a v4 theme props and overrides.
12
+ *
13
+ * @public
14
+ */
15
+ declare function transformV5ComponentThemesToV4(theme: Theme, components?: ThemeOptions['components']): {
16
+ overrides: Overrides;
17
+ props: ComponentsProps;
18
+ };
4
19
 
5
20
  /**
6
21
  * Backstage specific additions to the material-ui palette.
@@ -72,108 +87,155 @@ type BackstagePaletteAdditions = {
72
87
  };
73
88
  };
74
89
  /**
75
- * The full Backstage palette.
76
- *
77
- * @public
78
- */
79
- type BackstagePalette = Palette & BackstagePaletteAdditions;
80
- /**
81
- * The full Backstage palette options.
90
+ * Selector for what page theme to use.
82
91
  *
83
92
  * @public
84
93
  */
85
- type BackstagePaletteOptions = PaletteOptions & BackstagePaletteAdditions;
94
+ type PageThemeSelector = {
95
+ themeId: string;
96
+ };
86
97
  /**
87
- * Selector for what page theme to use.
98
+ * The theme definitions for a given layout page.
88
99
  *
89
100
  * @public
90
101
  */
91
- type PageThemeSelector = {
92
- themeId: string;
102
+ type PageTheme = {
103
+ colors: string[];
104
+ shape: string;
105
+ backgroundImage: string;
106
+ fontColor: string;
93
107
  };
94
108
  /**
95
- * A Backstage theme.
109
+ * Backstage specific additions to the material-ui theme.
96
110
  *
97
111
  * @public
98
112
  */
99
- interface BackstageTheme extends Theme {
100
- palette: BackstagePalette;
113
+ type BackstageThemeAdditions = {
101
114
  page: PageTheme;
102
115
  getPageTheme: (selector: PageThemeSelector) => PageTheme;
103
- }
116
+ };
117
+
104
118
  /**
105
- * Backstage theme options.
119
+ * A container of one theme for multiple different MUI versions.
106
120
  *
107
- * @public
108
- * @remarks
109
- *
110
- * This is essentially a partial theme definition made by the user, that then
111
- * gets merged together with defaults and other values to form the final
112
- * {@link BackstageTheme}.
121
+ * Currently known keys are 'v4' and 'v5'.
113
122
  *
123
+ * @public
114
124
  */
115
- interface BackstageThemeOptions extends ThemeOptions {
116
- palette: BackstagePaletteOptions;
117
- page: PageTheme;
118
- getPageTheme: (selector: PageThemeSelector) => PageTheme;
125
+ interface UnifiedTheme {
126
+ getTheme(version: string): unknown | undefined;
119
127
  }
128
+
120
129
  /**
121
- * A simpler configuration for creating a new theme that just tweaks some parts
122
- * of the backstage one.
130
+ * Options for creating a new {@link UnifiedTheme}.
123
131
  *
124
132
  * @public
125
133
  */
126
- type SimpleThemeOptions = {
127
- palette: BackstagePaletteOptions;
128
- defaultPageTheme: string;
134
+ interface UnifiedThemeOptions {
135
+ palette: PaletteOptions & PaletteOptions$1;
136
+ defaultPageTheme?: string;
129
137
  pageTheme?: Record<string, PageTheme>;
130
138
  fontFamily?: string;
131
139
  htmlFontSize?: number;
132
- };
140
+ components?: ThemeOptions['components'];
141
+ }
133
142
  /**
134
- * The theme definitions for a given layout page.
143
+ * Creates a new {@link UnifiedTheme} using the provided options.
135
144
  *
136
145
  * @public
137
146
  */
138
- type PageTheme = {
139
- colors: string[];
140
- shape: string;
141
- backgroundImage: string;
142
- fontColor: string;
143
- };
144
-
147
+ declare function createUnifiedTheme(options: UnifiedThemeOptions): UnifiedTheme;
145
148
  /**
146
- * The default Backstage light theme.
149
+ * Creates a new {@link UnifiedTheme} using MUI v4 theme options.
150
+ * Note that this uses `adaptV4Theme` from MUI v5, which is deprecated.
147
151
  *
148
152
  * @public
149
153
  */
150
- declare const lightTheme: BackstageTheme;
154
+ declare function createUnifiedThemeFromV4(options: ThemeOptions$1): UnifiedTheme;
155
+
151
156
  /**
152
- * The default Backstage dark theme.
157
+ * Built-in Backstage MUI themes.
153
158
  *
154
159
  * @public
155
160
  */
156
- declare const darkTheme: BackstageTheme;
161
+ declare const themes: {
162
+ light: UnifiedTheme;
163
+ dark: UnifiedTheme;
164
+ };
157
165
 
158
166
  /**
159
- * A helper for creating theme options.
167
+ * Props for {@link UnifiedThemeProvider}.
160
168
  *
161
169
  * @public
162
170
  */
163
- declare function createThemeOptions(options: SimpleThemeOptions): BackstageThemeOptions;
171
+ interface UnifiedThemeProviderProps {
172
+ children: ReactNode;
173
+ theme: UnifiedTheme;
174
+ noCssBaseline?: boolean;
175
+ }
164
176
  /**
165
- * A helper for creating theme overrides.
177
+ * Provides themes for all MUI versions supported by the provided unified theme.
166
178
  *
167
179
  * @public
168
180
  */
169
- declare function createThemeOverrides(theme: BackstageTheme): Overrides;
181
+ declare function UnifiedThemeProvider(props: UnifiedThemeProviderProps): JSX.Element;
182
+
183
+ /**
184
+ * Options for {@link createBaseThemeOptions}.
185
+ *
186
+ * @public
187
+ */
188
+ interface BaseThemeOptionsInput<PaletteOptions> {
189
+ palette: PaletteOptions;
190
+ defaultPageTheme?: string;
191
+ pageTheme?: Record<string, PageTheme>;
192
+ fontFamily?: string;
193
+ htmlFontSize?: number;
194
+ }
170
195
  /**
171
- * Creates a Backstage MUI theme using a palette. The theme is created with the
172
- * common Backstage options and component styles.
196
+ * A helper for creating theme options.
173
197
  *
174
198
  * @public
175
199
  */
176
- declare function createTheme(options: SimpleThemeOptions): BackstageTheme;
200
+ declare function createBaseThemeOptions<PaletteOptions>(options: BaseThemeOptionsInput<PaletteOptions>): {
201
+ palette: PaletteOptions;
202
+ typography: {
203
+ htmlFontSize: number;
204
+ fontFamily: string;
205
+ h1: {
206
+ fontSize: number;
207
+ fontWeight: number;
208
+ marginBottom: number;
209
+ };
210
+ h2: {
211
+ fontSize: number;
212
+ fontWeight: number;
213
+ marginBottom: number;
214
+ };
215
+ h3: {
216
+ fontSize: number;
217
+ fontWeight: number;
218
+ marginBottom: number;
219
+ };
220
+ h4: {
221
+ fontWeight: number;
222
+ fontSize: number;
223
+ marginBottom: number;
224
+ };
225
+ h5: {
226
+ fontWeight: number;
227
+ fontSize: number;
228
+ marginBottom: number;
229
+ };
230
+ h6: {
231
+ fontWeight: number;
232
+ fontSize: number;
233
+ marginBottom: number;
234
+ };
235
+ };
236
+ page: PageTheme;
237
+ getPageTheme: ({ themeId }: PageThemeSelector) => PageTheme;
238
+ };
177
239
 
178
240
  /**
179
241
  * The default predefined burst shapes.
@@ -221,4 +283,287 @@ declare function genPageTheme(props: {
221
283
  */
222
284
  declare const pageTheme: Record<string, PageTheme>;
223
285
 
224
- export { BackstagePalette, BackstagePaletteAdditions, BackstagePaletteOptions, BackstageTheme, BackstageThemeOptions, PageTheme, PageThemeSelector, SimpleThemeOptions, colorVariants, createTheme, createThemeOptions, createThemeOverrides, darkTheme, genPageTheme, lightTheme, pageTheme, shapes };
286
+ /**
287
+ * Built-in Backstage color palettes.
288
+ *
289
+ * @public
290
+ */
291
+ declare const palettes: {
292
+ light: {
293
+ type: "light";
294
+ mode: "light";
295
+ background: {
296
+ default: string;
297
+ paper: string;
298
+ };
299
+ status: {
300
+ ok: string;
301
+ warning: string;
302
+ error: string;
303
+ running: string;
304
+ pending: string;
305
+ aborted: string;
306
+ };
307
+ bursts: {
308
+ fontColor: string;
309
+ slackChannelText: string;
310
+ backgroundColor: {
311
+ default: string;
312
+ };
313
+ gradient: {
314
+ linear: string;
315
+ };
316
+ };
317
+ primary: {
318
+ main: string;
319
+ };
320
+ banner: {
321
+ info: string;
322
+ error: string;
323
+ text: string;
324
+ link: string;
325
+ closeButtonColor: string;
326
+ warning: string;
327
+ };
328
+ border: string;
329
+ textContrast: string;
330
+ textVerySubtle: string;
331
+ textSubtle: string;
332
+ highlight: string;
333
+ errorBackground: string;
334
+ warningBackground: string;
335
+ infoBackground: string;
336
+ errorText: string;
337
+ infoText: string;
338
+ warningText: string;
339
+ linkHover: string;
340
+ link: string;
341
+ gold: string;
342
+ navigation: {
343
+ background: string;
344
+ indicator: string;
345
+ color: string;
346
+ selectedColor: string;
347
+ navItem: {
348
+ hoverBackground: string;
349
+ };
350
+ submenu: {
351
+ background: string;
352
+ };
353
+ };
354
+ pinSidebarButton: {
355
+ icon: string;
356
+ background: string;
357
+ };
358
+ tabbar: {
359
+ indicator: string;
360
+ };
361
+ };
362
+ dark: {
363
+ type: "dark";
364
+ mode: "dark";
365
+ background: {
366
+ default: string;
367
+ paper: string;
368
+ };
369
+ status: {
370
+ ok: string;
371
+ warning: string;
372
+ error: string;
373
+ running: string;
374
+ pending: string;
375
+ aborted: string;
376
+ };
377
+ bursts: {
378
+ fontColor: string;
379
+ slackChannelText: string;
380
+ backgroundColor: {
381
+ default: string;
382
+ };
383
+ gradient: {
384
+ linear: string;
385
+ };
386
+ };
387
+ primary: {
388
+ main: string;
389
+ dark: string;
390
+ };
391
+ secondary: {
392
+ main: string;
393
+ };
394
+ banner: {
395
+ info: string;
396
+ error: string;
397
+ text: string;
398
+ link: string;
399
+ closeButtonColor: string;
400
+ warning: string;
401
+ };
402
+ border: string;
403
+ textContrast: string;
404
+ textVerySubtle: string;
405
+ textSubtle: string;
406
+ highlight: string;
407
+ errorBackground: string;
408
+ warningBackground: string;
409
+ infoBackground: string;
410
+ errorText: string;
411
+ infoText: string;
412
+ warningText: string;
413
+ linkHover: string;
414
+ link: string;
415
+ gold: string;
416
+ navigation: {
417
+ background: string;
418
+ indicator: string;
419
+ color: string;
420
+ selectedColor: string;
421
+ navItem: {
422
+ hoverBackground: string;
423
+ };
424
+ submenu: {
425
+ background: string;
426
+ };
427
+ };
428
+ pinSidebarButton: {
429
+ icon: string;
430
+ background: string;
431
+ };
432
+ tabbar: {
433
+ indicator: string;
434
+ };
435
+ };
436
+ };
437
+
438
+ /**
439
+ * The old MUI v4 Backstage light theme.
440
+ *
441
+ * @public
442
+ * @deprecated Use {@link themes.light} instead.
443
+ */
444
+ declare const lightTheme: _material_ui_core.Theme;
445
+ /**
446
+ * The old MUI v4 Backstage dark theme.
447
+ *
448
+ * @public
449
+ * @deprecated Use {@link themes.dark} instead.
450
+ */
451
+ declare const darkTheme: _material_ui_core.Theme;
452
+
453
+ /**
454
+ * The full Backstage palette.
455
+ *
456
+ * @public
457
+ * @deprecated This type is deprecated, the MUI Palette type is now always extended instead.
458
+ */
459
+ type BackstagePalette = Palette & BackstagePaletteAdditions;
460
+ /**
461
+ * The full Backstage palette options.
462
+ *
463
+ * @public
464
+ * @deprecated This type is deprecated, the MUI PaletteOptions type is now always extended instead.
465
+ */
466
+ type BackstagePaletteOptions = PaletteOptions & BackstagePaletteAdditions;
467
+ /**
468
+ * Backstage theme options.
469
+ *
470
+ * @public
471
+ * @deprecated This type is deprecated, the MUI ThemeOptions type is now always extended instead.
472
+ * @remarks
473
+ *
474
+ * This is essentially a partial theme definition made by the user, that then
475
+ * gets merged together with defaults and other values to form the final
476
+ * {@link BackstageTheme}.
477
+ *
478
+ */
479
+ interface BackstageThemeOptions extends ThemeOptions$2 {
480
+ palette: BackstagePaletteOptions;
481
+ page: PageTheme;
482
+ getPageTheme: (selector: PageThemeSelector) => PageTheme;
483
+ }
484
+ /**
485
+ * A Backstage theme.
486
+ *
487
+ * @public
488
+ * @deprecated This type is deprecated, the MUI Theme type is now always extended instead.
489
+ */
490
+ interface BackstageTheme extends Theme$1 {
491
+ palette: BackstagePalette;
492
+ page: PageTheme;
493
+ getPageTheme: (selector: PageThemeSelector) => PageTheme;
494
+ }
495
+ /**
496
+ * A simpler configuration for creating a new theme that just tweaks some parts
497
+ * of the backstage one.
498
+ *
499
+ * @public
500
+ * @deprecated Use {@link BaseThemeOptionsInput} instead.
501
+ */
502
+ type SimpleThemeOptions = {
503
+ palette: PaletteOptions;
504
+ defaultPageTheme?: string;
505
+ pageTheme?: Record<string, PageTheme>;
506
+ fontFamily?: string;
507
+ htmlFontSize?: number;
508
+ };
509
+ declare module '@material-ui/core/styles/createPalette' {
510
+ interface Palette extends BackstagePaletteAdditions {
511
+ }
512
+ interface PaletteOptions extends BackstagePaletteAdditions {
513
+ }
514
+ }
515
+ declare module '@material-ui/core/styles/createTheme' {
516
+ interface Theme extends BackstageThemeAdditions {
517
+ }
518
+ interface ThemeOptions extends BackstageThemeAdditions {
519
+ }
520
+ }
521
+
522
+ /**
523
+ * An old helper for creating MUI v4 theme options.
524
+ *
525
+ * @public
526
+ * @deprecated Use {@link createBaseThemeOptions} instead.
527
+ */
528
+ declare function createThemeOptions(options: SimpleThemeOptions): ThemeOptions$2;
529
+ /**
530
+ * * An old helper for creating MUI v4 theme overrides.
531
+ *
532
+ * @public
533
+ * @deprecated Use {@link defaultComponentThemes} with {@link transformV5ComponentThemesToV4} instead.
534
+ */
535
+ declare function createThemeOverrides(theme: Theme$1): Overrides;
536
+ /**
537
+ * The old method to create a Backstage MUI v4 theme using a palette.
538
+ * The theme is created with the common Backstage options and component styles.
539
+ *
540
+ * @public
541
+ * @deprecated Use {@link createUnifiedTheme} instead.
542
+ */
543
+ declare function createTheme(options: SimpleThemeOptions): Theme$1;
544
+
545
+ declare module '@mui/material/styles' {
546
+ interface Palette extends BackstagePaletteAdditions {
547
+ }
548
+ interface PaletteOptions extends BackstagePaletteAdditions {
549
+ }
550
+ }
551
+ declare module '@mui/material/styles' {
552
+ interface Theme extends BackstageThemeAdditions {
553
+ }
554
+ interface ThemeOptions extends BackstageThemeAdditions {
555
+ }
556
+ }
557
+ declare module '@mui/private-theming/defaultTheme' {
558
+ interface DefaultTheme extends Theme {
559
+ }
560
+ }
561
+
562
+ /**
563
+ * A helper for creating theme overrides.
564
+ *
565
+ * @public
566
+ */
567
+ declare const defaultComponentThemes: ThemeOptions['components'];
568
+
569
+ export { BackstagePalette, BackstagePaletteAdditions, BackstagePaletteOptions, BackstageTheme, BackstageThemeAdditions, BackstageThemeOptions, BaseThemeOptionsInput, PageTheme, PageThemeSelector, SimpleThemeOptions, UnifiedTheme, UnifiedThemeOptions, UnifiedThemeProvider, UnifiedThemeProviderProps, colorVariants, createBaseThemeOptions, createTheme, createThemeOptions, createThemeOverrides, createUnifiedTheme, createUnifiedThemeFromV4, darkTheme, defaultComponentThemes, genPageTheme, lightTheme, pageTheme, palettes, shapes, themes, transformV5ComponentThemesToV4 };