diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2022-07-18 14:37:37 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2022-07-22 14:36:05 +0200 |
| commit | 9736b27dcf1ac6c5c9a011890bfac9a381feb6de (patch) | |
| tree | 5797ec79ca24299c5e4684154cd57c1fdae0fc11 /gui/src | |
| parent | b898f36c84d994207c8e01e77c72ad939f4583a5 (diff) | |
| download | mullvadvpn-9736b27dcf1ac6c5c9a011890bfac9a381feb6de.tar.xz mullvadvpn-9736b27dcf1ac6c5c9a011890bfac9a381feb6de.zip | |
Move Cell group component to its own file
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/renderer/components/cell/CellButton.tsx | 7 | ||||
| -rw-r--r-- | gui/src/renderer/components/cell/Group.tsx | 39 | ||||
| -rw-r--r-- | gui/src/renderer/components/cell/index.ts | 1 |
3 files changed, 40 insertions, 7 deletions
diff --git a/gui/src/renderer/components/cell/CellButton.tsx b/gui/src/renderer/components/cell/CellButton.tsx index 5a24cfe901..6c6beb6d83 100644 --- a/gui/src/renderer/components/cell/CellButton.tsx +++ b/gui/src/renderer/components/cell/CellButton.tsx @@ -49,10 +49,3 @@ export const CellButton = styled( ); }), )({}); - -export const CellButtonGroup = styled.div({ - display: 'flex', - flexDirection: 'column', - flex: 1, - marginBottom: '20px', -}); diff --git a/gui/src/renderer/components/cell/Group.tsx b/gui/src/renderer/components/cell/Group.tsx new file mode 100644 index 0000000000..c167b2d525 --- /dev/null +++ b/gui/src/renderer/components/cell/Group.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import styled from 'styled-components'; + +interface IStyledGroupProps { + noMarginBottom?: boolean; +} + +const StyledGroup = styled.div({}, (props: IStyledGroupProps) => ({ + display: 'flex', + flexDirection: 'column', + flex: 1, + marginBottom: props.noMarginBottom ? '0px' : '20px', +})); + +const StyledCellWrapper = styled.div({ + display: 'flex', + flexDirection: 'column', + flex: 1, + marginBottom: '1px', +}); + +interface IGroupProps extends IStyledGroupProps { + children: React.ReactNode | React.ReactNode[]; +} + +export function Group(props: IGroupProps) { + const children = React.Children.toArray(props.children); + return ( + <StyledGroup noMarginBottom={props.noMarginBottom}> + {children.map((child, index) => + index === children.length - 1 ? ( + child + ) : ( + <StyledCellWrapper key={index}>{child}</StyledCellWrapper> + ), + )} + </StyledGroup> + ); +} diff --git a/gui/src/renderer/components/cell/index.ts b/gui/src/renderer/components/cell/index.ts index a16cb93097..cc510e5b22 100644 --- a/gui/src/renderer/components/cell/index.ts +++ b/gui/src/renderer/components/cell/index.ts @@ -4,3 +4,4 @@ export * from './Footer'; export * from './Input'; export * from './Label'; export * from './Section'; +export * from './Group'; |
