tag.stories.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import styled from '@emotion/styled';
  2. import Tag from 'sentry/components/tag';
  3. import {IconClock, IconDelete, IconFire, IconIssues, IconWarning} from 'sentry/icons';
  4. import {toTitleCase} from 'sentry/utils';
  5. import theme from 'sentry/utils/theme';
  6. export default {
  7. title: 'Components/Tags',
  8. component: Tag,
  9. argTypes: {
  10. tooltipText: {
  11. type: 'string',
  12. },
  13. to: {
  14. table: {
  15. disable: true,
  16. },
  17. },
  18. icon: {
  19. table: {
  20. disable: true,
  21. },
  22. },
  23. onDismiss: {
  24. table: {
  25. disable: true,
  26. },
  27. },
  28. href: {
  29. table: {
  30. disable: true,
  31. },
  32. },
  33. },
  34. };
  35. const types = Object.keys(theme.tag);
  36. export const Basic = () => (
  37. <Wrapper>
  38. {types.map(type => (
  39. <Tag key={type} type={type}>
  40. {toTitleCase(type)}
  41. </Tag>
  42. ))}
  43. </Wrapper>
  44. );
  45. Basic.storyName = 'Basic';
  46. export const WithIcon = ({...args}) => (
  47. <div>
  48. <Tag icon={<IconFire />} {...args}>
  49. Error
  50. </Tag>{' '}
  51. <Tag icon={<IconWarning />} {...args}>
  52. Error
  53. </Tag>{' '}
  54. <Tag icon={<IconClock />} {...args}>
  55. Error
  56. </Tag>{' '}
  57. <Tag icon={<IconDelete />} {...args}>
  58. Error
  59. </Tag>{' '}
  60. <Tag icon={<IconIssues />} {...args}>
  61. Error
  62. </Tag>
  63. </div>
  64. );
  65. WithIcon.storyName = 'With Icon';
  66. export const WithTooltip = ({type}) => (
  67. <Tag type={type} tooltipText="lorem ipsum">
  68. children
  69. </Tag>
  70. );
  71. WithTooltip.storyName = 'With Tooltip';
  72. WithTooltip.args = {
  73. type: 'highlight',
  74. };
  75. WithTooltip.argTypes = {
  76. type: {
  77. control: {
  78. type: 'select',
  79. options: types,
  80. },
  81. },
  82. };
  83. export const WithDismiss = ({...args}) => <Tag {...args}>Dismissable</Tag>;
  84. WithDismiss.storyName = 'With Dismiss';
  85. WithDismiss.argTypes = {
  86. onDismiss: {action: 'dismissed'},
  87. };
  88. export const WithInternalLink = () => (
  89. <Tag to="/organizations/sentry/issues/">Internal link</Tag>
  90. );
  91. WithInternalLink.storyName = 'With Internal Link';
  92. export const WithExternalLink = () => <Tag href="https://sentry.io/">External link</Tag>;
  93. WithExternalLink.storyName = 'With External Link';
  94. const Wrapper = styled('div')`
  95. display: grid;
  96. `;