Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implemented shaded variant button group #2027

Merged
merged 2 commits into from
Nov 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/ButtonGroup/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { BaseProps } from '../types';

export interface ButtonGroupProps extends BaseProps {
children?: ReactNode;
variant?: 'default' | 'shaded';
}

export default function(props: ButtonGroupProps): JSX.Element | null;
8 changes: 6 additions & 2 deletions src/components/ButtonGroup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import StyledContainer from './styled/container';
* Button groups are used to bunch together buttons with similar actions
*/
export default function ButtonGroup(props) {
const { className, style, children } = props;
const { className, style, children, variant } = props;

return (
<StyledContainer className={className} style={style} role="group">
<StyledContainer className={className} style={style} role="group" variant={variant}>
{children}
</StyledContainer>
);
Expand All @@ -23,10 +23,14 @@ ButtonGroup.propTypes = {
className: PropTypes.string,
/** An object with custom style applied to the outer element. */
style: PropTypes.object,
/** The variant changes the appearance of the ButtonGroup. Accepted variants include default,
* and shaded. This value defaults to default. */
variant: PropTypes.oneOf(['default', 'shaded']),
};

ButtonGroup.defaultProps = {
children: null,
className: undefined,
style: undefined,
variant: 'default',
};
14 changes: 14 additions & 0 deletions src/components/ButtonGroup/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,17 @@ const socials = [
</Content>
</Container>
```
##### button group with shaded variant

```js
import React from 'react';
import { ButtonGroup, Button } from 'react-rainbow-components';

<div className="rainbow-p-vertical_large rainbow-align-content_center rainbow-flex_wrap">
<ButtonGroup className="rainbow-m-around_medium" variant='shaded'>
<Button label="Refresh" variant="neutral" />
<Button label="Edit" variant="neutral" />
<Button label="Save" variant="neutral" />
</ButtonGroup>
</div>
```
31 changes: 30 additions & 1 deletion src/components/ButtonGroup/styled/container.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* stylelint-disable no-descending-specificity */
import styled from 'styled-components';
import attachThemeAttrs from '../../../styles/helpers/attachThemeAttrs';

const StyledContainer = styled.div`
const StyledContainer = attachThemeAttrs(styled.div)`
display: inline-flex;

button {
Expand Down Expand Up @@ -32,6 +33,34 @@ const StyledContainer = styled.div`
> div:only-child > button {
border-radius: 100px;
}

${props =>
props.variant === 'shaded' &&
`
box-shadow: ${props.shadows.shadow_10};
background-color: ${props.palette.background.main};
border-radius: 100px;
> label:last-child > div {
display: none;
}
button {
border: none;
&::after {
content: '';
position: absolute;
right: 1px;
height: 20px;
width: 1px;
background-color: ${props.palette.border.divider};
box-sizing: border-box;
}
}
button:last-of-type {
&::after {
content: none;
}
}
`}
`;

export default StyledContainer;