Skip to content

Commit 3a7055d

Browse files
committed
UI: Make banner width match content + round corners
1 parent 0fe2627 commit 3a7055d

File tree

1 file changed

+34
-26
lines changed

1 file changed

+34
-26
lines changed

src/components/banner.js

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
AlertTitle,
66
Box,
77
CloseButton,
8+
Container,
89
useDisclosure,
910
} from '@chakra-ui/react'
1011

@@ -16,34 +17,41 @@ export const Banner = ({ title, description, children }) => {
1617
} = useDisclosure({ defaultIsOpen: true })
1718

1819
return isVisible ? (
19-
<Box pt={16} px={20}>
20-
<Alert
21-
status='info'
22-
variant='solid'
23-
alignItems='flex-start' // Align icon nicely with multi-line text
24-
>
25-
<AlertIcon />
26-
<Box flex='1' ml={3}>
27-
{' '}
28-
{/* Container for text content, allows vertical flow */}
29-
<AlertTitle>{title}</AlertTitle>
30-
{description && (
31-
<AlertDescription mt={1}>{description}</AlertDescription>
32-
)}
33-
<Box mt={2}>
20+
<Box pt={16}>
21+
{' '}
22+
{/* This Box provides top padding to clear the header */}
23+
<Container maxW='container.lg'>
24+
{' '}
25+
{/* Constrains the width of the banner */}
26+
<Alert
27+
status='info'
28+
variant='solid'
29+
alignItems='flex-start' // Align icon nicely with multi-line text
30+
borderRadius='md' // Added rounded corners
31+
>
32+
<AlertIcon />
33+
<Box flex='1' ml={3}>
3434
{' '}
35-
{/* Wrapper for children, e.g., links */}
36-
{children}
35+
{/* Container for text content, allows vertical flow */}
36+
<AlertTitle>{title}</AlertTitle>
37+
{description && (
38+
<AlertDescription mt={1}>{description}</AlertDescription>
39+
)}
40+
<Box mt={2}>
41+
{' '}
42+
{/* Wrapper for children, e.g., links */}
43+
{children}
44+
</Box>
3745
</Box>
38-
</Box>
39-
<CloseButton
40-
position='absolute' // Position absolutely within the Alert
41-
alignSelf='flex-start'
42-
right='8px' // Adjust as needed
43-
top='8px' // Adjust as needed
44-
onClick={onClose}
45-
/>
46-
</Alert>
46+
<CloseButton
47+
position='absolute' // Position absolutely within the Alert
48+
alignSelf='flex-start'
49+
right='8px' // Adjust as needed
50+
top='8px' // Adjust as needed
51+
onClick={onClose}
52+
/>
53+
</Alert>
54+
</Container>
4755
</Box>
4856
) : (
4957
<></>

0 commit comments

Comments
 (0)