forked from cypress-io/cypress
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPost.js
More file actions
39 lines (34 loc) · 924 Bytes
/
Post.js
File metadata and controls
39 lines (34 loc) · 924 Bytes
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
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import Skeleton from 'react-loading-skeleton'
import { getRandomNumber } from './calc'
export default class Post extends Component {
static propTypes = {
title: PropTypes.string,
children: PropTypes.node,
size: PropTypes.oneOf(['small', 'large']),
}
static defaultProps = {
size: 'small',
}
getStyle () {
const { size } = this.props
const baseStyle = {
padding: 8,
width: '20em',
}
return Object.assign(baseStyle, {
fontSize: size === 'small' ? 16 : 25,
lineHeight: size === 'small' ? 'normal' : 2,
})
}
render () {
return (
<div style={this.getStyle()}>
<h1>{this.props.title || <Skeleton />}</h1>
<p>{this.props.children || <Skeleton count={5} />}</p>
<p className="random">random id {getRandomNumber()}</p>
</div>
)
}
}