From e94188e5535f54b45cc57e14d57c390d95cc4b2a Mon Sep 17 00:00:00 2001 From: Andrea Del Rio Date: Tue, 15 Oct 2019 16:48:23 -0500 Subject: [PATCH 1/5] added disabled state to EuiBadge --- src-docs/src/views/badge/badge.js | 6 ++-- src-docs/src/views/badge/badge_with_icon.js | 2 +- src-docs/src/views/badge/beta_badge.js | 7 ++++ .../src/views/badge/notification_badge.tsx | 8 ++++- src/components/badge/_badge.scss | 34 +++++++++++++++---- src/components/badge/_index.scss | 1 + src/components/badge/badge.tsx | 9 +++++ .../badge/beta_badge/_beta_badge.scss | 6 ++++ .../badge/beta_badge/beta_badge.tsx | 6 ++++ .../_notification_badge.scss | 5 +++ .../notification_badge/badge_notification.tsx | 13 ++++++- 11 files changed, 86 insertions(+), 11 deletions(-) diff --git a/src-docs/src/views/badge/badge.js b/src-docs/src/views/badge/badge.js index ee0e567a710..742993b4f00 100644 --- a/src-docs/src/views/badge/badge.js +++ b/src-docs/src/views/badge/badge.js @@ -14,15 +14,17 @@ const badges = [ 'accent', 'warning', 'danger', - '#fea27f', '#000', + '#fea27f', ]; export default () => ( {badges.map(badge => ( - {badge} + + {badge === '#fea27f' ? 'disabled badge' : badge} + ))} diff --git a/src-docs/src/views/badge/badge_with_icon.js b/src-docs/src/views/badge/badge_with_icon.js index 7ae47352f8d..c0dba2ee87b 100644 --- a/src-docs/src/views/badge/badge_with_icon.js +++ b/src-docs/src/views/badge/badge_with_icon.js @@ -6,7 +6,7 @@ export default () => (
Default - + Primary
diff --git a/src-docs/src/views/badge/beta_badge.js b/src-docs/src/views/badge/beta_badge.js index f0c7dd0f5e8..05f662f0e23 100644 --- a/src-docs/src/views/badge/beta_badge.js +++ b/src-docs/src/views/badge/beta_badge.js @@ -15,6 +15,13 @@ export default () => ( tooltipContent="This module is not GA. Please help us by reporting any bugs." />   + +   diff --git a/src-docs/src/views/badge/notification_badge.tsx b/src-docs/src/views/badge/notification_badge.tsx index 99c7f9e46cd..331ead9bce9 100644 --- a/src-docs/src/views/badge/notification_badge.tsx +++ b/src-docs/src/views/badge/notification_badge.tsx @@ -2,4 +2,10 @@ import React from 'react'; import { EuiNotificationBadge } from '../../../../src/components/badge/notification_badge'; -export default () => 3; +export default () => ( +
+ 3 +   + 3 +
+); diff --git a/src/components/badge/_badge.scss b/src/components/badge/_badge.scss index 8b506d6a22a..dab6cee6ae7 100644 --- a/src/components/badge/_badge.scss +++ b/src/components/badge/_badge.scss @@ -19,6 +19,12 @@ // So, make the text left aligned to ensure all badges line up the same text-align: left; + &.euiBadge-isDisabled { + // sass-lint:disable-block no-important + background-color: $euiColorLightestShade !important; + color: $euiButtonColorDisabled !important; + } + &:focus-within { @include euiFocusRing('small'); } @@ -40,9 +46,15 @@ font-weight: inherit; line-height: inherit; - &:hover, - &:focus { - text-decoration: underline; + &:disabled { + cursor: not-allowed; + } + + &:not(:disabled) { + &:hover, + &:focus { + text-decoration: underline; + } } } @@ -57,6 +69,10 @@ border-radius: 2px; } + &:disabled { + cursor: not-allowed; + } + .euiBadge__icon { // Remove margins from icon itself so that focus state doesn't include that space margin: 0 !important; // sass-lint:disable-line no-important @@ -86,9 +102,15 @@ } .euiBadge-isClickable { - &:hover, - &:focus { - text-decoration: underline; + &:not(:disabled) { + &:hover, + &:focus { + text-decoration: underline; + } + } + + &.euiBadge-isDisabled { + cursor: not-allowed; } &:focus { diff --git a/src/components/badge/_index.scss b/src/components/badge/_index.scss index a567f7a42de..a5d83c76aef 100644 --- a/src/components/badge/_index.scss +++ b/src/components/badge/_index.scss @@ -1,3 +1,4 @@ +@import '../button/variables'; @import 'badge'; @import 'beta_badge/index'; @import 'notification_badge/index'; diff --git a/src/components/badge/badge.tsx b/src/components/badge/badge.tsx index 673a981494f..d1fe457ad22 100644 --- a/src/components/badge/badge.tsx +++ b/src/components/badge/badge.tsx @@ -56,6 +56,8 @@ export type EuiBadgeProps = { */ color?: IconColor; + isDisabled?: boolean; + /** * Props passed to the close button. */ @@ -89,6 +91,7 @@ export const EuiBadge: FunctionComponent = ({ iconType, iconSide = 'left', className, + isDisabled, onClick, iconOnClick, onClickAriaLabel, @@ -119,6 +122,9 @@ export const EuiBadge: FunctionComponent = ({ { 'euiBadge-isClickable': onClick && !iconOnClick, }, + { + 'euiBadge-isDisabled': isDisabled, + }, iconSideToClassNameMap[iconSide], optionalColorClass, className @@ -141,6 +147,7 @@ export const EuiBadge: FunctionComponent = ({