Skip to content

Commit

Permalink
Added a small version of the EuiCallOut (#269)
Browse files Browse the repository at this point in the history
* Added a small (`size=“s”`) version of the `EuiCallOut`
  • Loading branch information
cchaos authored Jan 8, 2018
1 parent 2de627d commit 8c538ad
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Added Apache, Nginx, MySQL logos [(#270)](https://github.com/elastic/eui/pull/270)
- Fixed `<EuiContextMenu>` to pass the `event` argument to a `<EuiContextMenuItem>`'s `onClick` handler even when a panel is defined. [(#265)](https://github.com/elastic/eui/pull/265)
- Added small version of `EuiCallOut` [(#269)](https://github.com/elastic/eui/pull/269)

# [`0.0.11`](https://github.com/elastic/eui/tree/v0.0.11)

Expand Down
14 changes: 10 additions & 4 deletions src-docs/src/views/call_out/call_out_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ export const CallOutExample = {
code: infoHtml,
}],
text: (
<p>
Use <EuiCode>EuiCallOut</EuiCode> to communicate general information to the user.
Note that the <EuiCode>Icon</EuiCode> prop is optional.
</p>
<div>
<p>
Use <EuiCode>EuiCallOut</EuiCode> to communicate general information to the user.
Note that the <EuiCode>Icon</EuiCode> prop is optional.
</p>
<p>
For callouts that have a perminant spot in the UI, but need to be less obstructive,
set the <EuiCode>size</EuiCode> property to <EuiCode>s</EuiCode> (small).
</p>
</div>
),
demo: <Info />,
}, {
Expand Down
9 changes: 9 additions & 0 deletions src-docs/src/views/call_out/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,14 @@ export default () => (
title="Callouts can exist as just a title. Simply omit the child content."
iconType="gear"
/>

<EuiSpacer size="m" />

<EuiCallOut
size="s"
title="This is a small callout for more unintrusive but constant messages."
iconType="pin"
/>

</div>
);
9 changes: 9 additions & 0 deletions src/components/call_out/_call_out.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
.euiCallOut {
padding: $euiSize;
border-left: $euiSizeXS / 2 solid transparent;

&.euiCallOut--small {
padding: $euiSizeS;
}
}

// Modifier naming and colors.
Expand Down Expand Up @@ -46,6 +50,11 @@ $callOutTypes: (
> * + * {
margin-left: $euiSizeS; /* 3 */
}

// smaller font size for headers in small callout
.euiCallOut--small & {
@include euiFontSizeS;
}
}

/**
Expand Down
25 changes: 23 additions & 2 deletions src/components/call_out/call_out.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,28 @@ const colorToClassNameMap = {

export const COLORS = Object.keys(colorToClassNameMap);

const sizeToClassNameMap = {
s: 'euiCallOut--small',
m: '',
};

export const SIZES = Object.keys(sizeToClassNameMap);

export const EuiCallOut = ({
title,
color,
size,
iconType,
children,
className,
...rest
}) => {
const classes = classNames('euiCallOut', colorToClassNameMap[color], className);
const classes = classNames(
'euiCallOut',
colorToClassNameMap[color],
sizeToClassNameMap[size],
className,
);

let headerIcon;

Expand All @@ -45,7 +58,13 @@ export const EuiCallOut = ({
}

let optionalChildren;
if (children) {
if (children && size === 's') {
optionalChildren = (
<EuiText size="xs">
{children}
</EuiText>
);
} else if (children) {
optionalChildren = (
<EuiText size="s">
{children}
Expand Down Expand Up @@ -77,8 +96,10 @@ EuiCallOut.propTypes = {
title: PropTypes.node,
iconType: PropTypes.oneOf(ICON_TYPES),
color: PropTypes.oneOf(COLORS),
size: PropTypes.oneOf(SIZES),
};

EuiCallOut.defaultProps = {
color: 'primary',
size: 'm',
};

0 comments on commit 8c538ad

Please sign in to comment.