draggableTabBar.stories.tsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import {Fragment, useState} from 'react';
  2. import styled from '@emotion/styled';
  3. import Alert from 'sentry/components/alert';
  4. import {Button} from 'sentry/components/button';
  5. import JSXNode from 'sentry/components/stories/jsxNode';
  6. import SizingWindow from 'sentry/components/stories/sizingWindow';
  7. import storyBook from 'sentry/stories/storyBook';
  8. import {
  9. DraggableTabBar,
  10. type Tab,
  11. } from 'sentry/views/issueList/groupSearchViewTabs/draggableTabBar';
  12. import {IssueSortOptions} from 'sentry/views/issueList/utils';
  13. const TabPanelContainer = styled('div')`
  14. width: 90%;
  15. height: 250px;
  16. background-color: white;
  17. `;
  18. const TABS: Tab[] = [
  19. {
  20. id: 'one',
  21. key: 'one',
  22. label: 'Inbox',
  23. content: <TabPanelContainer>This is the Inbox view</TabPanelContainer>,
  24. queryCount: 1001,
  25. query: '',
  26. querySort: IssueSortOptions.DATE,
  27. },
  28. {
  29. id: 'two',
  30. key: 'two',
  31. label: 'For Review',
  32. content: <TabPanelContainer>This is the For Review view</TabPanelContainer>,
  33. queryCount: 50,
  34. query: '',
  35. querySort: IssueSortOptions.DATE,
  36. },
  37. {
  38. id: 'three',
  39. key: 'three',
  40. label: 'Regressed',
  41. content: <TabPanelContainer>This is the Regressed view</TabPanelContainer>,
  42. queryCount: 100,
  43. query: '',
  44. querySort: IssueSortOptions.DATE,
  45. },
  46. ];
  47. export default storyBook(DraggableTabBar, story => {
  48. story('Default', () => {
  49. const [showTempTab, setShowTempTab] = useState(false);
  50. const [tabs, setTabs] = useState(TABS);
  51. return (
  52. <Fragment>
  53. <Alert type="warning">This component is still a work in progress.</Alert>
  54. <p>
  55. You should be using all of <JSXNode name="Tabs" />, <JSXNode name="TabList" />,{' '}
  56. <JSXNode name="TabList.Item" />, <JSXNode name="DroppableTabPanels" /> and
  57. <JSXNode name="DroppableTabPanels.Item" /> components.
  58. </p>
  59. <p>
  60. This will give you all kinds of accessibility and state tracking out of the box.
  61. But you will have to render all tab content, including hooks, upfront.
  62. </p>
  63. <SizingWindow style={{flexDirection: 'column', alignItems: 'flex-start'}}>
  64. <StyledButton onClick={() => setShowTempTab(!showTempTab)}>
  65. Toggle Temporary View
  66. </StyledButton>
  67. <TabBarContainer>
  68. <DraggableTabBar
  69. tabs={tabs}
  70. setTabs={setTabs}
  71. onDiscardTempView={() => {
  72. setShowTempTab(false);
  73. }}
  74. orgSlug={'sentry'}
  75. router={{} as any}
  76. />
  77. </TabBarContainer>
  78. </SizingWindow>
  79. </Fragment>
  80. );
  81. });
  82. });
  83. const StyledButton = styled(Button)`
  84. justify-content: start;
  85. margin-bottom: 5px;
  86. `;
  87. const TabBarContainer = styled('div')`
  88. display: flex;
  89. justify-content: start;
  90. width: 90%;
  91. height: 300px;
  92. `;