-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jonathan Eiten
committed
May 10, 2017
1 parent
f932471
commit ef6dc23
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |