unify intents based on configured tailwind intents
This commit is contained in:
parent
a3951016d0
commit
bb0cf7f575
@ -1,7 +1,7 @@
|
||||
import { Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||
import type { StatFields } from '../../config/types';
|
||||
import { defaultFieldFormatter } from '../table-row';
|
||||
import { Card, Indicator, Variant } from '@vegaprotocol/ui-toolkit';
|
||||
import { Card, Indicator, TailwindIntents } from '@vegaprotocol/ui-toolkit';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
export const PromotedStatsItem = ({
|
||||
@ -15,9 +15,9 @@ export const PromotedStatsItem = ({
|
||||
() =>
|
||||
goodThreshold
|
||||
? goodThreshold(value)
|
||||
? Variant.Success
|
||||
: Variant.Danger
|
||||
: Variant.Highlight,
|
||||
? TailwindIntents.Success
|
||||
: TailwindIntents.Danger
|
||||
: TailwindIntents.Highlight,
|
||||
[goodThreshold, value]
|
||||
);
|
||||
return (
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Tooltip } from '@vegaprotocol/ui-toolkit';
|
||||
import type { StatFields } from '../../config/types';
|
||||
import { useMemo } from 'react';
|
||||
import { Indicator, Variant } from '@vegaprotocol/ui-toolkit';
|
||||
import { Indicator, TailwindIntents } from '@vegaprotocol/ui-toolkit';
|
||||
|
||||
export const defaultFieldFormatter = (field: unknown) =>
|
||||
field === undefined ? 'no data' : field;
|
||||
@ -17,9 +17,9 @@ export const TableRow = ({
|
||||
() =>
|
||||
goodThreshold
|
||||
? goodThreshold(value)
|
||||
? Variant.Success
|
||||
: Variant.Danger
|
||||
: Variant.Highlight,
|
||||
? TailwindIntents.Success
|
||||
: TailwindIntents.Danger
|
||||
: TailwindIntents.Help,
|
||||
[goodThreshold, value]
|
||||
);
|
||||
return (
|
||||
@ -30,7 +30,7 @@ export const TableRow = ({
|
||||
{formatter ? formatter(value) : defaultFieldFormatter(value)}
|
||||
</td>
|
||||
<td className="py-4 px-8">
|
||||
<Indicator variant={variant} />
|
||||
<Indicator variant={TailwindIntents.Success} />
|
||||
</td>
|
||||
</tr>
|
||||
</Tooltip>
|
||||
|
@ -1,8 +1,8 @@
|
||||
import classNames from 'classnames';
|
||||
import type { Variant } from '../../utils/intent';
|
||||
import type { TailwindIntents } from '../../utils/intent';
|
||||
import { getVariantBackground } from '../../utils/intent';
|
||||
|
||||
export const Indicator = ({ variant }: { variant?: Variant }) => {
|
||||
export const Indicator = ({ variant }: { variant?: TailwindIntents }) => {
|
||||
const names = classNames(
|
||||
'inline-block w-8 h-8 mb-2 mr-8 rounded',
|
||||
getVariantBackground(variant)
|
||||
|
@ -1,11 +1,11 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import classNames from 'classnames';
|
||||
import type { Variant } from '../../utils/intent';
|
||||
import { getVariantBackground } from '../../utils/intent';
|
||||
import type { TailwindIntents } from '../../utils/intent';
|
||||
|
||||
interface LozengeProps {
|
||||
children: ReactNode;
|
||||
variant?: Variant;
|
||||
variant?: TailwindIntents;
|
||||
className?: string;
|
||||
details?: string;
|
||||
}
|
||||
|
@ -9,10 +9,12 @@ export enum Intent {
|
||||
Help = 'help',
|
||||
}
|
||||
|
||||
export enum Variant {
|
||||
Success = 'success',
|
||||
Warning = 'warning',
|
||||
export enum TailwindIntents {
|
||||
Danger = 'danger',
|
||||
Warning = 'warning',
|
||||
Prompt = 'prompt',
|
||||
Success = 'success',
|
||||
Help = 'help',
|
||||
Highlight = 'highlight',
|
||||
}
|
||||
|
||||
@ -27,12 +29,13 @@ export const getIntentShadow = (intent?: Intent) => {
|
||||
});
|
||||
};
|
||||
|
||||
export const getVariantBackground = (variant?: Variant) => {
|
||||
export const getVariantBackground = (variant?: TailwindIntents) => {
|
||||
return classNames({
|
||||
'bg-intent-success text-black': variant === Variant.Success,
|
||||
'bg-intent-danger text-white': variant === Variant.Danger,
|
||||
'bg-intent-warning text-black': variant === Variant.Warning,
|
||||
'bg-intent-highlight text-black': variant === Variant.Highlight,
|
||||
'bg-intent-help text-white': !variant,
|
||||
'bg-intent-danger text-white': variant === TailwindIntents.Danger,
|
||||
'bg-intent-warning text-black': variant === TailwindIntents.Warning,
|
||||
'bg-intent-prompt text-black': variant === TailwindIntents.Prompt,
|
||||
'bg-intent-success text-black': variant === TailwindIntents.Success,
|
||||
'bg-intent-help text-white': variant === TailwindIntents.Help,
|
||||
'bg-intent-highlight text-black': variant === TailwindIntents.Highlight,
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user