-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: [F36-889] full height button group divider
- Loading branch information
1 parent
903facb
commit 137c6cf
Showing
4 changed files
with
55 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@contentful/f36-button': minor | ||
--- | ||
|
||
chore: [F36-889] full height button group divider |
87 changes: 34 additions & 53 deletions
87
packages/components/button/src/ButtonGroup/ButtonGroup.styles.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,42 @@ | ||
import { css } from 'emotion'; | ||
import tokens from '@contentful/f36-tokens'; | ||
import type { GetStyleArguments } from './types'; | ||
import type { CSSObject } from '@emotion/serialize'; | ||
|
||
const getGroupContentStyle = ({ withDivider }: GetStyleArguments) => { | ||
const dividerStyle = getDividerStyle(withDivider); | ||
export default function getButtonGroupStyles() { | ||
const divider = css({ | ||
marginLeft: '-1px', | ||
zIndex: tokens.zIndexDefault + 1, | ||
width: '1px', | ||
opacity: '20%', | ||
backgroundColor: tokens.colorWhite, | ||
}); | ||
|
||
return { | ||
borderRadius: '0 !important', | ||
marginRight: '-1px', | ||
zIndex: tokens.zIndexDefault, | ||
'&:first-child': { | ||
borderBottomLeftRadius: `${tokens.borderRadiusMedium} !important`, | ||
borderTopLeftRadius: `${tokens.borderRadiusMedium} !important`, | ||
}, | ||
'&:last-child': { | ||
borderBottomRightRadius: `${tokens.borderRadiusMedium} !important`, | ||
borderTopRightRadius: `${tokens.borderRadiusMedium} !important`, | ||
marginRight: 0, | ||
}, | ||
'&:focus': { | ||
zIndex: tokens.zIndexDefault + 1, | ||
}, | ||
...dividerStyle, | ||
}; | ||
}; | ||
|
||
const getDividerStyle = (withDivider: boolean): CSSObject => { | ||
if (!withDivider) return {}; | ||
return { | ||
position: 'relative', | ||
'&:before': { | ||
content: '""', | ||
width: '1px', | ||
opacity: '20%', | ||
backgroundColor: tokens.colorWhite, | ||
height: '60%', | ||
left: '0', | ||
position: 'absolute', | ||
}, | ||
'&:first-child, &:focus': { | ||
'&:before': { | ||
display: 'none', | ||
divider, | ||
buttonGroup: css({ | ||
display: 'inline-flex', | ||
position: 'relative', | ||
'&:hover, &:has(:focus-visible)': { | ||
[`> .${divider}`]: { | ||
opacity: '0', | ||
}, | ||
}, | ||
}, | ||
'&:hover, &:hover + &': { | ||
'&:before': { | ||
display: 'none', | ||
}), | ||
groupContent: css({ | ||
borderRadius: '0 !important', | ||
marginRight: '-1px', | ||
zIndex: tokens.zIndexDefault, | ||
'&:first-child': { | ||
borderBottomLeftRadius: `${tokens.borderRadiusMedium} !important`, | ||
borderTopLeftRadius: `${tokens.borderRadiusMedium} !important`, | ||
}, | ||
}, | ||
'&:last-child': { | ||
borderBottomRightRadius: `${tokens.borderRadiusMedium} !important`, | ||
borderTopRightRadius: `${tokens.borderRadiusMedium} !important`, | ||
marginRight: 0, | ||
}, | ||
'&:focus': { | ||
zIndex: tokens.zIndexDefault + 1, | ||
}, | ||
}), | ||
}; | ||
}; | ||
|
||
export default ({ withDivider }: GetStyleArguments) => ({ | ||
buttonGroup: css({ | ||
display: 'inline-flex', | ||
position: 'relative', | ||
}), | ||
groupContent: css(getGroupContentStyle({ withDivider })), | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters