Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions workspaces/theme/.changeset/graduate-nfs-alpha-to-stable.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@red-hat-developer-hub/backstage-plugin-theme': major
---

**BREAKING**: Graduated the New Frontend System (NFS) theme module to stable API.

The NFS `rhdhThemeModule` has been promoted from the `./alpha` subpath to the primary `.` entry point. The `./alpha` subpath has been removed. Legacy (OFS) exports (`getThemes`, `getAllThemes`, `LogoFull`, `LogoIcon`, etc.) have been moved to the new `./legacy` subpath.

**Migration for NFS consumers (previously using `./alpha`):**

```diff
- import { rhdhThemeModule } from '@red-hat-developer-hub/backstage-plugin-theme/alpha';
+ import { rhdhThemeModule } from '@red-hat-developer-hub/backstage-plugin-theme';
```

**Migration for OFS consumers:**

```diff
- import { getThemes, LogoFull } from '@red-hat-developer-hub/backstage-plugin-theme';
+ import { getThemes, LogoFull } from '@red-hat-developer-hub/backstage-plugin-theme/legacy';
```
2 changes: 1 addition & 1 deletion workspaces/theme/packages/app-legacy/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import { BCCTestPage } from '@red-hat-developer-hub/backstage-plugin-bcc-test';
import { BUITestPage } from '@red-hat-developer-hub/backstage-plugin-bui-test';
import { MUI4TestPage } from '@red-hat-developer-hub/backstage-plugin-mui4-test';
import { MUI5TestPage } from '@red-hat-developer-hub/backstage-plugin-mui5-test';
import { getAllThemes } from '@red-hat-developer-hub/backstage-plugin-theme';
import { getAllThemes } from '@red-hat-developer-hub/backstage-plugin-theme/legacy';

