rlayers
Version:
React Components for OpenLayers
29 lines • 1.1 kB
JavaScript
import React from 'react';
import { RContext } from '../context';
import { default as RBaseStyle } from './RBaseStyle';
/**
* Background element of a text
*
* Requires an `RText` context
*
* Provides an `RStyle` context - for `Fill` or `Stroke`
*/
export default class RBackground extends RBaseStyle {
create(props) {
this.classProps = RBackground.classProps;
const parent = this.context.style;
if (!parent.setBackgroundFill || !parent.setBackgroundStroke)
/* istanbul ignore next */
throw new Error('Parent element does not support a background');
return {
setFill: parent.setBackgroundFill.bind(parent),
setStroke: parent.setBackgroundStroke.bind(parent)
};
}
render() {
return (React.createElement("div", { className: '_rlayers_RStyle_RBackground' },
React.createElement(RContext.Provider, { value: Object.assign(Object.assign({}, this.context), { style: this.ol }) }, this.props.children)));
}
}
RBackground.classProps = [];
//# sourceMappingURL=RBackground.js.map