Skip to content

Commit

Permalink
[@mantine/core] Alert: Fix incorrect styles when the component is use…
Browse files Browse the repository at this point in the history
…d without children (#5196)
  • Loading branch information
rtivital committed Nov 7, 2023
1 parent 233f924 commit d9c9c94
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/mantine-core/src/components/Alert/Alert.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
}

.title {
margin-bottom: var(--mantine-spacing-xs);
display: flex;
align-items: center;
justify-content: space-between;
font-size: var(--mantine-font-size-sm);
font-weight: 700;

&[data-with-clos-button] {
&[data-with-close-button] {
padding-right: var(--mantine-spacing-md);

@mixin rtl {
Expand Down Expand Up @@ -69,6 +68,7 @@
overflow: hidden;
font-size: var(--mantine-font-size-sm);
color: var(--_message-color, var(--__message-color));
margin-top: var(--mantine-spacing-xs);

@mixin light {
--__message-color: var(--mantine-color-black);
Expand Down
8 changes: 8 additions & 0 deletions src/mantine-core/src/components/Alert/Alert.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ export function Unstyled() {
);
}

export function WithoutDescription() {
return (
<div style={{ maxWidth: 500, margin: 'auto', padding: 40 }}>
<Alert icon="$" title="Bummer!" color="red" variant="light" withCloseButton></Alert>
</div>
);
}

export function CSSVariables() {
return (
<MantineThemeProvider
Expand Down
8 changes: 5 additions & 3 deletions src/mantine-core/src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,11 @@ export const Alert = factory<AlertFactory>((_props, ref) => {
</div>
)}

<div id={bodyId} {...getStyles('message')}>
{children}
</div>
{children && (
<div id={bodyId} {...getStyles('message')}>
{children}
</div>
)}
</div>

{withCloseButton && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const usage: MantineDemo = {
component: Wrapper,
code,
centered: true,
striped: true,
controls: [
interactiveVariantsControl,
{ prop: 'color', type: 'color', initialValue: 'blue', libraryValue: 'blue' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const configurator: MantineDemo = {
component: Wrapper,
code,
centered: true,
striped: true,
maxWidth: 400,
controls: [
{ ...(staticVariantsControl as any), initialValue: 'light' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export const configurator: MantineDemo = {
type: 'configurator',
component: Avatar,
centered: true,
striped: true,
code,
controls: [
staticVariantsControl,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const configurator: MantineDemo = {
component: Wrapper,
code,
centered: true,
striped: true,
controls: [
interactiveVariantsControl,
{ type: 'color', prop: 'color', initialValue: 'blue', libraryValue: 'blue' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const usage: MantineDemo = {
component: Wrapper,
code,
centered: true,
striped: true,
controls: [
{
prop: 'variant',
Expand Down

0 comments on commit d9c9c94

Please sign in to comment.