Skip to content

Instantly share code, notes, and snippets.

@ojame
Last active November 5, 2015 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ojame/393ca07cff4586e0f0f8 to your computer and use it in GitHub Desktop.
Save ojame/393ca07cff4586e0f0f8 to your computer and use it in GitHub Desktop.
import React, {Component, PropTypes} from 'react';
import cx from 'classnames';
import styles from './wherever';
export default class Heading extends Component {
static propTypes = {
level: PropTypes.oneOf(1, 2, 3, 4, 5, 6).isRequired,
theme: PropTypes.oneOf('macropod', 'bugherd'),
};
render() {
this.tag = 'h' + this.props.level;
const headingClass = {
[styles[this.tag]]: true,
[styles[theme]]: this.props.theme,
};
return (
<this.tag className={headingClass} {...this.props}>{ this.props.children }</this.tag>
)
}
}
.bugherd {
color: yellow;
}
.h1 {
font-size: 100px;
}
.h2 {
font-size: 80px;
}
.h3 {
font-size: 60px;
}
.h4 {
font-size: 40px;
}
.h5 {
font-size: 20px;
}
.h5 {
font-size: 10px;
}
import React, {Component, PropTypes} from 'react';
import {Heading} from './blobs';
export default class Telephone extends Component {
render() {
return (
<div>
<Heading level={1}>First Heading</Heading>
<Heading level={2} theme="bugherd">Yellow Second Heading</Heading>
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment