1
0

ClientTrafficCell.stories.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import type { Meta, StoryObj } from '@storybook/react-vite';
  2. import { ThemeProvider } from '@/hooks/useTheme';
  3. import ClientTrafficCell from './ClientTrafficCell';
  4. const GiB = 1024 ** 3;
  5. const meta = {
  6. title: 'Clients/ClientTrafficCell',
  7. component: ClientTrafficCell,
  8. tags: ['autodocs'],
  9. decorators: [
  10. (Story) => (
  11. <ThemeProvider>
  12. <Story />
  13. </ThemeProvider>
  14. ),
  15. ],
  16. parameters: {
  17. layout: 'padded',
  18. docs: {
  19. description: {
  20. component:
  21. 'Traffic usage cell for the clients table: used bytes, a color-coded progress bar, and the quota (or an infinity icon for unlimited clients), with an upload/download/remaining breakdown in a hover popover.',
  22. },
  23. },
  24. },
  25. argTypes: {
  26. up: { description: 'Uploaded bytes counted against the client.' },
  27. down: { description: 'Downloaded bytes counted against the client.' },
  28. total: { description: 'Traffic quota in bytes; 0 or less renders as unlimited.' },
  29. enabled: { description: 'Grays the bar out when the client is disabled.' },
  30. trafficDiff: {
  31. description:
  32. 'Headroom in bytes below the quota at which the bar shifts from green to orange.',
  33. },
  34. compact: { description: 'Smaller bar and tighter layout for dense table rows.' },
  35. },
  36. } satisfies Meta<typeof ClientTrafficCell>;
  37. export default meta;
  38. type Story = StoryObj<typeof meta>;
  39. export const Default: Story = {
  40. args: {
  41. up: 6 * GiB,
  42. down: 35 * GiB,
  43. total: 100 * GiB,
  44. trafficDiff: 5 * GiB,
  45. },
  46. };
  47. export const Unlimited: Story = {
  48. args: {
  49. up: 87 * GiB,
  50. down: 940 * GiB,
  51. total: 0,
  52. },
  53. };
  54. export const Depleted: Story = {
  55. args: {
  56. up: 9 * GiB,
  57. down: 42 * GiB,
  58. total: 50 * GiB,
  59. trafficDiff: 5 * GiB,
  60. },
  61. };
  62. export const DisabledCompact: Story = {
  63. args: {
  64. up: 2 * GiB,
  65. down: 11 * GiB,
  66. total: 40 * GiB,
  67. enabled: false,
  68. compact: true,
  69. },
  70. };