BlueRain
Github
  • πŸ’§Introduction
  • Overview
    • πŸ“²Quick Start
    • πŸŽ›οΈConfiguration with bluerain.js
    • 🎑Lifecycle Events
    • πŸ›£οΈRoadmap
  • Key Concepts
    • πŸ”ŒPlugins
      • Developing an Analytics Plugin
      • Developing a Logger Plugin
      • Developing a Theme Plugin
    • 🎣Hooks
    • 🎁Components
    • πŸ“¦BlueRain Modules
    • πŸŽ›οΈConfigs
    • πŸ“ˆAnalytics
    • πŸ“”Logger
    • 🎨Themes
      • Installation
      • Consuming Selected Theme
      • Customise Themes
      • Customise Components
      • Theme Configs
      • Theme Structure
    • Registry
  • Guides
    • πŸ—ΏIcons
    • πŸ›‚Migrating from V3
  • Components
    • Typography
    • Icons
      • Icon
      • DynamicIcon πŸ“Œ
      • PluginIcon πŸ“Œ
  • CLI
    • Expo
    • Web
    • Storybook (Web)
    • Storybook Native (Expo)
Powered by GitBook
On this page
  1. Key Concepts
  2. Plugins

Developing a Theme Plugin

PreviousDeveloping a Logger PluginNextHooks

Last updated 6 years ago

A plugin can register any number of themes. To do this simple set the themesΒ property of your plugin class.

class MaterialUIPlugin extends Plugin {

    public themes = [{
        name: 'Material UI (Light)',
        slug: 'material-ui-light',
        mode: 'light',
        
        // .. other theme props
    }, {
        name: 'Material UI (Dark)',
        slug: 'material-ui-dark',
        mode: 'dark',
        
        // .. other theme props
    }]
}

The following guide needs to be added to section.

Each object in the theme property can be a . This mean each theme's code can be split into different bundles on web.

class MaterialUIPlugin extends Plugin {

    public themes = [
		import('path/to/theme-1'),
		import('path/to/theme-2'),
	]
}

Be aware though, that if you use this approach, these bundles will be downloaded during boot time. This is because BlueBase needs know each theme's name and slug to store them in registry.

If you want to split the theme so that they are downloaded only when selected, spilt the internal theme property.

class MaterialUIPlugin extends Plugin {

    public themes = [{
        name: 'Material UI (Light)',
        slug: 'material-ui-light',
        mode: 'light',
        
        theme: import('./theme-rules-light'),

        // .. other theme props
    }, {
        name: 'Material UI (Dark)',
        slug: 'material-ui-dark',
        mode: 'dark',
        
        theme: import('./theme-rules-dark'),
        
        // .. other theme props
    }]
}
πŸ”Œ
Themes
BlueBase Module