|
1 | | -import React from 'react'; |
2 | 1 | import styled from 'styled-components'; |
3 | 2 | import { borderRadius4 } from '../utilities/borderRadius'; |
4 | 3 | import { Neutral } from '../utilities/colors'; |
5 | 4 | import { space8 } from '../utilities/spacing'; |
6 | 5 |
|
7 | | -export interface ButtonGroupProps |
8 | | - extends React.HtmlHTMLAttributes<HTMLDivElement> { |
9 | | - segmented?: boolean; |
10 | | - fullWidth?: boolean; |
11 | | -} |
12 | | - |
13 | | -export const ButtonGroup = styled.div` |
| 6 | +export const StyledButtonGroup = styled.div` |
14 | 7 | display: flex; |
15 | 8 | flex-direction: row; |
16 | 9 | align-items: center; |
17 | 10 | padding: 0px; |
18 | | - ${({ segmented }: ButtonGroupProps) => |
19 | | - segmented |
20 | | - ? `> button { |
21 | | - border-radius: 0; |
22 | | - border-right: 0; |
23 | | - |
24 | | - :nth-child(1) { |
25 | | - border-radius: ${borderRadius4} 0px 0px ${borderRadius4}; |
26 | | - } |
27 | | -
|
28 | | - :nth-last-child(1) { |
29 | | - border-radius: 0px ${borderRadius4} ${borderRadius4} 0px; |
30 | | - border-right: 1px solid ${Neutral.B68} |
31 | | - } |
32 | | - } |
33 | | - > button:focus { |
34 | | - z-index: 1; |
35 | | - border: 1px solid ${Neutral.B68} |
36 | | - } |
37 | | -
|
38 | | - button[data-active='true'] { |
39 | | - border: 1px solid ${Neutral.B40} |
40 | | - } |
41 | | - ` |
42 | | - : `gap: ${space8};`} |
43 | | - ${({ fullWidth }: ButtonGroupProps) => |
44 | | - fullWidth |
45 | | - ? `> button { |
46 | | - flex: 1; |
47 | | - }` |
48 | | - : ``} |
| 11 | + gap: ${space8}; |
| 12 | +
|
| 13 | + &[data-segmented='true'] { |
| 14 | + gap: 0; |
| 15 | + } |
| 16 | +
|
| 17 | + &[data-segmented='true'] button[data-active='true'] { |
| 18 | + border: 1px solid ${Neutral.B40}; |
| 19 | + } |
| 20 | +
|
| 21 | + &[data-segmented='true'] button { |
| 22 | + border-radius: 0; |
| 23 | + border-right: 0; |
| 24 | +
|
| 25 | + :nth-child(1) { |
| 26 | + border-radius: ${borderRadius4} 0px 0px ${borderRadius4}; |
| 27 | + } |
| 28 | +
|
| 29 | + :nth-last-child(1) { |
| 30 | + border-radius: 0px ${borderRadius4} ${borderRadius4} 0px; |
| 31 | + border-right: 1px solid ${Neutral.B68}; |
| 32 | + } |
| 33 | + } |
| 34 | +
|
| 35 | + &[data-segmented='true'] button:focus { |
| 36 | + z-index: 1; |
| 37 | + border: 1px solid ${Neutral.B68}; |
| 38 | + } |
| 39 | +
|
| 40 | + &[data-full-width='true'] button { |
| 41 | + flex: 1; |
| 42 | + } |
| 43 | +
|
| 44 | + &[data-segmented='true']&[data-button-wrapped='true'] > * { |
| 45 | + button { |
| 46 | + border-radius: 0; |
| 47 | + border-right: 0; |
| 48 | + } |
| 49 | + :nth-child(1) button { |
| 50 | + border-radius: ${borderRadius4} 0px 0px ${borderRadius4}; |
| 51 | + } |
| 52 | +
|
| 53 | + :nth-last-child(1) button { |
| 54 | + border-radius: 0px ${borderRadius4} ${borderRadius4} 0px; |
| 55 | + border-right: 1px solid ${Neutral.B68}; |
| 56 | + } |
| 57 | + } |
49 | 58 | `; |
0 commit comments