formatters.stories.js 3.5 KB

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