Skip to content

Commit

Permalink
fix: Better alignment for Alert icons (#807)
Browse files Browse the repository at this point in the history
* fix: Better alignment for Alert icons

* Update changelog

* Use IconButton in Alert

* Fix alignment when close button is not present
  • Loading branch information
frankieyan authored Oct 23, 2024
1 parent ef4d195 commit edb0fef
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
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

0 comments on commit edb0fef

Please sign in to comment.