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

Added a small version of the EuiCallOut #269

Merged
merged 3 commits into from
Jan 8, 2018
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 @@ -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',
};