blob: 357d93ec37a9af9a63d9f38099ffbf7c8fdfdd2a (
plain)
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
|
import styled, { css } from 'styled-components';
import { Flex, FlexProps } from '../lib/components';
import { StyledButton } from '../lib/components/button';
export type WrapButtonGroupProps = FlexProps;
const StyledFlex = styled(Flex)`
${({ $gap: gapProp }) => {
const $gap = gapProp ?? '0px';
return css`
&& > ${StyledButton} {
flex: 1 0 auto;
max-width: 100%;
}
&&:has(> :nth-child(2)) {
& > ${StyledButton} {
min-width: calc((100% - ${$gap}) / 2);
}
}
&&:has(> :nth-child(3)) {
& > ${StyledButton} {
min-width: calc((100% - ${$gap} * 2) / 3);
}
}
&&:has(> :nth-child(4)) {
& > ${StyledButton} {
min-width: calc((100% - ${$gap} * 3) / 4);
}
}
&&:has(> :nth-child(5)) {
& > ${StyledButton} {
min-width: calc((100% - ${$gap} * 4) / 5);
}
}
`;
}}
`;
export function ButtonGroup({ $gap, children, ...props }: WrapButtonGroupProps) {
return (
<StyledFlex $gap={$gap} $flexWrap="wrap" {...props}>
{children}
</StyledFlex>
);
}
|