tabs.stories.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import styled from '@emotion/styled';
  2. import {Item, TabList, TabPanels, Tabs} from 'sentry/components/tabs';
  3. import space from 'sentry/styles/space';
  4. export default {
  5. title: 'Views/Tabs',
  6. component: Tabs,
  7. };
  8. const TABS = [
  9. {key: 'details', label: 'Details', content: 'So by colonel hearted ferrars.'},
  10. {
  11. key: 'activity',
  12. label: 'Activity',
  13. content: 'Draw from upon here gone add one.',
  14. },
  15. {
  16. key: 'user-feedback',
  17. label: 'User Feedback',
  18. content: 'He in sportsman household otherwise it perceived instantly.',
  19. },
  20. {
  21. key: 'attachments',
  22. label: 'Attachments',
  23. content: 'Do play they miss give so up.',
  24. },
  25. {
  26. key: 'tags',
  27. label: 'Tags',
  28. content: 'Words to up style of since world.',
  29. },
  30. {
  31. key: 'disabled',
  32. label: 'Disabled',
  33. content: 'Unreachable content.',
  34. disabled: true,
  35. },
  36. ];
  37. export const Default = args => {
  38. return (
  39. <Tabs {...args}>
  40. <TabList>
  41. {TABS.map(tab => (
  42. <Item key={tab.key} disabled={tab.disabled}>
  43. {tab.label}
  44. </Item>
  45. ))}
  46. </TabList>
  47. <StyledTabPanels orientation={args.orientation}>
  48. {TABS.map(tab => (
  49. <Item key={tab.key}>{tab.content}</Item>
  50. ))}
  51. </StyledTabPanels>
  52. </Tabs>
  53. );
  54. };
  55. Default.storyName = 'Default';
  56. Default.args = {
  57. orientation: 'horizontal',
  58. disabled: false,
  59. value: undefined,
  60. defaultValue: undefined,
  61. };
  62. Default.argTypes = {
  63. orientation: {
  64. options: ['horizontal', 'vertical'],
  65. control: {type: 'radio'},
  66. },
  67. value: {
  68. options: TABS.map(tab => tab.key),
  69. control: {type: 'select'},
  70. },
  71. defaultValue: {
  72. options: TABS.map(tab => tab.key),
  73. control: {type: 'select'},
  74. },
  75. className: {control: {type: 'disabed'}},
  76. };
  77. // To add styles to tab panels, wrap styled() around `TabPanels`, not `Item`
  78. const StyledTabPanels = styled(TabPanels)`
  79. ${p =>
  80. p.orientation === 'horizontal'
  81. ? `padding: ${space(2)} 0;`
  82. : `padding: 0 ${space(2)};`};
  83. color: ${p => p.theme.subText};
  84. `;