Skip to content

Commit 984a76f

Browse files
tassoevanggazzo
authored andcommitted
fix: Update Callout margins; allow Callout without title (#106)
1 parent 8e7b5e4 commit 984a76f

10 files changed

+42
-23
lines changed
Loading
Loading
Loading
Loading
Loading
Loading

packages/fuselage/src/components/Callout/index.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Icon } from '../Icon';
77
const Container = createStyledComponent('rcx-callout', 'section');
88
const Wrapper = createStyledComponent('rcx-callout__wrapper');
99
const Title = createStyledComponent('rcx-callout__title', 'h1');
10+
const ChildrenWrapper = createStyledComponent('rcx-callout__children', 'div');
1011

1112
export const Callout = React.forwardRef(function Callout({
1213
children,
@@ -20,10 +21,12 @@ export const Callout = React.forwardRef(function Callout({
2021
|| (type === 'danger' && 'ban');
2122

2223
return <Container mod-type={type} ref={ref} {...props}>
23-
<Icon name={iconName} x16 />
24+
<Icon name={iconName} size={20} />
2425
<Wrapper>
25-
<Title mod-has-children={!!children}>{title}</Title>
26-
{children}
26+
{title && <Title>{title}</Title>}
27+
<ChildrenWrapper>
28+
{children}
29+
</ChildrenWrapper>
2730
</Wrapper>
2831
</Container>;
2932
});
@@ -37,6 +40,6 @@ Callout.displayName = 'Callout';
3740
Callout.propTypes = {
3841
children: PropTypes.node,
3942
invisible: PropTypes.bool,
40-
title: PropTypes.string.isRequired,
43+
title: PropTypes.node,
4144
type: PropTypes.oneOf(['info', 'success', 'warning', 'danger']).isRequired,
4245
};

packages/fuselage/src/components/Callout/spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import { Callout } from '../..';
55

66
it('renders without crashing', () => {
77
const div = document.createElement('div');
8-
ReactDOM.render(<Callout title='' />, div);
8+
ReactDOM.render(<Callout />, div);
99
ReactDOM.unmountComponentAtNode(div);
1010
});

packages/fuselage/src/components/Callout/stories.mdx

+21
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,24 @@ something important in the content of the current page.
4343
</>
4444
</Story>
4545
</Preview>
46+
47+
## With description only
48+
49+
<Preview>
50+
<Story name='With Description Only'>
51+
<>
52+
<Callout>
53+
This is a generic description.
54+
</Callout>
55+
<Callout type='success'>
56+
This is a successful description.
57+
</Callout>
58+
<Callout type='warning'>
59+
This is a warning description.
60+
</Callout>
61+
<Callout type='danger'>
62+
This is a danger description.
63+
</Callout>
64+
</>
65+
</Story>
66+
</Preview>

packages/fuselage/src/components/Callout/styles.scss

+13-18
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55

66
display: flex;
77

8-
margin: 0 0 #{ $spaces-x24 };
9-
margin-inline: 0;
10-
margin-block-start: 0;
11-
margin-block-end: #{ $spaces-x24 };
12-
13-
padding: #{ $spaces-x16 };
8+
padding-block: #{ $spaces-x16 };
9+
padding-inline-start: #{ $spaces-x16 };
10+
padding-inline-end: #{ $spaces-x32 };
1411

1512
border-radius: #{ $borders-radius-x2 };
1613

@@ -29,10 +26,6 @@
2926
&--type-danger {
3027
background-color: #{ map-get($colors, red200) };
3128
}
32-
33-
& > .rcx-icon {
34-
font-size: #{ $sizes-x16 };
35-
}
3629
}
3730

3831
.rcx-callout__wrapper {
@@ -43,9 +36,7 @@
4336
overflow: hidden;
4437
flex: 1 1 0;
4538

46-
margin: 0 #{ $spaces-x8 };
47-
margin-block: 0;
48-
margin-inline: #{ $spaces-x8 };
39+
margin-inline-start: #{ $spaces-x8 };
4940

5041
color: #{ $text-colors-default };
5142
flex-flow: column nowrap;
@@ -56,12 +47,16 @@
5647
.rcx-callout__title {
5748
@include box;
5849

59-
@include as-caption($bold: true);
60-
61-
&--has-children {
62-
margin-bottom: #{ $spaces-x4 };
63-
}
50+
padding-block: #{ $spaces-x2 };
6451

52+
@include as-caption($bold: true);
6553
@include with-text--ellipsis;
6654
@include with-text--nowrap;
6755
}
56+
57+
.rcx-callout__children {
58+
@include box;
59+
display: block;
60+
61+
padding-block: #{ $spaces-x2 };
62+
}

0 commit comments

Comments
 (0)