Chore: Improve Tagstory (#51677)

This commit is contained in:
Sonja Feitsch 2022-07-06 10:26:34 +02:00 committed by GitHub
parent 2970c6db37
commit 95053b760d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 5 deletions

View File

@ -1,6 +1,8 @@
import { Story, Preview, Props } from '@storybook/addon-docs/blocks';
import { Tag } from './Tag';
<Meta title="MDX|Tag" component={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.

View File

@ -1,10 +1,10 @@
import { action } from '@storybook/addon-actions';
import { Story } from '@storybook/react';
import React from 'react';
import { Tag } from '@grafana/ui';
import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
import { Props as TagProps, Tag } from './Tag';
import mdx from './Tag.mdx';
export default {
@ -15,9 +15,28 @@ export default {
docs: {
page: mdx,
},
controls: {
exclude: ['onClick'],
},
},
args: {
name: 'Tag',
colorIndex: 0,
showIcon: false,
},
};
export const single = () => {
return <Tag name="Tag" onClick={action('Tag clicked')} />;
interface StoryProps extends TagProps {
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}
/>
);
};

View File

@ -64,13 +64,15 @@ const getTagStyles = (theme: GrafanaTheme, name: string, colorIndex?: number) =>
font-weight: ${theme.typography.weight.semibold};
font-size: ${theme.typography.size.sm};
line-height: ${theme.typography.lineHeight.xs};
vertical-align: baseline;
background-color: ${colors.color};
color: ${theme.palette.gray98};
white-space: nowrap;
text-shadow: none;
padding: 3px 6px;
border-radius: ${theme.border.radius.md};
display: flex;
align-items: center;
gap: 3px;
`,
hover: css`
&:hover {