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: Allow CSS overrides for TopBar wrapper element #710

Merged
merged 4 commits into from
Oct 17, 2024
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
27 changes: 9 additions & 18 deletions lib/src/components/top-bar/TopBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ const TopBarDivider = () => (
<Divider orientation="vertical" css={{ height: '$2', bg: '$divider' }} />
)

const StyledRoot = styled('div', {
const StyledRoot = styled(Flex, {
bg: '$background',
position: 'sticky',
display: 'flex',
alignItems: 'center',
width: '100vw',
top: '0',
zIndex: 1,
borderBottom: '1px solid $borderBottom',
transition: 'box-shadow .2s ease-out',
px: '$4',
py: '$2',
'@md': {
px: '$5'
},
variants: {
hasScrolled: {
true: { boxShadow: '0px 4px 4px -2px rgba(31, 31, 31, 0.1);' }
Expand All @@ -34,16 +37,6 @@ const StyledRoot = styled('div', {
}
})

const Container = styled(Flex, {
alignItems: 'center',
height: '$4',
mx: '$4',
width: '100%',
'@md': {
mx: '$5'
}
})

type StyledRootProps = React.ComponentProps<typeof StyledRoot>

interface TopBarProps extends StyledRootProps {
Expand All @@ -52,20 +45,18 @@ interface TopBarProps extends StyledRootProps {
}

const TopBarComponent = ({
size = 'md',
className = topBarColorSchemes['light'],
...props
}: TopBarProps) => {
const { y: scrollPositionY } = useWindowScrollPosition()

return (
<StyledRoot
align="center"
className={className}
hasScrolled={!!scrollPositionY}
avirati marked this conversation as resolved.
Show resolved Hide resolved
size={size}
>
<Container {...props} />
</StyledRoot>
{...props}
/>
)
}

Expand Down
Loading
Loading