sidebarSection.stories.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import styled from '@emotion/styled';
  2. import {KeyValueTable, KeyValueTableRow} from 'sentry/components/keyValueTable';
  3. import QuestionTooltip from 'sentry/components/questionTooltip';
  4. import * as SidebarSection from 'sentry/components/sidebarSection';
  5. import Tag from 'sentry/components/tag';
  6. import TextOverflow from 'sentry/components/textOverflow';
  7. import {Tooltip} from 'sentry/components/tooltip';
  8. import {space} from 'sentry/styles/space';
  9. export default {
  10. title: 'Views/Sidebar Section',
  11. component: SidebarSection,
  12. argTypes: {
  13. title: {control: {type: 'text'}},
  14. icon: {
  15. control: {type: 'boolean'},
  16. },
  17. },
  18. };
  19. export const Default = ({title, icon}) => (
  20. <SidebarSection.Wrap>
  21. <SidebarSection.Title>
  22. {title}
  23. {icon && <QuestionTooltip position="top" title="Tooltip description" size="sm" />}
  24. </SidebarSection.Title>
  25. <SidebarSection.Content>{'16 hours'}</SidebarSection.Content>
  26. </SidebarSection.Wrap>
  27. );
  28. Default.storyName = 'With text';
  29. Default.parameters = {
  30. docs: {
  31. description: {
  32. story: 'Generic sidebar section with text.',
  33. },
  34. },
  35. };
  36. Default.args = {
  37. title: 'Subheading',
  38. icon: false,
  39. };
  40. export const WithIconTagsText = ({title, icon}) => (
  41. <SidebarSection.Wrap>
  42. <SidebarSection.Title>
  43. {title}
  44. {icon && <QuestionTooltip position="top" title="Tooltip description" size="sm" />}
  45. </SidebarSection.Title>
  46. <SidebarSection.Content>
  47. <Tooltip title="Tooltip description" isHoverable>
  48. <Tag type="default">{'Adopted'}</Tag>
  49. </Tooltip>
  50. <Environment>{'in production'}</Environment>
  51. </SidebarSection.Content>
  52. </SidebarSection.Wrap>
  53. );
  54. WithIconTagsText.storyName = 'With Icon, Tags, and Text';
  55. WithIconTagsText.parameters = {
  56. docs: {
  57. description: {
  58. story: 'Sidebar section that has an icon, tag, and text.',
  59. },
  60. },
  61. };
  62. WithIconTagsText.args = {
  63. title: 'Icon, Tag, and Text',
  64. icon: true,
  65. };
  66. export const WithRows = ({title, icon}) => (
  67. <SidebarSection.Wrap>
  68. <SidebarSection.Title>
  69. {title}
  70. {icon && <QuestionTooltip position="top" title="Tooltip description" size="sm" />}
  71. </SidebarSection.Title>
  72. <SidebarSection.Content>
  73. <KeyValueTable>
  74. <KeyValueTableRow
  75. keyName="Created"
  76. value={<StyledTextOverflow>{'Nov 17, 2021 5:36 PM'}</StyledTextOverflow>}
  77. />
  78. <KeyValueTableRow
  79. keyName="Version"
  80. value={<StyledTextOverflow>{'3.3.3'}</StyledTextOverflow>}
  81. />
  82. <KeyValueTableRow
  83. keyName="Package"
  84. value={<StyledTextOverflow>{'frontend'}</StyledTextOverflow>}
  85. />
  86. <KeyValueTableRow
  87. keyName="First Event"
  88. value={<StyledTextOverflow>{'\u2014'}</StyledTextOverflow>}
  89. />
  90. <KeyValueTableRow
  91. keyName="Last Event"
  92. value={<StyledTextOverflow>{'\u2014'}</StyledTextOverflow>}
  93. />
  94. <KeyValueTableRow
  95. keyName="Source Maps"
  96. value={<StyledTextOverflow>{'333 artifacts'}</StyledTextOverflow>}
  97. />
  98. </KeyValueTable>
  99. </SidebarSection.Content>
  100. </SidebarSection.Wrap>
  101. );
  102. WithRows.storyName = 'With Multiple Rows';
  103. WithRows.parameters = {
  104. docs: {
  105. description: {
  106. story:
  107. 'Section of the sidebar with multiple rows using the KeyValueTable component (label with date, etc).',
  108. },
  109. },
  110. };
  111. WithRows.args = {
  112. title: 'With Multiple Rows',
  113. icon: false,
  114. };
  115. const Environment = styled('span')`
  116. color: ${p => p.theme.textColor};
  117. margin-left: ${space(0.5)};
  118. font-size: ${p => p.theme.fontSizeSmall};
  119. `;
  120. const StyledTextOverflow = styled(TextOverflow)`
  121. line-height: inherit;
  122. text-align: right;
  123. `;