mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Improve Tag
story (#51677)
This commit is contained in:
parent
2970c6db37
commit
95053b760d
@ -1,6 +1,8 @@
|
|||||||
import { Story, Preview, Props } from '@storybook/addon-docs/blocks';
|
import { Story, Preview, Props } from '@storybook/addon-docs/blocks';
|
||||||
import { Tag } from './Tag';
|
import { Tag } from './Tag';
|
||||||
|
|
||||||
|
<Meta title="MDX|Tag" component={Tag} />
|
||||||
|
|
||||||
# Tag
|
# Tag
|
||||||
|
|
||||||
Used for displaying metadata, for example to add more details to search results. Background and border colors are generated from the tag name.
|
Used for displaying metadata, for example to add more details to search results. Background and border colors are generated from the tag name.
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { action } from '@storybook/addon-actions';
|
import { action } from '@storybook/addon-actions';
|
||||||
|
import { Story } from '@storybook/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { Tag } from '@grafana/ui';
|
|
||||||
|
|
||||||
import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
|
import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
|
||||||
|
|
||||||
|
import { Props as TagProps, Tag } from './Tag';
|
||||||
import mdx from './Tag.mdx';
|
import mdx from './Tag.mdx';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -15,9 +15,28 @@ export default {
|
|||||||
docs: {
|
docs: {
|
||||||
page: mdx,
|
page: mdx,
|
||||||
},
|
},
|
||||||
|
controls: {
|
||||||
|
exclude: ['onClick'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
args: {
|
||||||
|
name: 'Tag',
|
||||||
|
colorIndex: 0,
|
||||||
|
showIcon: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const single = () => {
|
interface StoryProps extends TagProps {
|
||||||
return <Tag name="Tag" onClick={action('Tag clicked')} />;
|
showIcon?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Single: Story<StoryProps> = (args) => {
|
||||||
|
return (
|
||||||
|
<Tag
|
||||||
|
name={args.name}
|
||||||
|
colorIndex={args.colorIndex}
|
||||||
|
onClick={action('Tag clicked')}
|
||||||
|
icon={args.showIcon ? args.icon : undefined}
|
||||||
|
/>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
@ -64,13 +64,15 @@ const getTagStyles = (theme: GrafanaTheme, name: string, colorIndex?: number) =>
|
|||||||
font-weight: ${theme.typography.weight.semibold};
|
font-weight: ${theme.typography.weight.semibold};
|
||||||
font-size: ${theme.typography.size.sm};
|
font-size: ${theme.typography.size.sm};
|
||||||
line-height: ${theme.typography.lineHeight.xs};
|
line-height: ${theme.typography.lineHeight.xs};
|
||||||
vertical-align: baseline;
|
|
||||||
background-color: ${colors.color};
|
background-color: ${colors.color};
|
||||||
color: ${theme.palette.gray98};
|
color: ${theme.palette.gray98};
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-shadow: none;
|
text-shadow: none;
|
||||||
padding: 3px 6px;
|
padding: 3px 6px;
|
||||||
border-radius: ${theme.border.radius.md};
|
border-radius: ${theme.border.radius.md};
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 3px;
|
||||||
`,
|
`,
|
||||||
hover: css`
|
hover: css`
|
||||||
&:hover {
|
&:hover {
|
||||||
|
Loading…
Reference in New Issue
Block a user