Skip to content

Commit 05cd33e

Browse files
fix: Add TypeScript Types for Cloudinary Product Gallery Widget (#218)
# Description This pull request introduces TypeScript types for the Cloudinary Product Gallery Widget. It defines a comprehensive interface for the widget, following the reference documentation for better type safety and improved developer experience. No additional dependencies are required for this change. ## Issue Ticket Number 199 Fixes #199 ## Type of change <!-- Please select all options that are applicable. --> - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Fix or improve the documentation - [ ] This change requires a documentation update # Checklist <!-- These must all be followed and checked. --> - [x] I have followed the contributing guidelines of this project as mentioned in [CONTRIBUTING.md](/CONTRIBUTING.md) - [x] I have created an [issue](https://github.com/colbyfayock/cloudinary-util/issues) ticket for this PR - [x] I have checked to ensure there aren't other open [Pull Requests](https://github.com/colbyfayock/cloudinary-util/pulls) for the same update/change? - [x] I have performed a self-review of my own code - [x] I have run tests locally to ensure they all pass - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes needed to the documentation
1 parent 8b99479 commit 05cd33e

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

packages/types/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ export type {
3737
CloudinaryVideoPlayerTextTracksTrackOptionsTheme,
3838
} from "./types/cloudinary-video-player.js";
3939

40+
export type { CloudinaryProductGallery } from "./types/cloudinary-product-gallery.js";
41+
4042
export type {
4143
CloudinaryAssetConfiguration,
4244
CloudinaryAssetConfigurationAuthToken,
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
export interface CloudinaryProductGallery {
2+
// Required parameters
3+
cloudName?: string;
4+
mediaAssets?:
5+
| {
6+
publicId?: string;
7+
tag?: string;
8+
mediaType?: string;
9+
resourceType?: string;
10+
transformation?: object;
11+
thumbnailTransformation?: object;
12+
altText?: string;
13+
videoPlayerSource?: object;
14+
}[]
15+
| string[]; // string[] is a list of publicIDs
16+
container?: string | HTMLElement;
17+
18+
// Widget
19+
analytics?: boolean;
20+
displayProps?: {
21+
mode?: "classic" | "expanded";
22+
spacing?: number;
23+
columns?: number;
24+
topOffset?: number;
25+
bottomOffset?: number;
26+
};
27+
focus?: boolean;
28+
loaderProps?: {
29+
color?: string;
30+
opacity?: number;
31+
style?: "cloudinary" | "circle" | "custom";
32+
url?: string;
33+
};
34+
placeholderImage?: boolean;
35+
sort?: "none" | "asc" | "desc";
36+
sortProps?: {
37+
source?: string;
38+
id?: string;
39+
direction?: string;
40+
};
41+
themeProps?: {
42+
primary?: string; // Default: "#FFFFFF"
43+
onPrimary?: string; // Default: "#000000"
44+
active?: string; // Default: "#0078FF"
45+
};
46+
viewportBreakpoints?: {
47+
breakpoint: number; // Required
48+
[key: string]: any; // Other configuration parameters to override
49+
}[];
50+
51+
// Main viewer parameters
52+
accessibilityProps?: {
53+
mediaAltSource?: string;
54+
mediaAltId?: string;
55+
};
56+
ar3dProps?: {
57+
shadows?: boolean;
58+
showAR?: boolean;
59+
};
60+
aspectRatio?:
61+
| "square"
62+
| "1:1"
63+
| "3:4"
64+
| "4:3"
65+
| "4:6"
66+
| "6:4"
67+
| "5:7"
68+
| "7:5"
69+
| "5:8"
70+
| "8:5"
71+
| "9:16"
72+
| "16:9";
73+
borderColor?: string;
74+
borderWidth?: number;
75+
imageBreakpoint?: number;
76+
videoBreakpoint?: number;
77+
preload?: string[];
78+
radius?: number;
79+
spinProps?: {
80+
animate?: "none" | "start" | "end" | "both";
81+
spinDirection?: "clockwise" | "counter-clockwise";
82+
disableZoom?: boolean;
83+
showTip?: "always" | "never" | "touch";
84+
tipPosition?: "top" | "center" | "bottom";
85+
tipText?: string; // Default: "Drag to rotate"
86+
tipTouchText?: string; // Default: "Swipe to rotate"
87+
};
88+
startIndex?: number;
89+
tipProps?: {
90+
textColor?: string;
91+
color?: string;
92+
radius?: number;
93+
opacity?: number;
94+
};
95+
transition?: "slide" | "fade" | "none";
96+
videoProps?: {
97+
controls?: string;
98+
sound?: boolean;
99+
autoplay?: boolean;
100+
loop?: boolean;
101+
playerType?: string;
102+
};
103+
zoom?: boolean;
104+
zoomProps?: any;
105+
zoomPopupProps?: {
106+
backdropColor?: string;
107+
backdropOpacity?: number;
108+
zIndex?: number;
109+
};
110+
111+
// Carousel parameters
112+
carouselLocation?: "left" | "right" | "top" | "bottom";
113+
carouselOffset?: number;
114+
carouselStyle?: "none" | "thumbnails" | "indicators";
115+
indicatorProps?: {
116+
color?: string;
117+
selectedColor?: string;
118+
shape?: "round" | "square" | "radius";
119+
size?: number;
120+
spacing?: number;
121+
sticky?: boolean;
122+
};
123+
thumbnailProps?: any;
124+
125+
// Navigation parameters
126+
navigation?: "none" | "always" | "mouseover";
127+
navigationButtonProps?: {
128+
shape?: "none" | "round" | "square" | "radius" | "rectangle";
129+
iconColor?: string;
130+
color?: string;
131+
size?: number;
132+
};
133+
navigationOffset?: number;
134+
navigationPosition?: "inside" | "outside" | "offset";
135+
}

0 commit comments

Comments
 (0)