Skip to content

Commit 24e0da4

Browse files
committed
docs: Write about the latest features
1 parent 16abc60 commit 24e0da4

File tree

2 files changed

+45
-35
lines changed

2 files changed

+45
-35
lines changed

README.md

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ A simple, easy-to-use, and responsive image gallery component with a lightbox fo
1111
- Keyboard accessible
1212
- Mobile responsive
1313
- Lightbox with translucent background
14+
- Thumbnails
15+
- Image captions
16+
- Lazy loading support
1417
- Set column numbers dynamically or manually
18+
- Resolution switching compatible
1519
- Customizable styles
1620

1721
## Live Demo and Tutorial
@@ -57,24 +61,23 @@ const imagesArray = [
5761
alt: "Image2's alt text",
5862
caption: "Image2's description",
5963
src: "http://example.com/image2.png",
64+
thumbSrc: "http://example.com/image2_640.png",
6065
},
6166
{
6267
id: "uniqueid333",
6368
alt: "Image3's alt text",
6469
caption: "Image3's description",
65-
src: "http://example.com/image3.webp",
70+
src: "http://example.com/image3.webp?w=2400",
71+
gridSrc: "http://example.com/image3.webp?w=1280",
72+
thumbSrc: "http://example.com/image3.webp?w=640",
73+
srcSet:
74+
"http://example.com/image3.webp?w=2400 2400w, http://example.com/image3.webp?w=1280 1280w, http://example.com/image3.webp?w=640 640w",
75+
mediaSizes: "(max-width: 640px) 640w, (max-width: 1024px) 1280w, 2400px",
6676
},
6777
];
6878

