-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added beta badges to cards and keypad menu items
- Loading branch information
cchaos
committed
Apr 26, 2018
1 parent
2cca657
commit 2a4820d
Showing
19 changed files
with
393 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiBetaBadge, | ||
} from '../../../../src/components'; | ||
|
||
export default () => ( | ||
<div> | ||
<EuiBetaBadge label="Beta" description="This module is not GA. Please help us by reporting any bugs." /> | ||
  | ||
<EuiBetaBadge label="Lab" description="This module is not GA. Please help us by reporting any bugs." /> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiCard, | ||
EuiIcon, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
} from '../../../../src/components'; | ||
|
||
const icons = ['dashboard', 'monitoring', 'watches']; | ||
const badges = [null, 'Beta', 'Lab']; | ||
|
||
const cardNodes = icons.map(function (item, index) { | ||
return ( | ||
<EuiFlexItem key={index}> | ||
<EuiCard | ||
icon={<EuiIcon size="xxl" type={`${item}App`} />} | ||
title={`Kibana ${item}`} | ||
description="Example of a card's description. Stick to one or two sentences." | ||
betaLabel={badges[index]} | ||
betaDescription={badges[index] ? "This module is not GA. Please help us by reporting any bugs." : undefined} | ||
onClick={() => window.alert('Card clicked')} | ||
/> | ||
</EuiFlexItem> | ||
); | ||
}); | ||
|
||
export default () => ( | ||
<EuiFlexGroup gutterSize="l"> | ||
{cardNodes} | ||
</EuiFlexGroup> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiIcon, | ||
EuiKeyPadMenu, | ||
EuiKeyPadMenuItem, | ||
} from '../../../../src/components'; | ||
|
||
export default () => ( | ||
<EuiKeyPadMenu> | ||
<EuiKeyPadMenuItem | ||
label="Dashboard" | ||
href="#" | ||
> | ||
<EuiIcon type="dashboardApp" size="l" /> | ||
</EuiKeyPadMenuItem> | ||
|
||
<EuiKeyPadMenuItem | ||
label="Dashboard" | ||
href="#" | ||
betaLabel="Beta" | ||
betaDescription="This module is not GA. Please help us by reporting any bugs." | ||
> | ||
<EuiIcon type="dashboardApp" size="l" /> | ||
</EuiKeyPadMenuItem> | ||
|
||
<EuiKeyPadMenuItem | ||
label="Dashboard" | ||
href="#" | ||
betaLabel="Lab" | ||
betaDescription="This module is not GA. Please help us by reporting any bugs." | ||
> | ||
<EuiIcon type="dashboardApp" size="l" /> | ||
</EuiKeyPadMenuItem> | ||
</EuiKeyPadMenu> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
@import 'badge'; | ||
@import 'beta_badge/index'; |
11 changes: 11 additions & 0 deletions
11
src/components/badge/beta_badge/__snapshots__/beta_badge.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EuiBetaBadge is rendered 1`] = ` | ||
<span | ||
aria-label="aria-label" | ||
class="euiBetaBadge testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
> | ||
Beta | ||
</span> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
.euiBetaBadge { | ||
display: inline-block; | ||
padding: 0 $euiSizeL; | ||
border-radius: $euiSizeL; | ||
background-color: $euiColorAccent; | ||
vertical-align: text-bottom; // if displayed inline with text | ||
@include euiSlightShadowHover($euiColorAccent); | ||
|
||
font-size: $euiSizeM; | ||
font-weight: $euiFontWeightBold; | ||
letter-spacing: .05em; | ||
color: chooseLightOrDarkText($euiColorAccent, $euiColorEmptyShade, $euiColorFullShade); | ||
text-transform: uppercase; | ||
line-height: $euiSizeL; | ||
text-align: center; | ||
white-space: nowrap; | ||
|
||
cursor: default; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import 'beta_badge'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
|
||
import { EuiToolTip } from '../../tool_tip'; | ||
|
||
export const EuiBetaBadge = ({ | ||
className, | ||
label, | ||
description, | ||
tooltipPosition, | ||
title, | ||
...rest, | ||
}) => { | ||
|
||
const classes = classNames( | ||
'euiBetaBadge', | ||
className | ||
); | ||
|
||
if (description) { | ||
return ( | ||
<EuiToolTip | ||
position={tooltipPosition} | ||
content={description} | ||
title={title} | ||
> | ||
<span | ||
className={classes} | ||
{...rest} | ||
> | ||
{label} | ||
</span> | ||
</EuiToolTip> | ||
); | ||
} else { | ||
return ( | ||
<span | ||
className={classes} | ||
title={title} | ||
{...rest} | ||
> | ||
{label} | ||
</span> | ||
) | ||
} | ||
} | ||
|
||
EuiBetaBadge.propTypes = { | ||
className: PropTypes.string, | ||
|
||
/** | ||
* One word label like "Beta" or "Lab" | ||
*/ | ||
label: PropTypes.string.isRequired, | ||
|
||
/** | ||
* Description for the tooltip | ||
*/ | ||
description: PropTypes.node, | ||
|
||
/** | ||
* Custom position of the tooltip | ||
*/ | ||
tooltipPosition: PropTypes.string, | ||
|
||
/** | ||
* Optional title will be supplied as tooltip title or title attribute | ||
*/ | ||
title: PropTypes.string, | ||
} | ||
|
||
EuiBetaBadge.defaultProps = { | ||
tooltipPosition: 'top', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { render } from 'enzyme'; | ||
import { requiredProps } from '../../../test'; | ||
|
||
import { EuiBetaBadge } from './beta_badge'; | ||
|
||
describe('EuiBetaBadge', () => { | ||
test('is rendered', () => { | ||
const component = render( | ||
<EuiBetaBadge label="Beta" {...requiredProps} /> | ||
); | ||
|
||
expect(component) | ||
.toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { | ||
EuiBetaBadge, | ||
} from './beta_badge'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
export { | ||
EuiBadge, | ||
} from './badge'; | ||
|
||
export { | ||
EuiBetaBadge, | ||
} from './beta_badge'; |
Oops, something went wrong.