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

fix: Better alignment for Alert icons #807

Merged
merged 4 commits into from
Oct 23, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Reactist follows [semantic versioning](https://semver.org/) and doesn't introduc
# Next

- [Feat] Expose `showTimeout` and `hideTimeout` props for `Tooltip`
- [Fix] The center alignment between the `Alert` component's icon and message is now more accurate when the message is only one-line long.

# v26.0.0

Expand Down
9 changes: 8 additions & 1 deletion src/alert/alert.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
border-width: 1px;
color: var(--reactist-content-primary);
padding: var(--reactist-spacing-small);
}

.content {
/* this is to make sure it always has the same minimum height, whether it has a close button or not */
min-height: calc(2 * var(--reactist-spacing-small) + var(--reactist-button-small-height) + 2px);
min-height: var(--reactist-button-small-height);
}

.icon {
display: block;
}

.tone-info {
Expand Down
7 changes: 5 additions & 2 deletions src/alert/alert.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import { getClassNames } from '../utils/responsive-props'
import { Box } from '../box'
import { Button } from '../button'
import { IconButton } from '../button'
import { Columns, Column } from '../columns'

import { AlertIcon } from '../icons/alert-icon'
Expand Down Expand Up @@ -41,13 +41,16 @@ function Alert({ id, children, tone, closeLabel, onClose }: AlertProps) {
<Box
paddingY="xsmall"
paddingRight={onClose != null && closeLabel != null ? undefined : 'small'}
display="flex"
alignItems="center"
className={styles.content}
>
{children}
</Box>
</Column>
{onClose != null && closeLabel != null ? (
<Column width="content">
<Button
<IconButton
variant="quaternary"
size="small"
onClick={onClose}
Expand Down
Loading