-
Notifications
You must be signed in to change notification settings - Fork 9
Module Configuration
- Overview
- Accessing configuration
- Configuring a modifier
- Configuring a component
- Passing CSS to modules/components
- Dynamic utility values
- Special values
A module's default configuration is defined in a module JSON file (e.g. ui/modules/accordion/accordion.json) and can be modified at each level up-to the app
level, with higher levels taking precedence:
-
{module}.json
(lowest precedence) theme.json
UI.json
-
app.json
(highest precedence)
To edit a module's default configuration, change the values within its JSON file (e.g. ui/modules/accordion/accordion.json):
{
"accordion": {
...
}
}
To edit a module for a certain theme, pass the modified values within your theme's JSON file (e.g. ui/themes/One-Nexus/theme.json):
{
"theme": {
"accordion": {
...
}
}
}
To enforce module configurations for all themes, pass the values within your UI's JSON file (e.g. ui/ui.json):
{
"ui": {
"modules": {
"accordion": {
...
}
}
}
}
To enforce module configurations for all UIs, pass the values to your app's JSON file (e.g. app.json):
{
"app": {
"ui": {
"modules": {
"accordion": {
...
}
}
}
}
}
A module's configuration is accessible from its corresponding .scss
, .js
and .jsx
files:
Use the this()
helper function to get a module's configuration value:
@import 'accordion.json';
@mixin accordion($custom: custom('accordion')) {
// Configuration
$accordion: config($accordion, $custom);
// `$accordion` returns the merged configuration from all levels
$value: this('key') // equivalent to `$value: map-get($accordion, 'key')`;
...
}
import * as UI from '../../../ui';
import defaults from './accordion.json';
function accordion(custom) {
const TARGET = UI.getTarget('accordion', defaults, custom);
UI.Synergy(TARGET, (accordion, options) => {
// `options` returns the merged configuration from all levels
}, defaults, custom, UI.evalConfig);
...
}
import defaults from './accordion.json';
class Accordion extends React.Component {
componentWillMount() {
this.config = global.UI.config.accordion;
}
render() {
// `this.config` returns the merged configuration from all levels
...
}
}