@djangocfg/widget-visual 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +41 -0
  3. package/package.json +106 -0
  4. package/src/design/ColorPalette/ColorPalette.tsx +129 -0
  5. package/src/design/ColorPalette/README.md +34 -0
  6. package/src/design/ColorPalette/color-palette.stories.tsx +95 -0
  7. package/src/design/ColorPalette/components/Swatch.tsx +102 -0
  8. package/src/design/ColorPalette/hooks/useCopyToClipboard.ts +41 -0
  9. package/src/design/ColorPalette/index.ts +12 -0
  10. package/src/design/ColorPalette/lazy.tsx +21 -0
  11. package/src/design/ColorPalette/types.ts +63 -0
  12. package/src/design/ColorPalette/utils.ts +114 -0
  13. package/src/design/ColorPicker/ColorPicker.tsx +257 -0
  14. package/src/design/ColorPicker/color-picker.stories.tsx +113 -0
  15. package/src/design/ColorPicker/context/ColorPickerContext.tsx +28 -0
  16. package/src/design/ColorPicker/context/ColorPickerStore.tsx +166 -0
  17. package/src/design/ColorPicker/context/index.ts +2 -0
  18. package/src/design/ColorPicker/index.ts +15 -0
  19. package/src/design/ColorPicker/lazy.tsx +24 -0
  20. package/src/design/ColorPicker/lib/color-utils.ts +323 -0
  21. package/src/design/ColorPicker/parts/ColorPickerAlphaSlider.tsx +72 -0
  22. package/src/design/ColorPicker/parts/ColorPickerArea.tsx +155 -0
  23. package/src/design/ColorPicker/parts/ColorPickerEyeDropper.tsx +73 -0
  24. package/src/design/ColorPicker/parts/ColorPickerFormatSelect.tsx +64 -0
  25. package/src/design/ColorPicker/parts/ColorPickerHueSlider.tsx +64 -0
  26. package/src/design/ColorPicker/parts/ColorPickerInput.tsx +512 -0
  27. package/src/design/ColorPicker/parts/ColorPickerSwatch.tsx +63 -0
  28. package/src/design/ColorPicker/parts/index.ts +7 -0
  29. package/src/design/ColorPicker/types.ts +77 -0
  30. package/src/gallery/components/Gallery.tsx +182 -0
  31. package/src/gallery/components/compact/GalleryCompact.tsx +396 -0
  32. package/src/gallery/components/compact/index.ts +1 -0
  33. package/src/gallery/components/index.ts +21 -0
  34. package/src/gallery/components/lightbox/GalleryLightbox.tsx +426 -0
  35. package/src/gallery/components/lightbox/index.ts +1 -0
  36. package/src/gallery/components/media/GalleryImage.tsx +105 -0
  37. package/src/gallery/components/media/GalleryMedia.tsx +70 -0
  38. package/src/gallery/components/media/GalleryVideo.tsx +241 -0
  39. package/src/gallery/components/media/index.ts +3 -0
  40. package/src/gallery/components/preview/GalleryCarousel.tsx +374 -0
  41. package/src/gallery/components/preview/GalleryGrid.tsx +519 -0
  42. package/src/gallery/components/preview/index.ts +2 -0
  43. package/src/gallery/components/shared/ImageSpinner.tsx +37 -0
  44. package/src/gallery/components/shared/index.ts +1 -0
  45. package/src/gallery/components/thumbnails/GalleryThumbnails.tsx +198 -0
  46. package/src/gallery/components/thumbnails/GalleryThumbnailsVirtual.tsx +164 -0
  47. package/src/gallery/components/thumbnails/index.ts +2 -0
  48. package/src/gallery/gallery.stories.tsx +182 -0
  49. package/src/gallery/hooks/index.ts +23 -0
  50. package/src/gallery/hooks/useGallery.ts +138 -0
  51. package/src/gallery/hooks/useImageDimensions.ts +224 -0
  52. package/src/gallery/hooks/usePinchZoom.ts +239 -0
  53. package/src/gallery/hooks/usePreloadImages.ts +119 -0
  54. package/src/gallery/hooks/useSwipe.ts +87 -0
  55. package/src/gallery/hooks/useVirtualList.ts +129 -0
  56. package/src/gallery/hooks/useZoom.ts +321 -0
  57. package/src/gallery/index.ts +66 -0
  58. package/src/gallery/thumbnails.stories.tsx +127 -0
  59. package/src/gallery/types.ts +185 -0
  60. package/src/gallery/utils/imageAnalysis.ts +52 -0
  61. package/src/gallery/utils/index.ts +16 -0
  62. package/src/gallery/utils/normalizeUrl.ts +31 -0
  63. package/src/index.ts +18 -0
  64. package/src/lottie/LottiePlayer.client.tsx +319 -0
  65. package/src/lottie/index.tsx +66 -0
  66. package/src/lottie/lazy.tsx +65 -0
  67. package/src/lottie/lottie-player.stories.tsx +173 -0
  68. package/src/lottie/types.ts +138 -0
  69. package/src/lottie/useLottie.ts +187 -0
  70. package/src/lottie/usePrefersReducedMotion.ts +46 -0
  71. package/src/marquee/Marquee.tsx +637 -0
  72. package/src/marquee/index.ts +7 -0
  73. package/src/marquee/lazy.tsx +14 -0
  74. package/src/marquee/marquee.stories.tsx +118 -0
  75. package/src/marquee/types.ts +40 -0
  76. package/src/qrcode/QRCode.tsx +468 -0
  77. package/src/qrcode/index.ts +10 -0
  78. package/src/qrcode/lazy.tsx +19 -0
  79. package/src/qrcode/qr-code.stories.tsx +102 -0
  80. package/src/qrcode/types.ts +57 -0