const app = createApp({
apis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { NotificationsSidebarItem } from '@backstage/plugin-notifications';
import {
LogoFull,
LogoIcon,
} from '@red-hat-developer-hub/backstage-plugin-theme';
} from '@red-hat-developer-hub/backstage-plugin-theme/legacy';

const SidebarLogo = () => {
const { isOpen } = useSidebarOpenState();
Expand Down
2 changes: 1 addition & 1 deletion workspaces/theme/packages/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import { createApp } from '@backstage/frontend-defaults';
import { navModule } from './modules';
import { rhdhThemeModule } from '@red-hat-developer-hub/backstage-plugin-theme/alpha';
import { rhdhThemeModule } from '@red-hat-developer-hub/backstage-plugin-theme';

export default createApp({
features: [navModule, rhdhThemeModule],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const SidebarContent = NavContentBlueprint.make({

// Skipped items
nav.take('page:search'); // Using search modal instead
nav.take('page:notifications'); // Using NotificationsSidebarItem instead

return (
<Sidebar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Box from '@mui/material/Box';
import {
LogoFull,
LogoIcon,
} from '@red-hat-developer-hub/backstage-plugin-theme';
} from '@red-hat-developer-hub/backstage-plugin-theme/legacy';

export const SidebarLogo = () => {
const { isOpen } = useSidebarOpenState();
Expand Down
23 changes: 20 additions & 3 deletions workspaces/theme/plugins/theme/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ a [Storybook test-runner](https://github.com/storybookjs/test-runner) for automa

## API

### Legacy (OFS) — `@red-hat-developer-hub/backstage-plugin-theme/legacy`

Returns all testable themes (incl. the backstage default color scheme and older RHDH versions):

- `getAllThemes: () => AppTheme[]`
Expand All @@ -19,6 +21,21 @@ Returns the latest, not released RHDH light and dark theme for your backstage/RH
- `useThemes: () => AppTheme[]`
- `useLoaderTheme: () => MUIv5.Theme`

### New Frontend System (NFS)

NFS is the primary package entry point. OFS (legacy) theme helpers are available at `./legacy`.

Register the theme module in an NFS app:

```tsx
import { createApp } from '@backstage/frontend-defaults';
import { rhdhThemeModule } from '@red-hat-developer-hub/backstage-plugin-theme';

export default createApp({
features: [rhdhThemeModule /* ...other features */],
});
```

## Install dependencies

```shell
Expand Down Expand Up @@ -46,7 +63,7 @@ On older RHDH instances you can install it:
2. In `packages/app/src/components/DynamicRoot/DynamicRoot.tsx`

```tsx
import { useThemes } from '@red-hat-developer-hub/backstage-plugin-theme';
import { useThemes } from '@red-hat-developer-hub/backstage-plugin-theme/legacy';

// ...

Expand All @@ -73,7 +90,7 @@ On older RHDH instances you can install it:
2. Update `packages/app/src/App.tsx` and apply the themes to `createApp`:

```tsx
import { getThemes } from '@red-hat-developer-hub/backstage-plugin-theme';
import { getThemes } from '@red-hat-developer-hub/backstage-plugin-theme/legacy';

// ...

Expand All @@ -94,7 +111,7 @@ On older RHDH instances you can install it:
2. Add to your `*/dev/index.tsx`:

```tsx
import { getAllThemes } from '@red-hat-developer-hub/backstage-plugin-theme';
import { getAllThemes } from '@red-hat-developer-hub/backstage-plugin-theme/legacy';

// ...

Expand Down
2 changes: 1 addition & 1 deletion workspaces/theme/plugins/theme/dev/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import {
SidebarSignOutButton,
} from '@backstage/dev-utils';

import { rhdhThemeModule } from '../src/alpha';
import { rhdhThemeModule } from '../src';
import { ThemeTestPage } from './ThemeTestPage';

const rootRouteRef = createRouteRef({
Expand Down
2 changes: 1 addition & 1 deletion workspaces/theme/plugins/theme/dev/legacy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { createDevApp } from '@backstage/dev-utils';
import { getAllThemes } from '../src';
import { getAllThemes } from '../src/legacyExports';
import { ThemeTestPage } from './ThemeTestPage';

createDevApp()
Expand Down
10 changes: 7 additions & 3 deletions workspaces/theme/plugins/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
],
"exports": {
".": "./src/index.ts",
"./alpha": "./src/alpha/index.ts",
"./legacy": "./src/legacyExports.ts",
"./rhdh-theme-module": "./src/rhdhThemeModuleExport.ts",
"./package.json": "./package.json"
},
"typesVersions": {
"*": {
"alpha": [
"src/alpha/index.ts"
"legacy": [
"src/legacyExports.ts"
],
"rhdh-theme-module": [
"src/rhdhThemeModuleExport.ts"
],
"package.json": [
"package.json"
Expand Down
205 changes: 205 additions & 0 deletions workspaces/theme/plugins/theme/report-legacy.api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
## API Report File for "@red-hat-developer-hub/backstage-plugin-theme"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts
import { AppTheme } from '@backstage/core-plugin-api';
import { default as DarkIcon } from '@mui/icons-material/Brightness2Rounded';
import { JSX as JSX_2 } from 'react/jsx-runtime';
import { default as LightIcon } from '@mui/icons-material/WbSunnyRounded';
import { ReactNode } from 'react';
import { Theme } from '@mui/material';
import { UnifiedThemeOptions } from '@backstage/theme';

// @public (undocumented)
export type BackstageThemePalette = UnifiedThemeOptions['palette'];

// @public (undocumented)
export interface Branding {
// (undocumented)
theme?: {
[key: string]: ThemeConfig;
};
}

// @public (undocumented)
export interface Config {
// (undocumented)
app: {
branding?: Branding;
};
}

export { DarkIcon };

// @public (undocumented)
export const darkThemeProvider: (props: {
children: ReactNode;
}) => JSX.Element | null;

// @public (undocumented)
export const getAllThemes: () => AppTheme[];

// @public (undocumented)
export const getThemes: () => AppTheme[];

export { LightIcon };

// @public (undocumented)
export const lightThemeProvider: (props: {
children: ReactNode;
}) => JSX.Element | null;

// @public (undocumented)
export const LogoFull: (props: React.ComponentProps<'svg'>) => JSX_2.Element;

// @public (undocumented)
export const LogoIcon: (props: React.ComponentProps<'svg'>) => JSX_2.Element;

// @public (undocumented)
export interface RHDHThemePalette {
// (undocumented)
cards?: {
headerTextColor: string;
headerBackgroundColor: string;
headerBackgroundImage: string;
};
// (undocumented)
general: {
pageInset: string;
pageInsetBackgroundColor: string;
disabled: string;
disabledBackground: string;
paperBackgroundImage: string;
paperBorderColor: string;
popoverBoxShadow: string;
cardBackgroundColor: string;
cardBorderColor: string;
mainSectionBackgroundColor: string;
formControlBackgroundColor: string;
sidebarBackgroundColor: string;
sidebarDividerColor: string;
sidebarItemSelectedBackgroundColor: string;
tableTitleColor: string;
tableSubtitleColor: string;
tableColumnTitleColor: string;
tableRowHover: string;
tableBorderColor: string;
tableBackgroundColor: string;
tabsLinkHoverBackgroundColor: string;
contrastText: string;
appBarBackgroundScheme: 'light' | 'dark';
appBarBackgroundColor: string;
appBarForegroundColor: string;
appBarBackgroundImage: string;
starredItemsColor: string;
};
// (undocumented)
primary: {
main: string;
focusVisibleBorder: string;
};
// (undocumented)
secondary: {
main: string;
focusVisibleBorder: string;
};
}

// @public (undocumented)
export interface ThemeConfig {
// (undocumented)
defaultPageTheme?: string;
// (undocumented)
fontFamily?: UnifiedThemeOptions['fontFamily'];
// (undocumented)
htmlFontSize?: UnifiedThemeOptions['htmlFontSize'];
mode?: 'light' | 'dark';
// (undocumented)
options?: ThemeConfigOptions;
// (undocumented)
pageTheme?: Record<string, ThemeConfigPageTheme>;
// (undocumented)
palette?: ThemeConfigPalette;
// (undocumented)
typography?: UnifiedThemeOptions['typography'];
variant?: 'rhdh' | 'backstage';
}

// @public (undocumented)
export interface ThemeConfigOptions {
// (undocumented)
accordions?: 'patternfly' | 'mui';
// (undocumented)
appBar?: 'patternfly' | 'mui';
// (undocumented)
breadcrumbs?: 'patternfly' | 'mui';
// (undocumented)
buttons?: 'patternfly' | 'mui';
// (undocumented)
cards?: 'patternfly' | 'mui';
// (undocumented)
checkbox?: 'patternfly' | 'mui';
// (undocumented)
components?: 'rhdh' | 'backstage' | 'mui';
// (undocumented)
dialogs?: 'patternfly' | 'mui';
// (undocumented)
headers?: 'patternfly' | 'mui';
// (undocumented)
inputs?: 'patternfly' | 'mui';
// (undocumented)
pages?: 'patternfly' | 'mui';
// (undocumented)
paper?: 'patternfly' | 'mui';
// (undocumented)
rippleEffect?: 'on' | 'off';
// (undocumented)
sidebars?: 'patternfly' | 'mui';
// (undocumented)
tables?: 'patternfly' | 'mui';
// (undocumented)
tabs?: 'patternfly' | 'mui';
// (undocumented)
toolbars?: 'patternfly' | 'mui';
}

// @public (undocumented)
export interface ThemeConfigPageTheme {
// (undocumented)
backgroundColor?: string | string[];
// (undocumented)
backgroundImage?: string;
// (undocumented)
colors?: string | string[];
// (undocumented)
fontColor?: string;
// (undocumented)
shape?: string;
}

// @public (undocumented)
export type ThemeConfigPalette = BackstageThemePalette & {
rhdh?: RHDHThemePalette;
};

// @public (undocumented)
export const useAllThemes: () => AppTheme[];

// @public (undocumented)
export const useBranding: () => Branding | undefined;

// @public (undocumented)
export const useLoaderTheme: () => Theme;

// @public (undocumented)
export const useThemeConfig: (themeName: string) => ThemeConfig;

// @public
export const useThemeOptions: (themeConfig: ThemeConfig) => UnifiedThemeOptions;

// @public (undocumented)
export const useThemes: () => AppTheme[];

// (No @packageDocumentation comment for this package)
```
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
```ts
import { FrontendModule } from '@backstage/frontend-plugin-api';

// @public (undocumented)
export const rhdhThemeModule: FrontendModule;
// @public
const rhdhThemeModule: FrontendModule;
export default rhdhThemeModule;

// (No @packageDocumentation comment for this package)
```
Loading
Loading