2025-05-29 22:11:59 +08:00
|
|
|
/* eslint-disable @grafana/i18n/no-untranslated-strings */
|
2021-04-08 01:13:00 +08:00
|
|
|
import { css, cx } from '@emotion/css';
|
2025-07-29 16:30:18 +08:00
|
|
|
import { useId, useState } from 'react';
|
2024-06-25 19:43:47 +08:00
|
|
|
import * as React from 'react';
|
2022-04-22 21:33:13 +08:00
|
|
|
|
2025-07-29 16:30:18 +08:00
|
|
|
import { colorManipulator, GrafanaTheme2, ThemeRichColor, ThemeVizHue } from '@grafana/data';
|
2022-04-22 21:33:13 +08:00
|
|
|
|
|
|
|
import { useTheme2 } from '../../themes/ThemeContext';
|
2025-06-10 21:51:53 +08:00
|
|
|
import { allButtonVariants, Button } from '../Button/Button';
|
2022-04-22 21:33:13 +08:00
|
|
|
import { Card } from '../Card/Card';
|
2021-04-08 01:13:00 +08:00
|
|
|
import { CollapsableSection } from '../Collapse/CollapsableSection';
|
2025-03-11 22:55:30 +08:00
|
|
|
import { Combobox } from '../Combobox/Combobox';
|
2021-04-08 01:13:00 +08:00
|
|
|
import { Field } from '../Forms/Field';
|
2021-04-12 20:23:00 +08:00
|
|
|
import { InlineField } from '../Forms/InlineField';
|
|
|
|
import { InlineFieldRow } from '../Forms/InlineFieldRow';
|
2022-04-22 21:33:13 +08:00
|
|
|
import { RadioButtonGroup } from '../Forms/RadioButtonGroup/RadioButtonGroup';
|
|
|
|
import { Icon } from '../Icon/Icon';
|
|
|
|
import { Input } from '../Input/Input';
|
2025-02-11 19:27:04 +08:00
|
|
|
import { BackgroundColor, BorderColor, Box, BoxShadow } from '../Layout/Box/Box';
|
2024-04-11 00:23:31 +08:00
|
|
|
import { Stack } from '../Layout/Stack/Stack';
|
2025-10-02 20:06:49 +08:00
|
|
|
import { ScrollContainer } from '../ScrollContainer/ScrollContainer';
|
2022-04-22 21:33:13 +08:00
|
|
|
import { Switch } from '../Switch/Switch';
|
2024-04-11 00:23:31 +08:00
|
|
|
import { Text, TextProps } from '../Text/Text';
|
2021-04-08 01:13:00 +08:00
|
|
|
|
|
|
|
interface DemoBoxProps {
|
2024-04-11 00:23:31 +08:00
|
|
|
bg?: BackgroundColor;
|
|
|
|
border?: BorderColor;
|
2025-10-02 20:06:49 +08:00
|
|
|
scrollable?: boolean;
|
2025-02-11 19:27:04 +08:00
|
|
|
shadow?: BoxShadow;
|
2024-04-11 00:23:31 +08:00
|
|
|
textColor?: TextProps['color'];
|
2021-04-08 01:13:00 +08:00
|
|
|
}
|
|
|
|
|
2025-10-02 20:06:49 +08:00
|
|
|
const DemoBox = ({ bg, border, children, shadow, scrollable }: React.PropsWithChildren<DemoBoxProps>) => {
|
|
|
|
const MaybeScroll = scrollable ? ScrollContainer : React.Fragment;
|
2024-04-11 00:23:31 +08:00
|
|
|
return (
|
2025-02-11 19:27:04 +08:00
|
|
|
<Box
|
|
|
|
backgroundColor={bg ? bg : undefined}
|
|
|
|
padding={2}
|
|
|
|
borderStyle={border ? 'solid' : undefined}
|
|
|
|
borderColor={border}
|
|
|
|
boxShadow={shadow}
|
2025-10-03 17:07:36 +08:00
|
|
|
borderRadius={'lg'}
|
2025-02-11 19:27:04 +08:00
|
|
|
>
|
2025-10-02 20:06:49 +08:00
|
|
|
<MaybeScroll>{children}</MaybeScroll>
|
2024-04-11 00:23:31 +08:00
|
|
|
</Box>
|
2021-04-08 01:13:00 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-03-09 00:12:54 +08:00
|
|
|
const DemoText = ({
|
|
|
|
color,
|
|
|
|
bold,
|
|
|
|
children,
|
2024-04-11 00:23:31 +08:00
|
|
|
}: React.PropsWithChildren<{ color?: TextProps['color']; bold?: boolean; size?: number }>) => {
|
|
|
|
return (
|
|
|
|
<Box padding={0.5}>
|
|
|
|
{children && (
|
|
|
|
<Text color={color ? color : undefined} weight={bold ? 'bold' : undefined}>
|
|
|
|
{children}
|
|
|
|
</Text>
|
|
|
|
)}
|
|
|
|
</Box>
|
|
|
|
);
|
2021-04-08 01:13:00 +08:00
|
|
|
};
|
|
|
|
|
2021-04-12 20:23:00 +08:00
|
|
|
export const ThemeDemo = () => {
|
2021-04-08 01:13:00 +08:00
|
|
|
const [radioValue, setRadioValue] = useState('v');
|
|
|
|
const [boolValue, setBoolValue] = useState(false);
|
2021-04-12 20:23:00 +08:00
|
|
|
const [selectValue, setSelectValue] = useState('Item 2');
|
2021-04-21 20:25:43 +08:00
|
|
|
const t = useTheme2();
|
2025-07-29 16:30:18 +08:00
|
|
|
const inputId = useId();
|
|
|
|
const disabledInputId = useId();
|
|
|
|
const comboboxId = useId();
|
|
|
|
const radioId = useId();
|
|
|
|
const switchId = useId();
|
|
|
|
const switchTrueId = useId();
|
|
|
|
const switchDisabledId = useId();
|
|
|
|
const inlineId = useId();
|
|
|
|
const inlineDisabledId = useId();
|
2021-04-08 01:13:00 +08:00
|
|
|
|
|
|
|
const richColors = [
|
2021-04-21 21:34:08 +08:00
|
|
|
t.colors.primary,
|
|
|
|
t.colors.secondary,
|
|
|
|
t.colors.success,
|
|
|
|
t.colors.error,
|
|
|
|
t.colors.warning,
|
|
|
|
t.colors.info,
|
2021-04-08 01:13:00 +08:00
|
|
|
];
|
|
|
|
|
2025-05-03 00:42:02 +08:00
|
|
|
const vizColors = t.visualization.hues;
|
|
|
|
|
2021-04-12 20:23:00 +08:00
|
|
|
const selectOptions = [
|
|
|
|
{ label: 'Item 1', value: 'Item 1' },
|
|
|
|
{ label: 'Item 2', value: 'Item 2' },
|
|
|
|
{ label: 'Item 3', value: 'Item 3' },
|
|
|
|
{ label: 'Item 4', value: 'Item 4' },
|
|
|
|
];
|
2021-04-08 01:13:00 +08:00
|
|
|
const radioOptions = [
|
|
|
|
{ value: 'h', label: 'Horizontal' },
|
|
|
|
{ value: 'v', label: 'Vertical' },
|
|
|
|
{ value: 'a', label: 'Auto' },
|
|
|
|
];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
2023-07-17 23:12:09 +08:00
|
|
|
className={css({
|
|
|
|
width: '100%',
|
|
|
|
color: t.colors.text.primary,
|
|
|
|
})}
|
2021-04-08 01:13:00 +08:00
|
|
|
>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoBox bg="canvas">
|
2021-04-08 01:13:00 +08:00
|
|
|
<CollapsableSection label="Layers" isOpen={true}>
|
2021-04-21 21:34:08 +08:00
|
|
|
<DemoText>t.colors.background.canvas</DemoText>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoBox bg="primary" border="weak">
|
2021-04-21 21:34:08 +08:00
|
|
|
<DemoText>t.colors.background.primary is the main & preferred content </DemoText>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoBox bg="secondary" border="weak">
|
2025-02-11 19:27:04 +08:00
|
|
|
<DemoText>t.colors.background.secondary (Used for cards)</DemoText>
|
2021-04-08 01:13:00 +08:00
|
|
|
</DemoBox>
|
2025-02-11 19:27:04 +08:00
|
|
|
<Box padding={4}>
|
|
|
|
<DemoText>t.colors.background.elevated</DemoText>
|
|
|
|
<DemoBox bg="elevated" border="weak" shadow="z3">
|
|
|
|
This elevated color should be used for menus and popovers.
|
|
|
|
</DemoBox>
|
|
|
|
</Box>
|
2021-04-08 01:13:00 +08:00
|
|
|
</DemoBox>
|
|
|
|
</CollapsableSection>
|
|
|
|
<CollapsableSection label="Text colors" isOpen={true}>
|
2025-10-02 20:06:49 +08:00
|
|
|
<Stack justifyContent="flex-start" wrap="wrap">
|
2021-04-08 01:13:00 +08:00
|
|
|
<DemoBox>
|
|
|
|
<TextColors t={t} />
|
|
|
|
</DemoBox>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoBox bg="primary">
|
2021-04-08 01:13:00 +08:00
|
|
|
<TextColors t={t} />
|
|
|
|
</DemoBox>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoBox bg="secondary">
|
2021-04-08 01:13:00 +08:00
|
|
|
<TextColors t={t} />
|
|
|
|
</DemoBox>
|
2024-04-11 00:23:31 +08:00
|
|
|
</Stack>
|
2021-04-08 01:13:00 +08:00
|
|
|
</CollapsableSection>
|
|
|
|
<CollapsableSection label="Rich colors" isOpen={true}>
|
2025-10-02 20:06:49 +08:00
|
|
|
<DemoBox bg="primary" scrollable>
|
2025-10-03 17:07:36 +08:00
|
|
|
<table className={colorsTableStyle(t)}>
|
2021-04-08 01:13:00 +08:00
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<td>name</td>
|
|
|
|
<td>main</td>
|
2021-04-12 20:23:00 +08:00
|
|
|
<td>shade (used for hover)</td>
|
2023-04-21 17:09:46 +08:00
|
|
|
<td>transparent</td>
|
2021-04-08 01:13:00 +08:00
|
|
|
<td>border & text</td>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{richColors.map((color) => (
|
|
|
|
<RichColorDemo key={color.name} color={color} theme={t} />
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</DemoBox>
|
|
|
|
</CollapsableSection>
|
2025-05-03 00:42:02 +08:00
|
|
|
<CollapsableSection label="Viz hues" isOpen={true}>
|
2025-10-02 20:06:49 +08:00
|
|
|
<DemoBox bg="primary" scrollable>
|
2025-10-03 17:07:36 +08:00
|
|
|
<table className={colorsTableStyle(t)}>
|
2025-05-03 00:42:02 +08:00
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<td>name</td>
|
|
|
|
<td>super-light</td>
|
|
|
|
<td>light</td>
|
|
|
|
<td>primary</td>
|
|
|
|
<td>semi-dark</td>
|
|
|
|
<td>dark</td>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
{vizColors.map((color) => (
|
|
|
|
<VizHuesDemo key={color.name} color={color} theme={t} />
|
|
|
|
))}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</DemoBox>
|
|
|
|
</CollapsableSection>
|
2021-04-08 01:13:00 +08:00
|
|
|
<CollapsableSection label="Forms" isOpen={true}>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoBox bg="primary">
|
2021-04-08 01:13:00 +08:00
|
|
|
<Field label="Input label" description="Field description">
|
2025-07-29 16:30:18 +08:00
|
|
|
<Input id={inputId} placeholder="Placeholder" />
|
2021-04-08 01:13:00 +08:00
|
|
|
</Field>
|
|
|
|
<Field label="Input disabled" disabled>
|
2025-07-29 16:30:18 +08:00
|
|
|
<Input id={disabledInputId} placeholder="Placeholder" value="Disabled value" />
|
2021-04-08 01:13:00 +08:00
|
|
|
</Field>
|
2025-03-11 22:55:30 +08:00
|
|
|
<Field label="Combobox">
|
2025-07-29 16:30:18 +08:00
|
|
|
<Combobox
|
|
|
|
id={comboboxId}
|
|
|
|
options={selectOptions}
|
|
|
|
value={selectValue}
|
|
|
|
onChange={(v) => setSelectValue(v?.value!)}
|
|
|
|
/>
|
2021-04-12 20:23:00 +08:00
|
|
|
</Field>
|
2021-04-08 01:13:00 +08:00
|
|
|
<Field label="Radio label">
|
2025-07-29 16:30:18 +08:00
|
|
|
<RadioButtonGroup id={radioId} options={radioOptions} value={radioValue} onChange={setRadioValue} />
|
2021-04-08 01:13:00 +08:00
|
|
|
</Field>
|
2024-04-11 00:23:31 +08:00
|
|
|
<Stack>
|
2021-04-08 01:13:00 +08:00
|
|
|
<Field label="Switch">
|
2025-07-29 16:30:18 +08:00
|
|
|
<Switch id={switchId} value={boolValue} onChange={(e) => setBoolValue(e.currentTarget.checked)} />
|
2021-04-08 01:13:00 +08:00
|
|
|
</Field>
|
|
|
|
<Field label="Switch true">
|
2025-07-29 16:30:18 +08:00
|
|
|
<Switch id={switchTrueId} value={true} />
|
2021-04-08 01:13:00 +08:00
|
|
|
</Field>
|
2021-04-20 23:10:05 +08:00
|
|
|
<Field label="Switch false disabled" disabled={true}>
|
2025-07-29 16:30:18 +08:00
|
|
|
<Switch id={switchDisabledId} value={false} />
|
2021-04-08 01:13:00 +08:00
|
|
|
</Field>
|
2024-04-11 00:23:31 +08:00
|
|
|
</Stack>
|
|
|
|
<Stack direction="column">
|
2021-04-12 20:23:00 +08:00
|
|
|
<div>Inline forms</div>
|
|
|
|
<InlineFieldRow>
|
|
|
|
<InlineField label="Label">
|
2025-07-29 16:30:18 +08:00
|
|
|
<Input id={inlineId} placeholder="Placeholder" />
|
2021-04-12 20:23:00 +08:00
|
|
|
</InlineField>
|
|
|
|
<InlineField label="Another Label" disabled>
|
2025-07-29 16:30:18 +08:00
|
|
|
<Input id={inlineDisabledId} placeholder="Disabled" />
|
2021-04-12 20:23:00 +08:00
|
|
|
</InlineField>
|
|
|
|
</InlineFieldRow>
|
2024-04-11 00:23:31 +08:00
|
|
|
</Stack>
|
2021-04-08 01:13:00 +08:00
|
|
|
</DemoBox>
|
|
|
|
</CollapsableSection>
|
|
|
|
<CollapsableSection label="Shadows" isOpen={true}>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoBox bg="primary">
|
|
|
|
<Stack>
|
2023-10-24 18:53:22 +08:00
|
|
|
{Object.entries(t.shadows).map(([key, value]) => (
|
|
|
|
<ShadowDemo name={key} shadow={value} key={key} />
|
2021-04-12 20:23:00 +08:00
|
|
|
))}
|
2024-04-11 00:23:31 +08:00
|
|
|
</Stack>
|
2021-04-08 01:13:00 +08:00
|
|
|
</DemoBox>
|
|
|
|
</CollapsableSection>
|
|
|
|
<CollapsableSection label="Buttons" isOpen={true}>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoBox bg="primary">
|
|
|
|
<Stack direction="column" gap={3}>
|
2025-10-02 20:06:49 +08:00
|
|
|
<Stack wrap="wrap">
|
2021-04-12 20:23:00 +08:00
|
|
|
{allButtonVariants.map((variant) => (
|
|
|
|
<Button variant={variant} key={variant}>
|
|
|
|
{variant}
|
|
|
|
</Button>
|
|
|
|
))}
|
|
|
|
<Button variant="primary" disabled>
|
|
|
|
Disabled
|
2021-04-08 01:13:00 +08:00
|
|
|
</Button>
|
2024-04-11 00:23:31 +08:00
|
|
|
</Stack>
|
2025-05-22 17:03:58 +08:00
|
|
|
<Card noMargin>
|
2022-01-06 23:48:12 +08:00
|
|
|
<Card.Heading>Button inside card</Card.Heading>
|
2021-04-12 20:23:00 +08:00
|
|
|
<Card.Actions>
|
2022-01-06 23:48:12 +08:00
|
|
|
{allButtonVariants.map((variant) => (
|
|
|
|
<Button variant={variant} key={variant}>
|
|
|
|
{variant}
|
2021-04-12 20:23:00 +08:00
|
|
|
</Button>
|
2022-01-06 23:48:12 +08:00
|
|
|
))}
|
|
|
|
<Button variant="primary" disabled>
|
|
|
|
Disabled
|
|
|
|
</Button>
|
2021-04-12 20:23:00 +08:00
|
|
|
</Card.Actions>
|
|
|
|
</Card>
|
2024-04-11 00:23:31 +08:00
|
|
|
</Stack>
|
2021-04-08 01:13:00 +08:00
|
|
|
</DemoBox>
|
|
|
|
</CollapsableSection>
|
2021-04-12 20:23:00 +08:00
|
|
|
<CollapsableSection label="Actions" isOpen={true}>
|
|
|
|
<ActionsDemo />
|
|
|
|
</CollapsableSection>
|
2021-04-08 01:13:00 +08:00
|
|
|
</DemoBox>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2025-05-03 00:42:02 +08:00
|
|
|
interface VizHuesDemoProps {
|
|
|
|
color: ThemeVizHue;
|
|
|
|
theme: GrafanaTheme2;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function VizHuesDemo({ theme, color }: VizHuesDemoProps) {
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>{color.name}</td>
|
2025-05-22 17:03:58 +08:00
|
|
|
{color.shades.map((shade, index) => (
|
|
|
|
<td key={index}>
|
2025-05-03 00:42:02 +08:00
|
|
|
<div
|
|
|
|
className={css({
|
|
|
|
background: shade.color,
|
|
|
|
borderRadius: theme.shape.radius.default,
|
2025-07-29 16:30:18 +08:00
|
|
|
color: colorManipulator.getContrastRatio('#FFFFFF', shade.color) >= 4.5 ? '#FFFFFF' : '#000000',
|
2025-05-03 00:42:02 +08:00
|
|
|
padding: theme.spacing(1),
|
|
|
|
})}
|
|
|
|
>
|
|
|
|
{shade.color}
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
))}
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-04-08 01:13:00 +08:00
|
|
|
interface RichColorDemoProps {
|
2021-05-03 15:45:54 +08:00
|
|
|
theme: GrafanaTheme2;
|
2021-04-21 21:34:08 +08:00
|
|
|
color: ThemeRichColor;
|
2021-04-08 01:13:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export function RichColorDemo({ theme, color }: RichColorDemoProps) {
|
|
|
|
return (
|
|
|
|
<tr>
|
|
|
|
<td>{color.name}</td>
|
|
|
|
<td>
|
|
|
|
<div
|
2023-07-17 23:12:09 +08:00
|
|
|
className={css({
|
|
|
|
background: color.main,
|
2023-08-01 18:44:25 +08:00
|
|
|
borderRadius: theme.shape.radius.default,
|
2023-07-17 23:12:09 +08:00
|
|
|
color: color.contrastText,
|
2025-10-03 17:07:36 +08:00
|
|
|
padding: theme.spacing(1),
|
2023-07-17 23:12:09 +08:00
|
|
|
fontWeight: 500,
|
|
|
|
})}
|
2021-04-08 01:13:00 +08:00
|
|
|
>
|
|
|
|
{color.main}
|
|
|
|
</div>
|
|
|
|
</td>
|
2021-04-12 20:23:00 +08:00
|
|
|
<td>
|
|
|
|
<div
|
2023-07-17 23:12:09 +08:00
|
|
|
className={css({
|
|
|
|
background: color.shade,
|
2025-09-11 20:10:41 +08:00
|
|
|
color: theme.colors.getContrastText(color.shade, 4.5),
|
2023-08-01 18:44:25 +08:00
|
|
|
borderRadius: theme.shape.radius.default,
|
2025-10-03 17:07:36 +08:00
|
|
|
padding: theme.spacing(1),
|
2023-07-17 23:12:09 +08:00
|
|
|
})}
|
2021-04-12 20:23:00 +08:00
|
|
|
>
|
|
|
|
{color.shade}
|
|
|
|
</div>
|
|
|
|
</td>
|
2023-04-21 17:09:46 +08:00
|
|
|
<td>
|
|
|
|
<div
|
2023-07-17 23:12:09 +08:00
|
|
|
className={css({
|
|
|
|
background: color.transparent,
|
2023-08-01 18:44:25 +08:00
|
|
|
borderRadius: theme.shape.radius.default,
|
2025-10-03 17:07:36 +08:00
|
|
|
padding: theme.spacing(1),
|
2023-07-17 23:12:09 +08:00
|
|
|
})}
|
2023-04-21 17:09:46 +08:00
|
|
|
>
|
|
|
|
{color.shade}
|
|
|
|
</div>
|
|
|
|
</td>
|
2021-04-08 01:13:00 +08:00
|
|
|
<td>
|
|
|
|
<div
|
2023-07-17 23:12:09 +08:00
|
|
|
className={css({
|
|
|
|
border: `1px solid ${color.border}`,
|
|
|
|
color: color.text,
|
2023-08-01 18:44:25 +08:00
|
|
|
borderRadius: theme.shape.radius.default,
|
2025-10-03 17:07:36 +08:00
|
|
|
padding: theme.spacing(1),
|
2023-07-17 23:12:09 +08:00
|
|
|
})}
|
2021-04-08 01:13:00 +08:00
|
|
|
>
|
|
|
|
{color.text}
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2025-10-03 17:07:36 +08:00
|
|
|
const colorsTableStyle = (theme: GrafanaTheme2) =>
|
|
|
|
css({
|
2023-07-17 23:12:09 +08:00
|
|
|
textAlign: 'center',
|
2025-10-03 17:07:36 +08:00
|
|
|
overflow: 'auto',
|
|
|
|
|
|
|
|
td: {
|
|
|
|
padding: theme.spacing(1),
|
|
|
|
textAlign: 'center',
|
|
|
|
},
|
|
|
|
});
|
2021-04-08 01:13:00 +08:00
|
|
|
|
2021-05-03 15:45:54 +08:00
|
|
|
export function TextColors({ t }: { t: GrafanaTheme2 }) {
|
2021-04-08 01:13:00 +08:00
|
|
|
return (
|
|
|
|
<>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoText color="primary">
|
2021-04-08 01:13:00 +08:00
|
|
|
text.primary <Icon name="trash-alt" />
|
|
|
|
</DemoText>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoText color="secondary">
|
2021-04-08 01:13:00 +08:00
|
|
|
text.secondary <Icon name="trash-alt" />
|
|
|
|
</DemoText>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoText color="disabled">
|
2021-04-08 01:13:00 +08:00
|
|
|
text.disabled <Icon name="trash-alt" />
|
|
|
|
</DemoText>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoText color="primary">
|
2021-04-08 01:13:00 +08:00
|
|
|
primary.text <Icon name="trash-alt" />
|
|
|
|
</DemoText>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export function ShadowDemo({ name, shadow }: { name: string; shadow: string }) {
|
2025-10-03 17:07:36 +08:00
|
|
|
const t = useTheme2();
|
2021-04-08 01:13:00 +08:00
|
|
|
const style = css({
|
2025-10-03 17:07:36 +08:00
|
|
|
padding: t.spacing(2),
|
|
|
|
borderRadius: t.shape.radius.default,
|
2021-04-08 01:13:00 +08:00
|
|
|
boxShadow: shadow,
|
|
|
|
});
|
|
|
|
return <div className={style}>{name}</div>;
|
|
|
|
}
|
2021-04-12 20:23:00 +08:00
|
|
|
|
|
|
|
export function ActionsDemo() {
|
2021-04-21 20:25:43 +08:00
|
|
|
const t = useTheme2();
|
2021-04-12 20:23:00 +08:00
|
|
|
|
|
|
|
const item = css({
|
2025-10-03 17:07:36 +08:00
|
|
|
borderRadius: t.shape.radius.default,
|
|
|
|
padding: t.spacing(1),
|
2021-04-12 20:23:00 +08:00
|
|
|
':hover': {
|
2021-04-21 21:34:08 +08:00
|
|
|
background: t.colors.action.hover,
|
2021-04-12 20:23:00 +08:00
|
|
|
},
|
|
|
|
});
|
|
|
|
const hover = css({
|
2021-04-21 21:34:08 +08:00
|
|
|
background: t.colors.action.hover,
|
2021-04-12 20:23:00 +08:00
|
|
|
});
|
|
|
|
const selected = css({
|
2021-04-21 21:34:08 +08:00
|
|
|
background: t.colors.action.selected,
|
2021-04-12 20:23:00 +08:00
|
|
|
});
|
|
|
|
const focused = css({
|
2021-04-21 21:34:08 +08:00
|
|
|
background: t.colors.action.focus,
|
2021-04-12 20:23:00 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
return (
|
2024-04-11 00:23:31 +08:00
|
|
|
<Stack justifyContent="flex-start">
|
|
|
|
<DemoBox bg="canvas">
|
|
|
|
<Stack direction="column">
|
2021-04-12 20:23:00 +08:00
|
|
|
<div className={item}>item</div>
|
|
|
|
<div className={item}>item</div>
|
|
|
|
<div className={cx(item, hover)}>item hover</div>
|
|
|
|
<div className={cx(item, selected)}>item selected</div>
|
|
|
|
<div className={cx(item, focused)}>item focused</div>
|
2024-04-11 00:23:31 +08:00
|
|
|
</Stack>
|
2021-04-12 20:23:00 +08:00
|
|
|
</DemoBox>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoBox bg="primary">
|
|
|
|
<Stack direction="column">
|
2021-04-12 20:23:00 +08:00
|
|
|
<div className={item}>item</div>
|
|
|
|
<div className={item}>item</div>
|
|
|
|
<div className={cx(item, hover)}>item hover</div>
|
|
|
|
<div className={cx(item, selected)}>item selected</div>
|
|
|
|
<div className={cx(item, focused)}>item focused</div>
|
2024-04-11 00:23:31 +08:00
|
|
|
</Stack>
|
2021-04-12 20:23:00 +08:00
|
|
|
</DemoBox>
|
2024-04-11 00:23:31 +08:00
|
|
|
<DemoBox bg="secondary">
|
|
|
|
<Stack direction="column">
|
2021-04-12 20:23:00 +08:00
|
|
|
<div className={item}>item</div>
|
|
|
|
<div className={item}>item</div>
|
|
|
|
<div className={cx(item, hover)}>item hover</div>
|
|
|
|
<div className={cx(item, selected)}>item selected</div>
|
|
|
|
<div className={cx(item, focused)}>item focused</div>
|
2024-04-11 00:23:31 +08:00
|
|
|
</Stack>
|
2021-04-12 20:23:00 +08:00
|
|
|
</DemoBox>
|
2024-04-11 00:23:31 +08:00
|
|
|
</Stack>
|
2021-04-12 20:23:00 +08:00
|
|
|
);
|
|
|
|
}
|