pageBanner.stories.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import {Fragment, useState} from 'react';
  2. import styled from '@emotion/styled';
  3. import replaysDeadRageBackground from 'sentry-images/spot/replay-dead-rage-changelog.svg';
  4. import {Button, LinkButton} from 'sentry/components/button';
  5. import ExternalLink from 'sentry/components/links/externalLink';
  6. import PageBanner from 'sentry/components/replays/pageBanner';
  7. import SizingWindow from 'sentry/components/stories/sizingWindow';
  8. import {IconBroadcast} from 'sentry/icons';
  9. import storyBook from 'sentry/stories/storyBook';
  10. export default storyBook(PageBanner, story => {
  11. const storiesButton = (
  12. <LinkButton
  13. external
  14. href="https://sentry.io/orgredirect/organizations/:orgslug/stories"
  15. priority="primary"
  16. >
  17. View Stories
  18. </LinkButton>
  19. );
  20. story('Example', () => (
  21. <Fragment>
  22. <p>Here's an example Banner announcing this UI Component Library:</p>
  23. <PageBanner
  24. button={storiesButton}
  25. description="Build new products faster by exploring reusable the UI components available inside Sentry."
  26. heading="Introducing the UI Component Library"
  27. icon={<IconBroadcast size="sm" />}
  28. image={replaysDeadRageBackground}
  29. title="UI Library Available"
  30. />
  31. </Fragment>
  32. ));
  33. story('Example with dismiss', () => {
  34. const [isDismissed, setIsDismissed] = useState(false);
  35. return (
  36. <Fragment>
  37. <p>
  38. This example renders an X in the top-right corner. You can wire it up with
  39. something like <kbd>useDismissAlert()</kbd>.
  40. </p>
  41. <p>
  42. Is Dismissed? <var>{String(isDismissed)}</var>
  43. </p>
  44. {isDismissed ? (
  45. <Button size="sm" onClick={() => setIsDismissed(false)}>
  46. Show banner
  47. </Button>
  48. ) : (
  49. <PageBanner
  50. button={storiesButton}
  51. description="Build new products faster by exploring reusable the UI components available inside Sentry."
  52. heading="Introducing the UI Component Library"
  53. icon={<IconBroadcast size="sm" />}
  54. image={replaysDeadRageBackground}
  55. title="UI Library Available"
  56. onDismiss={() => setIsDismissed(true)}
  57. />
  58. )}
  59. </Fragment>
  60. );
  61. });
  62. story('Resizable', () => {
  63. const [flexGrow, setFlexGrow] = useState(false);
  64. return (
  65. <Fragment>
  66. <p>
  67. The banner will resize if it's shrunk really narrow. To make it expand inside a
  68. flex parent set <kbd>flex-grow:1</kbd>.
  69. </p>
  70. <p>
  71. <Button size="sm" onClick={() => setFlexGrow(!flexGrow)}>
  72. flexGrow: <var>{flexGrow ? 1 : 0}</var>
  73. </Button>
  74. </p>
  75. <SizingWindow>
  76. <PageBanner
  77. style={{flexGrow: flexGrow ? 1 : 0}}
  78. button={storiesButton}
  79. description="Build new products faster by exploring reusable the UI components available inside Sentry."
  80. heading="Introducing the UI Component Library"
  81. icon={<IconBroadcast size="sm" />}
  82. image={replaysDeadRageBackground}
  83. title="UI Library Available"
  84. />
  85. </SizingWindow>
  86. </Fragment>
  87. );
  88. });
  89. story('More variations', () => (
  90. <Fragment>
  91. <p>There are some examples where we change out the colors and mix things up:</p>
  92. <PageBanner
  93. button={storiesButton}
  94. description={
  95. <Fragment>
  96. Build new products faster by exploring reusable the UI components available
  97. inside Sentry.{' '}
  98. <ExternalLink href="https://sentry.io/orgredirect/organizations/:orgslug/stories">
  99. See stories
  100. </ExternalLink>
  101. </Fragment>
  102. }
  103. heading="Introducing the UI Component Library"
  104. icon={<IconBroadcast size="sm" />}
  105. image={replaysDeadRageBackground}
  106. title={
  107. <Fragment>
  108. UI Library Available at <Green>https://sentry.io/stories</Green>
  109. </Fragment>
  110. }
  111. />
  112. </Fragment>
  113. ));
  114. });
  115. const Green = styled('span')`
  116. color: ${p => p.theme.green400};
  117. font-weight: bold;
  118. `;