formatters.stories.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import Count from 'sentry/components/count';
  2. import DateTime from 'sentry/components/dateTime';
  3. import Duration from 'sentry/components/duration';
  4. import FileSize from 'sentry/components/fileSize';
  5. import Version from 'sentry/components/version';
  6. export default {
  7. title: 'Utilities/Text/Formatters',
  8. };
  9. export const _DateTime = () => (
  10. <div>
  11. <div>
  12. <DateTime date={1500000000000} />
  13. </div>
  14. <div>
  15. <DateTime seconds={false} date={1500000000000} />
  16. </div>
  17. <div>
  18. <DateTime dateOnly date={1500000000000} />
  19. </div>
  20. <div>
  21. <DateTime timeOnly date={1500000000000} />
  22. </div>
  23. </div>
  24. );
  25. _DateTime.storyName = 'DateTime';
  26. _DateTime.parameters = {
  27. docs: {
  28. description: {
  29. story: 'Formats number (in ms or seconds) into a datetime string',
  30. },
  31. },
  32. };
  33. export const _FileSize = () => (
  34. <div>
  35. <div>
  36. <FileSize bytes={15} />
  37. </div>
  38. <div>
  39. <FileSize bytes={15000} />
  40. </div>
  41. <div>
  42. <FileSize bytes={1500000} />
  43. </div>
  44. <div>
  45. <FileSize bytes={15000000000} />
  46. </div>
  47. <div>
  48. <FileSize bytes={15000000000000} />
  49. </div>
  50. <div>
  51. <FileSize bytes={15000000000000000} />
  52. </div>
  53. </div>
  54. );
  55. _FileSize.storyName = 'FileSize';
  56. _FileSize.parameters = {
  57. docs: {
  58. description: {
  59. story: 'Formats number of bytes to filesize string',
  60. },
  61. },
  62. };
  63. export const _Duration = ({exact, abbreviation}) => {
  64. return (
  65. <div>
  66. <div>
  67. <Duration seconds={15} exact={exact} abbreviation={abbreviation} />
  68. </div>
  69. <div>
  70. <Duration seconds={60} exact={exact} abbreviation={abbreviation} />
  71. </div>
  72. <div>
  73. <Duration seconds={15000} exact={exact} abbreviation={abbreviation} />
  74. </div>
  75. <div>
  76. <Duration seconds={86400} exact={exact} abbreviation={abbreviation} />
  77. </div>
  78. <div>
  79. <Duration seconds={186400} exact={exact} abbreviation={abbreviation} />
  80. </div>
  81. <div>
  82. <Duration seconds={604800} exact={exact} abbreviation={abbreviation} />
  83. </div>
  84. <div>
  85. <Duration seconds={1500000} exact={exact} abbreviation={abbreviation} />
  86. </div>
  87. </div>
  88. );
  89. };
  90. _Duration.args = {
  91. exact: false,
  92. abbreviation: false,
  93. };
  94. _Duration.parameters = {
  95. docs: {
  96. description: {
  97. story: 'Formats number of seconds into a duration string',
  98. },
  99. },
  100. };
  101. export const _Count = () => (
  102. <div>
  103. <div>
  104. 5000000 =
  105. <Count value="5000000" />
  106. </div>
  107. <div>
  108. 500000000 =
  109. <Count value="500000000" />
  110. </div>
  111. <div>
  112. 50000 =
  113. <Count value="50000" />
  114. </div>
  115. </div>
  116. );
  117. _Count.parameters = {
  118. docs: {
  119. description: {
  120. story: 'Formats numbers into a shorthand string',
  121. },
  122. },
  123. };
  124. export const _Version = ({
  125. version,
  126. anchor,
  127. preservePageFilters,
  128. tooltipRawVersion,
  129. withPackage,
  130. projectId,
  131. truncate,
  132. className,
  133. }) => {
  134. return (
  135. <div>
  136. {version} =
  137. <Version
  138. version={version}
  139. anchor={anchor}
  140. preservePageFilters={preservePageFilters}
  141. tooltipRawVersion={tooltipRawVersion}
  142. withPackage={withPackage}
  143. projectId={projectId}
  144. truncate={truncate}
  145. className={className}
  146. />
  147. </div>
  148. );
  149. };
  150. _Version.args = {
  151. version: 'foo.bar.Baz@1.0.0+20200101',
  152. anchor: true,
  153. preservePageFilters: false,
  154. tooltipRawVersion: true,
  155. withPackage: false,
  156. projectId: '',
  157. truncate: false,
  158. className: 'asdsad',
  159. };
  160. _Version.parameters = {
  161. docs: {
  162. description: {
  163. story: 'Formats release version',
  164. },
  165. },
  166. };