@@ -0,0 +1,102 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import {
3
+ QRCode,
4
+ QRCodeCanvas,
5
+ QRCodeSvg,
6
+ QRCodeImage,
7
+ QRCodeDownload,
8
+ QRCodeOverlay,
9
+ QRCodeSkeleton,
10
+ } from '.';
11
+
12
+ const meta = {
13
+ title: 'Widgets/Visual/QRCode',
14
+ component: QRCode,
15
+ tags: ['autodocs'],
16
+ parameters: {
17
+ docs: {
18
+ description: {
19
+ component: 'A QR code generator with canvas, SVG, and image output formats.',
20
+ },
21
+ },
22
+ },
23
+ argTypes: {
24
+ value: { control: 'text' },
25
+ size: { control: 'number' },
26
+ level: { control: 'select', options: ['L', 'M', 'Q', 'H'] },
27
+ margin: { control: 'number' },
28
+ },
29
+ args: {
30
+ value: 'https://djangocfg.dev',
31
+ },
32
+ } satisfies Meta<typeof QRCode>;
33
+
34
+ export default meta;
35
+ type Story = StoryObj<typeof meta>;
36
+
37
+ export const Default: Story = {
38
+ render: () => (
39
+ <QRCode value="https://djangocfg.dev" size={200}>
40
+ <QRCodeCanvas />
41
+ <QRCodeSkeleton />
42
+ </QRCode>
43
+ ),
44
+ };
45
+
46
+ export const Svg: Story = {
47
+ render: () => (
48
+ <QRCode value="https://djangocfg.dev" size={200}>
49
+ <QRCodeSvg />
50
+ <QRCodeSkeleton />
51
+ </QRCode>
52
+ ),
53
+ };
54
+
55
+ export const Image: Story = {
56
+ render: () => (
57
+ <QRCode value="https://djangocfg.dev" size={200}>
58
+ <QRCodeImage />
59
+ <QRCodeSkeleton />
60
+ </QRCode>
61
+ ),
62
+ };
63
+
64
+ export const WithOverlay: Story = {
65
+ render: () => (
66
+ <QRCode value="https://djangocfg.dev" size={200}>
67
+ <QRCodeCanvas />
68
+ <QRCodeOverlay className="size-10 rounded-full bg-white p-1">
69
+ <span className="text-xs font-bold">DC</span>
70
+ </QRCodeOverlay>
71
+ <QRCodeSkeleton />
72
+ </QRCode>
73
+ ),
74
+ };
75
+
76
+ export const CustomColors: Story = {
77
+ render: () => (
78
+ <QRCode
79
+ value="https://djangocfg.dev"
80
+ size={200}
81
+ foregroundColor="#3b82f6"
82
+ backgroundColor="#f8fafc"
83
+ >
84
+ <QRCodeCanvas />
85
+ <QRCodeSkeleton />
86
+ </QRCode>
87
+ ),
88
+ };
89
+
90
+ export const WithDownload: Story = {
91
+ render: () => (
92
+ <div className="flex flex-col items-center gap-4">
93
+ <QRCode value="https://djangocfg.dev" size={200}>
94
+ <QRCodeCanvas />
95
+ <QRCodeSkeleton />
96
+ </QRCode>
97
+ <QRCodeDownload format="png" filename="djangocfg-qr">
98
+ Download PNG
99
+ </QRCodeDownload>
100
+ </div>
101
+ ),
102
+ };
@@ -0,0 +1,57 @@
1
+ import * as React from 'react';
2
+
3
+ export type QRCodeLevel = 'L' | 'M' | 'Q' | 'H';
4
+
5
+ export interface QRCodeCanvasOpts {
6
+ errorCorrectionLevel: QRCodeLevel;
7
+ type?: 'image/png' | 'image/jpeg' | 'image/webp';
8
+ quality?: number;
9
+ margin?: number;
10
+ color?: {
11
+ dark: string;
12
+ light: string;
13
+ };
14
+ width?: number;
15
+ rendererOpts?: {
16
+ quality?: number;
17
+ };
18
+ }
19
+
20
+ export interface StoreState {
21
+ dataUrl: string | null;
22
+ svgString: string | null;
23
+ isGenerating: boolean;
24
+ error: Error | null;
25
+ generationKey: string;
26
+ }
27
+
28
+ export interface Store {
29
+ subscribe: (callback: () => void) => () => void;
30
+ getState: () => StoreState;
31
+ setState: <K extends keyof StoreState>(key: K, value: StoreState[K]) => void;
32
+ setStates: (updates: Partial<StoreState>) => void;
33
+ notify: () => void;
34
+ }
35
+
36
+ export interface QRCodeContextValue {
37
+ value: string;
38
+ size: number;
39
+ margin: number;
40
+ level: QRCodeLevel;
41
+ backgroundColor: string;
42
+ foregroundColor: string;
43
+ canvasRef: React.RefObject<HTMLCanvasElement | null>;
44
+ }
45
+
46
+ export interface QRCodeProps extends Omit<React.ComponentProps<'div'>, 'onError'> {
47
+ value: string;
48
+ size?: number;
49
+ level?: QRCodeLevel;
50
+ margin?: number;
51
+ quality?: number;
52
+ backgroundColor?: string;
53
+ foregroundColor?: string;
54
+ onError?: (error: Error) => void;
55
+ onGenerated?: () => void;
56
+ asChild?: boolean;
57
+ }