-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
59 changed files
with
2,540 additions
and
133 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 |
---|---|---|
|
@@ -14,4 +14,5 @@ web/.project | |
_site | ||
.sass-cache | ||
.jekyll-metadata | ||
*.lock | ||
*.lock | ||
docs/developer-guide/reference/ |
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
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
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
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
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
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,46 @@ | ||
/** | ||
* Copyright 2017, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
const React = require('react'); | ||
const withSideEffect = require('react-side-effect'); | ||
|
||
const reducePropsToState = (props) => { | ||
const innermostProps = props[props.length - 1]; | ||
if (innermostProps) { | ||
return {theme: innermostProps.theme || 'default', themeElement: innermostProps.themeElement || 'theme_stylesheet'}; | ||
} | ||
return null; | ||
}; | ||
|
||
const handleStateChangeOnClient = (themeCfg) => { | ||
if (themeCfg) { | ||
const link = document.getElementById(themeCfg.themeElement); | ||
if (link && themeCfg.theme) { | ||
const basePath = link.href && link.href.substring(0, link.href.lastIndexOf("/")); | ||
link.setAttribute('href', basePath + "/" + themeCfg.theme + ".css"); | ||
} | ||
} | ||
}; | ||
|
||
const Theme = React.createClass({ | ||
propTypes: { | ||
theme: React.PropTypes.string.isRequired | ||
}, | ||
getDefaultProps() { | ||
return { | ||
theme: 'default' | ||
}; | ||
}, | ||
render() { | ||
if (this.props.children) { | ||
return React.Children.only(this.props.children); | ||
} | ||
return null; | ||
} | ||
}); | ||
|
||
module.exports = withSideEffect(reducePropsToState, handleStateChangeOnClient)(Theme); |
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,48 @@ | ||
/** | ||
* Copyright 2017, GeoSolutions Sas. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const React = require('react'); | ||
const {head} = require('lodash'); | ||
const {FormGroup, Label, FormControl} = require('react-bootstrap'); | ||
const Message = require('../I18N/Message'); | ||
|
||
const ThemeSwitcher = React.createClass({ | ||
propTypes: { | ||
themes: React.PropTypes.array, | ||
selectedTheme: React.PropTypes.object, | ||
onThemeSelected: React.PropTypes.func, | ||
style: React.PropTypes.object | ||
}, | ||
getDefaultProps() { | ||
return { | ||
onThemeSelected: () => {}, | ||
style: { | ||
width: "300px", | ||
margin: "20px auto" | ||
} | ||
}; | ||
}, | ||
|
||
onChangeTheme(themeId) { | ||
const theme = head(this.props.themes.filter((t) => t.id === themeId)); | ||
this.props.onThemeSelected(theme); | ||
}, | ||
render() { | ||
return ( | ||
<FormGroup className="theme-switcher" style={this.props.style} bsSize="small"> | ||
<Label><Message msgId="manager.theme_combo"/></Label> | ||
<FormControl | ||
value={this.props.selectedTheme && this.props.selectedTheme.id} | ||
componentClass="select" ref="mapType" onChange={(e) => this.onChangeTheme(e.target.value)}> | ||
{this.props.themes.map( (t) => <option key={t.id} value={t.id}>{t.label || t.id}</option>)} | ||
</FormControl> | ||
</FormGroup>); | ||
} | ||
}); | ||
|
||
module.exports = ThemeSwitcher; |
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
Binary file not shown.
Oops, something went wrong.