mirror of
https://github.com/Unleash/unleash.git
synced 2025-07-26 13:48:33 +02:00
refactor: normalize status badge designs (#1018)
This commit is contained in:
parent
a11cb72d99
commit
91a825792e
@ -1,13 +0,0 @@
|
|||||||
import { makeStyles } from 'tss-react/mui';
|
|
||||||
|
|
||||||
export const useStyles = makeStyles()(theme => ({
|
|
||||||
indicator: {
|
|
||||||
padding: '0.2rem',
|
|
||||||
borderRadius: '5px',
|
|
||||||
marginLeft: '0.5rem',
|
|
||||||
backgroundColor: '#000',
|
|
||||||
color: '#fff',
|
|
||||||
fontSize: '0.9rem',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
},
|
|
||||||
}));
|
|
@ -1,16 +0,0 @@
|
|||||||
import { useStyles } from './DisabledIndicator.styles';
|
|
||||||
import classnames from 'classnames';
|
|
||||||
interface IDisabledIndicator {
|
|
||||||
className?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const DisabledIndicator = ({ className }: IDisabledIndicator) => {
|
|
||||||
const { classes: styles } = useStyles();
|
|
||||||
return (
|
|
||||||
<span className={classnames(styles.indicator, className)}>
|
|
||||||
disabled
|
|
||||||
</span>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default DisabledIndicator;
|
|
34
frontend/src/component/common/StatusBadge/StatusBadge.tsx
Normal file
34
frontend/src/component/common/StatusBadge/StatusBadge.tsx
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
import { styled, useTheme } from '@mui/material';
|
||||||
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
|
interface IStatusBadgeProps {
|
||||||
|
severity: 'success' | 'warning';
|
||||||
|
className?: string;
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const StatusBadge = ({
|
||||||
|
severity,
|
||||||
|
className,
|
||||||
|
children,
|
||||||
|
}: IStatusBadgeProps) => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const background = theme.palette.statusBadge[severity];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StyledStatusBadge sx={{ background }} className={className}>
|
||||||
|
{children}
|
||||||
|
</StyledStatusBadge>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const StyledStatusBadge = styled('div')(({ theme }) => ({
|
||||||
|
padding: theme.spacing(0.5, 1),
|
||||||
|
textDecoration: 'none',
|
||||||
|
color: theme.palette.text.primary,
|
||||||
|
display: 'inline-block',
|
||||||
|
borderRadius: theme.shape.borderRadius,
|
||||||
|
marginLeft: theme.spacing(1.5),
|
||||||
|
fontSize: theme.fontSizes.smallerBody,
|
||||||
|
lineHeight: 1,
|
||||||
|
}));
|
@ -23,9 +23,9 @@ import {
|
|||||||
} from 'component/providers/AccessProvider/permissions';
|
} from 'component/providers/AccessProvider/permissions';
|
||||||
import { useDrag, useDrop, DropTargetMonitor } from 'react-dnd';
|
import { useDrag, useDrop, DropTargetMonitor } from 'react-dnd';
|
||||||
import { XYCoord, Identifier } from 'dnd-core';
|
import { XYCoord, Identifier } from 'dnd-core';
|
||||||
import DisabledIndicator from 'component/common/DisabledIndicator/DisabledIndicator';
|
|
||||||
import StringTruncator from 'component/common/StringTruncator/StringTruncator';
|
import StringTruncator from 'component/common/StringTruncator/StringTruncator';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { StatusBadge } from 'component/common/StatusBadge/StatusBadge';
|
||||||
|
|
||||||
interface IEnvironmentListItemProps {
|
interface IEnvironmentListItemProps {
|
||||||
env: IEnvironment;
|
env: IEnvironment;
|
||||||
@ -146,7 +146,11 @@ const EnvironmentListItem = ({
|
|||||||
</strong>
|
</strong>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={!env.enabled}
|
condition={!env.enabled}
|
||||||
show={<DisabledIndicator />}
|
show={
|
||||||
|
<StatusBadge severity="warning">
|
||||||
|
Disabled
|
||||||
|
</StatusBadge>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import {
|
|||||||
formatStrategyName,
|
formatStrategyName,
|
||||||
} from 'utils/strategyNames';
|
} from 'utils/strategyNames';
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
import DisabledIndicator from 'component/common/DisabledIndicator/DisabledIndicator';
|
|
||||||
import EnvironmentIcon from 'component/common/EnvironmentIcon/EnvironmentIcon';
|
import EnvironmentIcon from 'component/common/EnvironmentIcon/EnvironmentIcon';
|
||||||
import StringTruncator from 'component/common/StringTruncator/StringTruncator';
|
import StringTruncator from 'component/common/StringTruncator/StringTruncator';
|
||||||
import { useStyles } from './FeatureOverviewEnvironment.styles';
|
import { useStyles } from './FeatureOverviewEnvironment.styles';
|
||||||
@ -25,6 +24,7 @@ import FeatureOverviewEnvironmentMetrics from './FeatureOverviewEnvironmentMetri
|
|||||||
import { FeatureStrategyMenu } from 'component/feature/FeatureStrategy/FeatureStrategyMenu/FeatureStrategyMenu';
|
import { FeatureStrategyMenu } from 'component/feature/FeatureStrategy/FeatureStrategyMenu/FeatureStrategyMenu';
|
||||||
import { FEATURE_ENVIRONMENT_ACCORDION } from 'utils/testIds';
|
import { FEATURE_ENVIRONMENT_ACCORDION } from 'utils/testIds';
|
||||||
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
import { useRequiredPathParam } from 'hooks/useRequiredPathParam';
|
||||||
|
import { StatusBadge } from 'component/common/StatusBadge/StatusBadge';
|
||||||
|
|
||||||
interface IStrategyIconObject {
|
interface IStrategyIconObject {
|
||||||
count: number;
|
count: number;
|
||||||
@ -164,9 +164,12 @@ const FeatureOverviewEnvironment = ({
|
|||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={!env.enabled}
|
condition={!env.enabled}
|
||||||
show={
|
show={
|
||||||
<DisabledIndicator
|
<StatusBadge
|
||||||
|
severity="warning"
|
||||||
className={styles.disabledIndicatorPos}
|
className={styles.disabledIndicatorPos}
|
||||||
/>
|
>
|
||||||
|
Disabled
|
||||||
|
</StatusBadge>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
import { styled } from '@mui/material';
|
|
||||||
|
|
||||||
export const PredefinedBadge = () => {
|
|
||||||
return <StyledBadge>Predefined</StyledBadge>;
|
|
||||||
};
|
|
||||||
|
|
||||||
const StyledBadge = styled('div')(({ theme }) => ({
|
|
||||||
padding: theme.spacing(0.3, 1.25),
|
|
||||||
backgroundColor: theme.palette.predefinedBadgeColor,
|
|
||||||
textDecoration: 'none',
|
|
||||||
color: theme.palette.text.primary,
|
|
||||||
display: 'inline-block',
|
|
||||||
borderRadius: theme.shape.borderRadius,
|
|
||||||
marginLeft: theme.spacing(1.5),
|
|
||||||
}));
|
|
@ -37,7 +37,8 @@ import { SearchHighlightProvider } from 'component/common/Table/SearchHighlightC
|
|||||||
import { sortTypes } from 'utils/sortTypes';
|
import { sortTypes } from 'utils/sortTypes';
|
||||||
import { useTable, useGlobalFilter, useSortBy } from 'react-table';
|
import { useTable, useGlobalFilter, useSortBy } from 'react-table';
|
||||||
import { AddStrategyButton } from './AddStrategyButton/AddStrategyButton';
|
import { AddStrategyButton } from './AddStrategyButton/AddStrategyButton';
|
||||||
import { PredefinedBadge } from './PredefinedBadge/PredefinedBadge';
|
import { StatusBadge } from 'component/common/StatusBadge/StatusBadge';
|
||||||
|
|
||||||
interface IDialogueMetaData {
|
interface IDialogueMetaData {
|
||||||
show: boolean;
|
show: boolean;
|
||||||
title: string;
|
title: string;
|
||||||
@ -116,7 +117,11 @@ export const StrategiesList = () => {
|
|||||||
>
|
>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
condition={!editable}
|
condition={!editable}
|
||||||
show={() => <PredefinedBadge />}
|
show={() => (
|
||||||
|
<StatusBadge severity="success">
|
||||||
|
Predefined
|
||||||
|
</StatusBadge>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
</LinkCell>
|
</LinkCell>
|
||||||
);
|
);
|
||||||
|
@ -81,7 +81,6 @@ export default createTheme({
|
|||||||
highlight: '#FFEACC',
|
highlight: '#FFEACC',
|
||||||
sidebarContainer: 'rgba(32,32,33, 0.2)',
|
sidebarContainer: 'rgba(32,32,33, 0.2)',
|
||||||
grey: colors.grey,
|
grey: colors.grey,
|
||||||
predefinedBadgeColor: colors.green[100],
|
|
||||||
text: {
|
text: {
|
||||||
primary: colors.grey[900],
|
primary: colors.grey[900],
|
||||||
secondary: colors.grey[800],
|
secondary: colors.grey[800],
|
||||||
@ -101,6 +100,10 @@ export default createTheme({
|
|||||||
inactive: colors.orange[200],
|
inactive: colors.orange[200],
|
||||||
abandoned: colors.red[200],
|
abandoned: colors.red[200],
|
||||||
},
|
},
|
||||||
|
statusBadge: {
|
||||||
|
success: colors.green[100],
|
||||||
|
warning: colors.orange[200],
|
||||||
|
},
|
||||||
inactiveIcon: colors.grey[600],
|
inactiveIcon: colors.grey[600],
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
@ -49,11 +49,13 @@ declare module '@mui/material/styles' {
|
|||||||
abandoned: string;
|
abandoned: string;
|
||||||
};
|
};
|
||||||
dividerAlternative: string;
|
dividerAlternative: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Color for predefined badge
|
* Background colors for status badges.
|
||||||
*/
|
*/
|
||||||
predefinedBadgeColor: string;
|
statusBadge: {
|
||||||
|
success: string;
|
||||||
|
warning: string;
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* For table header hover effect.
|
* For table header hover effect.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user