/
s.js
41 lines (37 loc) · 1.02 KB
/
s.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React, { Component, PropTypes } from "react";
import Radium from "radium";
@Radium
class S extends Component {
render() {
let styles = {};
if (this.props.type.indexOf("strikethrough") !== -1) {
styles = Object.assign(styles, {textDecoration: "line-through"});
}
if (this.props.type.indexOf("underline") !== -1) {
styles = Object.assign(styles, {textDecoration: "underline"});
}
if (this.props.type.indexOf("bold") !== -1) {
styles = Object.assign(styles, {fontWeight: "bold"});
}
if (this.props.type.indexOf("italic") !== -1) {
styles = Object.assign(styles, {fontStyle: "italic"});
}
return (
<span style={[styles, this.context.styles.components.s[this.props.type], this.props.style]}>
{this.props.children}
</span>
);
}
}
S.propTypes = {
children: PropTypes.node,
style: PropTypes.object,
type: PropTypes.oneOfType([
PropTypes.string,
PropTypes.array
])
};
S.contextTypes = {
styles: PropTypes.object
};
export default S;