diff --git a/superset-frontend/src/components/Label/index.tsx b/superset-frontend/src/components/Label/index.tsx index 58c336e1884d8..dfed494115493 100644 --- a/superset-frontend/src/components/Label/index.tsx +++ b/superset-frontend/src/components/Label/index.tsx @@ -34,48 +34,78 @@ export interface LabelProps { } const SupersetLabel = styled(BootstrapLabel)` - &.supersetLabel { - border-radius: ${({ theme }) => theme.borderRadius}px; - border: none; - color: ${({ theme }) => theme.colors.secondary.light5}; - font-size: ${({ theme }) => theme.typography.sizes.s}; - font-weight: ${({ theme }) => theme.typography.weights.bold}; - min-width: ${({ theme }) => theme.gridUnit * 36}px; - min-height: ${({ theme }) => theme.gridUnit * 8}px; - text-transform: uppercase; - margin-left: ${({ theme }) => theme.gridUnit * 4}px; - &:first-of-type { - margin-left: 0; + cursor: ${({ onClick }) => (onClick ? 'pointer' : 'default')}; + transition: background-color ${({ theme }) => theme.transitionTiming}s; + &.label-warning { + background-color: ${({ theme }) => theme.colors.warning.base}; + &:hover { + background-color: ${({ theme, onClick }) => + onClick ? theme.colors.warning.dark1 : theme.colors.warning.base}; } - - i { - padding: 0 ${({ theme }) => theme.gridUnit * 2}px 0 0; + } + &.label-danger { + background-color: ${({ theme }) => theme.colors.error.base}; + &:hover { + background-color: ${({ theme, onClick }) => + onClick ? theme.colors.error.dark1 : theme.colors.error.base}; } - - &.primary { - background-color: ${({ theme }) => theme.colors.primary.base}; + } + &.label-success { + background-color: ${({ theme }) => theme.colors.success.base}; + &:hover { + background-color: ${({ theme, onClick }) => + onClick ? theme.colors.success.dark1 : theme.colors.success.base}; } - &.secondary { - color: ${({ theme }) => theme.colors.primary.base}; - background-color: ${({ theme }) => theme.colors.primary.light4}; + } + &.label-default { + background-color: ${({ theme }) => theme.colors.grayscale.base}; + &:hover { + background-color: ${({ theme, onClick }) => + onClick ? theme.colors.grayscale.dark1 : theme.colors.grayscale.base}; } - &.danger { - background-color: ${({ theme }) => theme.colors.error.base}; + } + &.label-info { + background-color: ${({ theme }) => theme.colors.info}; + &:hover { + background-color: ${({ theme, onClick }) => + onClick ? theme.colors.info.dark1 : theme.colors.info.base}; } } - - &.secondaryLabel { + &.label-primary { + background-color: ${({ theme }) => theme.colors.primary.base}; + &:hover { + background-color: ${({ theme, onClick }) => + onClick ? theme.colors.primary.dark1 : theme.colors.primary.base}; + } + } + /* note this is NOT a supported bootstrap label Style... this overrides default */ + &.label-secondary { background-color: ${({ theme }) => theme.colors.secondary.base}; &:hover { - background-color: ${({ theme }) => theme.colors.secondary.base}; + background-color: ${({ theme, onClick }) => + onClick ? theme.colors.secondary.dark1 : theme.colors.secondary.base}; } } `; export default function Label(props: LabelProps) { + const officialBootstrapStyles = [ + 'success', + 'warning', + 'danger', + 'info', + 'default', + 'primary', + ]; const labelProps = { ...props, placement: props.placement || 'top', + bsStyle: officialBootstrapStyles.includes(props.bsStyle || '') + ? props.bsStyle + : 'default', + className: officialBootstrapStyles.includes(props.bsStyle || '') + ? undefined + : `label-${props.bsStyle}`, }; return {props.children}; } diff --git a/superset-frontend/src/components/Label/label.stories.jsx b/superset-frontend/src/components/Label/label.stories.jsx index a9627498475b0..be1153f2832ef 100644 --- a/superset-frontend/src/components/Label/label.stories.jsx +++ b/superset-frontend/src/components/Label/label.stories.jsx @@ -18,7 +18,7 @@ */ import React from 'react'; import { action } from '@storybook/addon-actions'; -import { withKnobs, select, text } from '@storybook/addon-knobs'; +import { withKnobs, select, boolean, text } from '@storybook/addon-knobs'; import Label from './index'; export default { @@ -30,16 +30,34 @@ export default { const bsStyleKnob = { label: 'Types', options: { - danger: 'danger', - warning: 'warning', - success: 'success', default: 'default', + info: 'info', + success: 'success', + warning: 'warning', + danger: 'danger', + secondary: 'secondary', + primary: 'primary', }, defaultValue: 'default', }; -export const SupersetLabel = () => ( + +export const LabelGallery = () => ( +
+ {Object.values(bsStyleKnob.options).map(opt => ( + + ))} +
+); + +export const InteractiveLabel = () => (
-

Interactive

-

Gallery

- {Object.values(bsStyleKnob.options).map(opt => ( - - ))}
); diff --git a/superset-frontend/src/views/CRUD/chart/ChartList.tsx b/superset-frontend/src/views/CRUD/chart/ChartList.tsx index d1afb788f40da..2f196437b3f9a 100644 --- a/superset-frontend/src/views/CRUD/chart/ChartList.tsx +++ b/superset-frontend/src/views/CRUD/chart/ChartList.tsx @@ -540,7 +540,7 @@ class ChartList extends React.PureComponent { /> ))} coverRight={ - + } actions={