Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | 1x 1x 1x 11x 2x 2x 2x 22x 1x 22x 2x 2x 1x 1x 1x 9x 2x 2x 2x 18x 1x 18x 2x 2x 1x | import React, {Component} from 'react'
import PropTypes from 'prop-types'
import classNames from 'classnames'
const PARENT_CLASS_NAMES = {
stackForSmall: ['stack-for-small', 'rev-MediaObject--stackForSmall'],
stackForMedium: ['stack-for-medium', 'rev-MediaObject--stackForMedium'],
stackForLarge: ['stack-for-large', 'rev-MediaObject--stackForLarge'],
right: ['align-right', 'rev-MediaObject--right'],
center: ['align-center', 'rev-MediaObject--center'],
justify: ['align-justify', 'rev-MediaObject--justify'],
spaced: ['align-spaced', 'rev-MediaObject--spaced'],
top: ['align-top', 'rev-MediaObject--top'],
middle: ['middle', 'align-middle', 'rev-MediaObject--middle'],
bottom: ['bottom', 'align-bottom', 'rev-MediaObject--bottom'],
stretch: ['align-stretch', 'rev-MediaObject--stretch'],
}
const PARENT_PROP_TYPES = {
className: PropTypes.string,
children: PropTypes.node,
}
Object.keys(PARENT_CLASS_NAMES).forEach(
(key) => (PARENT_PROP_TYPES[key] = PropTypes.bool)
)
export default class MediaObject extends Component {
static propTypes = PARENT_PROP_TYPES
render() {
// Extract props that won't pass through
const {className, children, ...props} = this.props
// Start building the className
const classNameList = []
Object.keys(PARENT_CLASS_NAMES).forEach((name) => {
if (props[name]) {
classNameList.push(PARENT_CLASS_NAMES[name])
}
delete props[name]
})
// Finish building the className
const mediaObjectClassNames = classNames(
classNameList,
'media-object',
'rev-MediaObject',
className
)
return (
<div {...props} className={mediaObjectClassNames}>
{children}
</div>
)
}
}
const SECTION_CLASS_NAMES = {
main: ['main-section', 'rev-MediaObject-section--main'],
right: ['align-self-right', 'rev-MediaObject-section--right'],
center: ['align-self-center', 'rev-MediaObject-section--center'],
justify: ['align-self-justify', 'rev-MediaObject-section--justify'],
spaced: ['align-self-spaced', 'rev-MediaObject-section--spaced'],
top: ['align-self-top', 'rev-MediaObject-section--top'],
middle: ['middle', 'align-self-middle', 'rev-MediaObject-section--middle'],
bottom: ['bottom', 'align-self-bottom', 'rev-MediaObject-section--bottom'],
stretch: ['align-self-stretch', 'rev-MediaObject-section--stretch'],
}
const SECTION_PROP_TYPES = {
className: PropTypes.string,
children: PropTypes.node,
}
Object.keys(SECTION_CLASS_NAMES).forEach((key) => {
SECTION_PROP_TYPES[key] = PropTypes.bool
})
class MediaObjectSection extends Component {
static propTypes = SECTION_PROP_TYPES
render() {
// Extract props that won't pass through
const {className, children, ...props} = this.props
// Start building the className
const classNameList = []
Object.keys(SECTION_CLASS_NAMES).forEach((name) => {
if (props[name]) {
classNameList.push(SECTION_CLASS_NAMES[name])
}
delete props[name]
})
// Finish building the className
const sectionClassNames = classNames(
classNameList,
'media-object-section',
'rev-MediaObject-section',
className
)
return (
<div {...props} className={sectionClassNames}>
{children}
</div>
)
}
}
MediaObject.Section = MediaObjectSection
|