truncate.stories.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {Fragment} from 'react';
  2. import styled from '@emotion/styled';
  3. import Truncate from 'sentry/components/truncate';
  4. export default {
  5. title: 'Utilities/Text/Truncate',
  6. component: Truncate,
  7. };
  8. export const TruncateAndExpandOnHover = () => (
  9. <Fragment>
  10. <Wrapper position="start">
  11. <Truncate value="https://sentry.io/organizations/sentry/issues/" maxLength={30} />
  12. </Wrapper>
  13. <Wrapper position="end">
  14. <Truncate
  15. value="https://sentry.io/organizations/sentry/issues/"
  16. maxLength={30}
  17. leftTrim
  18. expandDirection="left"
  19. />
  20. </Wrapper>
  21. </Fragment>
  22. );
  23. TruncateAndExpandOnHover.storyName = 'Truncate and Expand on Hover';
  24. export const TruncateWithRegex = () => (
  25. <Fragment>
  26. <Wrapper position="start">
  27. <Truncate
  28. value="https://sentry.io/organizations/sentry/issues/"
  29. maxLength={30}
  30. trimRegex={/\.|\//g}
  31. />
  32. </Wrapper>
  33. <Wrapper position="end">
  34. <Truncate
  35. value="https://sentry.io/organizations/sentry/issues/"
  36. maxLength={30}
  37. trimRegex={/\.|\//g}
  38. leftTrim
  39. expandDirection="left"
  40. />
  41. </Wrapper>
  42. </Fragment>
  43. );
  44. TruncateWithRegex.storyName = 'Truncate with Regex';
  45. const Wrapper = styled('div')`
  46. display: flex;
  47. justify-content: flex-${p => p.position || 'start'};
  48. `;