Summary: _typescript_ Reviewed By: passy, bnelo12 Differential Revision: D16830539 fbshipit-source-id: a44ad0914b2581648b06e421476e0ba31ae96992
46 lines
944 B
TypeScript
46 lines
944 B
TypeScript
/**
|
|
* Copyright 2018-present Facebook.
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
* @format
|
|
*/
|
|
|
|
import styled from 'react-emotion';
|
|
import React, {Component} from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
const ButtonGroupContainer = styled('div')({
|
|
display: 'inline-flex',
|
|
marginLeft: 10,
|
|
'&:first-child': {
|
|
marginLeft: 0,
|
|
},
|
|
});
|
|
|
|
/**
|
|
* Group a series of buttons together.
|
|
*
|
|
* ```jsx
|
|
* <ButtonGroup>
|
|
* <Button>One</Button>
|
|
* <Button>Two</Button>
|
|
* <Button>Three</Button>
|
|
* </ButtonGroup>
|
|
* ```
|
|
*/
|
|
export default class ButtonGroup extends Component<{
|
|
children: React.ReactNode;
|
|
}> {
|
|
static childContextTypes = {
|
|
inButtonGroup: PropTypes.bool,
|
|
};
|
|
|
|
getChildContext() {
|
|
return {inButtonGroup: true};
|
|
}
|
|
|
|
render() {
|
|
return <ButtonGroupContainer>{this.props.children}</ButtonGroupContainer>;
|
|
}
|
|
}
|