6979
function App() {
70-
return (
71-
<ImageGallery
72-
imagesInfoArray={imagesArray}
73-
columnCount={"auto"}
74-
columnWidth={230}
75-
gapSize={24}
76-
/>
77-
);
80+
return <ImageGallery imagesInfoArray={imagesArray} gapSize={24} />;
7881
}
7982
```
8083

@@ -98,10 +101,14 @@ function App() {
98101

99102
(**Required**) An array of objects containing the following properties:
100103

101-
- `id`: (**Required**) An [identification string or number](https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key) that uniquely identifies each image among other images in the array.
102-
- `alt`: (**Required**) The image's [alternative text](https://webaim.org/techniques/alttext).
103-
- `caption`: (**Optional**) The [image's description](https://www.studysmarter.co.uk/explanations/english/blog/image-caption).
104-
- `src`: (**Required**) The image's [URL](https://codesweetly.com/web-address-url).
104+
- `id`: (**Required** - string or number) Each image's [unique identifying key](https://react.dev/learn/rendering-lists#keeping-list-items-in-order-with-key).
105+
- `alt`: (**Required** - string) The image's [alternative text](https://webaim.org/techniques/alttext).
106+
- `caption`: (**Optional** - string) The [image's description](https://www.studysmarter.co.uk/explanations/english/blog/image-caption).
107+
- `src`: (**Required** - string) The image's default [URL](https://codesweetly.com/web-address-url).
108+
- `gridSrc`: (**Optional** - string) The preferred grid image's URL.
109+
- `thumbSrc`: (**Optional** - string) The preferred thumbnail image's URL.
110+
- `srcSet`: (**Optional** - string) The set of images' URLs and sizes for [resolution switching](https://developer.mozilla.org/en-US/docs/Web/HTML/Responsive_images#resolution_switching_different_sizes).
111+
- [`mediaSizes`](https://developer.mozilla.org/en-US/docs/Web/HTML/Responsive_images#resolution_switching_different_sizes): (**Optional** - string) The media conditions and image sizes that hint the browser on the specific `srcSet` to display when a media condition is true.
105112

106113
</td>
107114
</tr>
@@ -113,11 +120,7 @@ function App() {
113120
</td>
114121
<td>number or keyword (string)</td>
115122
<td><code>"auto"</code></td>
116-
<td>
117-
118-
(**Optional**) The number of columns.
119-
120-
</td>
123+
<td>(<strong>Optional</strong>) The number of columns.</td>
121124
</tr>
122125
<tr>
123126
<td>
@@ -127,11 +130,7 @@ function App() {
127130
</td>
128131
<td>number or keyword (string)</td>
129132
<td><code>230</code></td>
130-
<td>
131-
132-
(**Optional**) The minimum width of the gallery's columns.
133-
134-
</td>
133+
<td>(<strong>Optional</strong>) The minimum width of the gallery's columns.</td>
135134
</tr>
136135
<tr>
137136
<td>
@@ -141,18 +140,10 @@ function App() {
141140
</td>
142141
<td>number</td>
143142
<td><code>24</code></td>
144-
<td>
145-
146-
(**Optional**) The gallery's gap size.
147-
148-
</td>
143+
<td>(<strong>Optional</strong>) The gallery's gap size.</td>
149144
</tr>
150145
<tr>
151-
<td>
152-
153-
`fixedCaption`
154-
155-
</td>
146+
<td><code>fixedCaption</code></td>
156147
<td>boolean</td>
157148
<td><code>false</code></td>
158149
<td>
@@ -162,11 +153,29 @@ function App() {
162153
</td>
163154
</tr>
164155
<tr>
156+
<td><code>thumbnailBorder</code></td>
157+
<td>string</td>
158+
<td><code>"3px solid #fff"</code></td>
159+
<td>(<strong>Optional</strong>) The thumbnail's border style.</td>
160+
</tr>
161+
<tr>
162+
<td><code>lazy</code></td>
163+
<td>boolean</td>
164+
<td><code>true</code></td>
165+
<td>(<strong>Optional</strong>) Specify whether to lazy load images.</td>
166+
</tr>
167+
<tr>
168+
<td><code>lazyFromIndex</code></td>
169+
<td>number</td>
170+
<td><code>6</code></td>
165171
<td>
166172

167-
`customStyles`
173+
(**Optional**) The image's [index](https://codesweetly.com/web-tech-terms-i/#index) to begin the grid's lazy loading.
168174

169175
</td>
176+
</tr>
177+
<tr>
178+
<td><code>customStyles</code></td>
170179
<td>ImageGalleryStylesType</td>
171180
<td><code>{}</code></td>
172181
<td>
@@ -183,6 +192,7 @@ function App() {
183192
- Modal toolbar: `modalToolbarStyle`
184193
- Modal toolbar button: `modalToolbarBtnStyle`
185194
- Modal slideshow section: `modalSlideShowSectionStyle`
195+
- Modal thumbnail section: `modalThumbnailSectionStyle`
186196
- Modal image element: `modalImageStyle`
187197
- Modal slide button: `modalSlideBtnStyle`
188198

src/ImageGallery.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const imagesArray = [
2020
thumbSrc:
2121
"https://images.unsplash.com/photo-1526047932273-341f2a7631f9?q=80&w=640",
2222
srcSet:
23-
"https://images.unsplash.com/photo-1526047932273-341f2a7631f9?q=80&w=2400 2400w, https://images.unsplash.com/photo-1526047932273-341f2a7631f9?q=80&w=1920 1920w, https://images.unsplash.com/photo-1526047932273-341f2a7631f9?q=80&w=640 640w",
23+
"https://images.unsplash.com/photo-1526047932273-341f2a7631f9?q=80&w=2400 2400w, https://images.unsplash.com/photo-1526047932273-341f2a7631f9?q=80&w=1280 1280w, https://images.unsplash.com/photo-1526047932273-341f2a7631f9?q=80&w=640 640w",
2424
mediaSizes: "(max-width: 640px) 640w, (max-width: 1024px) 1280w, 2400px",
2525
},
2626
{

0 commit comments

Comments
 (0)