Skip to content

Commit

Permalink
added missing file ./src/themes.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Eiten committed May 10, 2017
1 parent f932471 commit ef6dc23
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/themes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict';

// This file creates the Hypergrid theme registry, exposed as `Hypergrid.themes` (see).
// The initial registry consists of a single theme ('default').
// Application developers can add additional themes to this registry.

var defaults = require('./defaults');

var styles = [
'BackgroundColor',
'Color',
'Font'
];

var styleWithHalign = styles.concat([
'Halign'
]);

var dataCellStyles = styleWithHalign.concat([
'cellPadding',
'iconPadding'
]);

var stylers = [
{ prefix: '', props: dataCellStyles },
{ prefix: 'foregroundSelection', props: styles },
{ prefix: 'columnHeader', props: styleWithHalign },
{ prefix: 'columnHeaderForegroundSelection', props: styles },
{ prefix: 'rowHeader', props: styles },
{ prefix: 'rowHeaderForegroundSelection', props: styles }
];

var defaultTheme = {
themeName: defaults.themeName
};

// Here we create the `defaults` theme by copying over the theme props,
// which is a subset of all the props defined in defaults.js. The following
// combines the above prefixes with their styles to get theme prop names; and
// then copies those props from the defaults.js to create the `default` theme.
module.exports.default = stylers.reduce(function(theme, styler) {
return styler.props.reduce(function(theme, prop) {
prop = styler.prefix + prop;
prop = prop.replace('ForegroundSelectionBackground', 'BackgroundSelection');
prop = prop[0].toLowerCase() + prop.substr(1);
theme[prop] = defaults[prop];
return theme;
}, theme);
}, defaultTheme);

0 comments on commit ef6dc23

Please sign in to comment.