npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aws/plugin-aws-apps-demo-for-backstage

v0.3.3

Published

App Development for Backstage.io on AWS - home page and theme demo

Downloads

401

Readme

AWS Apps Demo

AWS Apps Demo is a plugin to demonstrate branding options for a Backstage implementation. It provides a basic Home page with an ability to add customer-specific logo images via logo and logoIcon configuration values.

AWS Apps Demo Home page

Install

# From your Backstage root directory
yarn add --cwd packages/app @aws/[email protected]

Setup

  1. Configure app-config.yaml. See Configuration.

  2. Add the customer theme and sample home page route to the Backstage application. When adding the "<Route ...>", ensure that the "/" root path doesn't conflict with existing routes. If an existing route entry already uses "/", then update the route values across all routes to guarantee uniqueness. Note: Adding a custom theme will override the default themes. If this is the first theme that you are adding to your Backstage configuration, there may be additional modifications required. See https://backstage.io/docs/getting-started/app-custom-theme/#creating-a-custom-theme for more details on additional changes to preserve existing lightTheme and darkTheme values

// packages/app/src/App.tsx
+ import { OPAHomePage, customerTheme } from '@aws/plugin-aws-apps-demo-for-backstage';
+ import { darkTheme, lightTheme } from '@backstage/theme';

  
  const app = createApp({
    ...
    themes: [
+     {
+       id: 'customerTheme',
+       title: 'CUSTOMER',
+       variant: 'light',
+       Provider: ({ children }) => (
+         <ThemeProvider theme={customerTheme}>
+           <CssBaseline>{children}</CssBaseline>
+         </ThemeProvider>
+       ),
+     },
+     // add the default 'light' and 'dark' themes if you wish to continue using them
+     {
+       id: 'light',
+       title: 'Light',
+       variant: 'light',
+       Provider: ({ children }) => (
+         <ThemeProvider theme={lightTheme}>
+           <CssBaseline>{children}</CssBaseline>
+         </ThemeProvider>
+       ),
+     },
+     {
+       id: 'dark',
+       title: 'Dark',
+       variant: 'dark',
+       Provider: ({ children }) => (
+         <ThemeProvider theme={darkTheme}>
+           <CssBaseline>{children}</CssBaseline>
+         </ThemeProvider>
+       ),
+     },
    ...
    ]
  })
  
  const routes = (
    <FlatRoutes>
-     <Route path="/" element={<Navigate to="catalog" />} />
+     <Route path="/" element={<Navigate to="home" />} />
+     <Route path="/home" element={ <OPAHomePage /> } />
      ...
    </FlatRoutes>
  );
  1. Add custom logos and home page link to the Sidebar
// packages/app/src/components/Root.tsx

+ import { useApi } from '@backstage/core-plugin-api';
+ import { AWSLogoFull, AWSLogoIcon, CustomerLogoIcon, CustomerLogoFullLight } from '@aws/plugin-aws-apps-demo-for-backstage';

...

+ function getLogo(themeId: string) {
+   switch (themeId) {
+     case 'customerTheme':
+       return[<CustomerLogoFullLight />, <CustomerLogoIcon />];
+     default:
+       return [<LogoFull />, <LogoIcon />];
+   }
+ }

  const SidebarLogo = () => {
+   const appThemeApi = useApi(appThemeApiRef);
+   const themeId = appThemeApi.getActiveThemeId();
    const classes = useSidebarLogoStyles();
    const { isOpen } = useSidebarOpenState();

+  const [fullLogo, iconLogo] = getLogo(themeId ?? '');

    return (
      <div className={classes.root}>
        <Link to="/" underline="none" className={classes.link} aria-label="Home">
+         {isOpen ? fullLogo : iconLogo}
        </Link>
      </div>
    );
 };

  export const Root = ({ children }: PropsWithChildren<{}>) => (
    <SidebarPage>
      <Sidebar>
        ...
        <SidebarGroup label="Menu" icon={<MenuIcon />}>
+         <SidebarItem icon={HomeIcon} to="/" text="Home" />
          ...
        </SidebarGroup>
      </Sidebar>
    </SidebarPage>
  )

Configuration

AWS Apps Demo has two configuration fields. Each of these fields are optional. If they are not specified, then default values will be used.

  • logo - a URL pointing to an image file to be used on the home page and in the SideBar when it is expanded. The default value will point to an Amazon logo.
  • logoIcon - a URL pointing to an image file to be used in the SideBar when it is collapsed. When the sidebar is collapsed, there is limited space, so this image should be a small image which is roughly square in shape. The default value will point to a small Amazon logo.

Note that you may also need to configure the backend.csp.img-src value to allow for loading images from a remote site.

Example configuration:

// app-config.yaml

app:
  title: Backstage App Suite
  baseUrl: "http://localhost:3000"
  logo: "https://mycompany.com/images/companyLogo.png"
  logoIcon: "https://mycompany.com/images/companyLogo_small.png"

backend:
  csp:
    connect-src: ["'self'", 'http:', 'https:']
    img-src: ["'self'", 'https://mycompany.com']

Next Steps

The home page provided in this plugin is a simple demonstration page. You can modify the OPAHomePage.tsx content to meet your needs. See the Backstage documentation for home page setup and customization for more details on how you can customize your experience: https://backstage.io/docs/getting-started/homepage