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

@adminjs/themes

v1.0.1

Published

Themes let you change the style and default components of your admin panel. There are three elements added to the app by each theme:

Downloads

8,813

Readme

Themes for AdminJS

Themes let you change the style and default components of your admin panel. There are three elements added to the app by each theme:

component overrides - React components that replace a subset of overridable components

theme overrides for @adminjs/design-system - this is merged into the default config, and then user's branding is applied on top

custom CSS styles - a single global CSS file with additional theme styles

Importing Themes in AdminJS

Setup

You can add availableThemes configuration option with an array of theme objects (for example imported from @adminjs/themes package) or themes bundled locally with @adminjs/themes CLI adminjs-themes bundle. The first theme on the list will be active by default. This can be changed with defaultTheme option - specify the ID of a theme - these are usually the same as the named exports.

import AdminJS from 'adminjs'
import { light, dark } from '@adminjs/themes'

new AdminJS({
  defaultTheme: 'dark', // same as `dark` from id in the theme index file,
  availableThemes: [light, dark],
})

Bundle and style paths are taken from @adminjs/themes if the theme is officially supported by library or can be imported from a local path like:

import path from 'path';
import * as url from 'url';

const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

new AdminJS({
  defaultTheme: 'my-custom-theme',
  availableThemes: {
    id: 'my-custom-theme',
    name: 'my custom theme',
    overrides: {
      colors: {
        primary100: '#f00',
      },
    },
    bundlePath: `${path.join(__dirname, `../themes/my-custom-theme`)}/theme.bundle.js`,
    stylePath: `${path.join(__dirname, `../themes/my-custom-theme`)}/style.css`,
  },
});

Full example available in @adminjs/themes example app.

Per-user themes

Additionally, the theme can be configured per-user by returning theme ID in the theme property of the CurrentAdmin object - this should be implemented via the framework plugin, i.e. authenticate function in @adminjs/express. Since you have full control of that object, returned the theme can be selected based on things like user's role or property in the database.

There's no UI control for changing themes, but you can implement this yourself. The general idea is to keep theme ID in the user resource, and add a button that will update the current user record with the selected theme. Alternatively, you can let the user edit their own record and offer a custom select property. Note that for the currentAdmin object to update the user most likely needs to sign in again.

CLI

You can create a new theme using @adminjs/themes cli. After checkout the repository you can register cli on your machine with yarn register:cli. After that, you can use adminjs-themes in your command line.

AdminJS Themes CLI provides commands for:

  • adminjs-themes generate <theme name> - Generating a new theme with the recommended file structure.
  • adminjs-themes bundle - Bundling all themes component overrides. You can pass theme ID as an argument to bundle ssingle theme.

For more information please use the command adminjs-themes bundle --help

Usage

Please see the documentation.

License

AdminJS is copyrighted © 2023 rst.software. It is a free software, and may be redistributed under the terms specified in the LICENSE file.

About rst.software

We’re an open, friendly team that helps clients from all over the world to transform their businesses and create astonishing products.

  • We are available for hire.
  • If you want to work for us - check out the career page.