avatar.stories.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // @ts-nocheck
  2. import * as mod from "./avatar"
  3. import { create } from "../storybook/scaffold"
  4. const docs = `### Overview
  5. User avatar with image fallback to initials.
  6. Use in user lists and headers.
  7. ### API
  8. - Required: \`fallback\` string.
  9. - Optional: \`src\`, \`background\`, \`foreground\`, \`size\`.
  10. ### Variants and states
  11. - Sizes: small, normal, large.
  12. - Image vs fallback state.
  13. ### Behavior
  14. - Uses grapheme-aware fallback rendering.
  15. ### Accessibility
  16. - TODO: provide alt text when using images; currently image is decorative.
  17. ### Theming/tokens
  18. - Uses \`data-component="avatar"\` with size and image state attributes.
  19. `
  20. const story = create({ title: "UI/Avatar", mod, args: { fallback: "A" } })
  21. export default {
  22. title: "UI/Avatar",
  23. id: "components-avatar",
  24. component: story.meta.component,
  25. tags: ["autodocs"],
  26. parameters: {
  27. docs: {
  28. description: {
  29. component: docs,
  30. },
  31. },
  32. },
  33. argTypes: {
  34. size: {
  35. control: "select",
  36. options: ["small", "normal", "large"],
  37. },
  38. },
  39. }
  40. export const Basic = story.Basic
  41. export const WithImage = {
  42. args: {
  43. src: "https://placehold.co/80x80/png",
  44. fallback: "J",
  45. },
  46. }
  47. export const Sizes = {
  48. render: () => (
  49. <div style={{ display: "flex", gap: "12px", "align-items": "center" }}>
  50. <mod.Avatar size="small" fallback="S" />
  51. <mod.Avatar size="normal" fallback="N" />
  52. <mod.Avatar size="large" fallback="L" />
  53. </div>
  54. ),
  55. }
  56. export const CustomColors = {
  57. args: {
  58. fallback: "C",
  59. background: "#1f2a44",
  60. foreground: "#f2f5ff",
  61. },
  62. }