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