diff-changes.stories.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. // @ts-nocheck
  2. import * as mod from "./diff-changes"
  3. import { create } from "../storybook/scaffold"
  4. import { changes } from "../storybook/fixtures"
  5. const docs = `### Overview
  6. Summarize additions/deletions as text or compact bars.
  7. Pair with \`Diff\`/\`DiffSSR\` to contextualize a change set.
  8. ### API
  9. - Required: \`changes\` as { additions, deletions } or an array of those objects.
  10. - Optional: \`variant\` ("default" | "bars").
  11. ### Variants and states
  12. - Default text summary or bar visualization.
  13. - Handles zero-change state (renders nothing in default variant).
  14. ### Behavior
  15. - Aggregates arrays into total additions/deletions.
  16. ### Accessibility
  17. - Ensure surrounding context conveys meaning of the counts/bars.
  18. ### Theming/tokens
  19. - Uses \`data-component="diff-changes"\` and diff color tokens.
  20. `
  21. const story = create({
  22. title: "UI/DiffChanges",
  23. mod,
  24. args: {
  25. changes,
  26. variant: "default",
  27. },
  28. })
  29. export default {
  30. title: "UI/DiffChanges",
  31. id: "components-diff-changes",
  32. component: story.meta.component,
  33. tags: ["autodocs"],
  34. parameters: {
  35. docs: {
  36. description: {
  37. component: docs,
  38. },
  39. },
  40. },
  41. argTypes: {
  42. variant: {
  43. control: "select",
  44. options: ["default", "bars"],
  45. },
  46. },
  47. }
  48. export const Default = story.Basic
  49. export const Bars = {
  50. args: {
  51. variant: "bars",
  52. },
  53. }
  54. export const MultipleFiles = {
  55. args: {
  56. changes: [
  57. { additions: 4, deletions: 1 },
  58. { additions: 8, deletions: 3 },
  59. { additions: 2, deletions: 0 },
  60. ],
  61. },
  62. }
  63. export const Zero = {
  64. args: {
  65. changes: { additions: 0, deletions: 0 },
  66. },
  67. }