File tree 1 file changed +18
-21
lines changed
1 file changed +18
-21
lines changed Original file line number Diff line number Diff line change @@ -140,30 +140,14 @@ augmentations are applied before the lightbox starts rendering.
140
140
141
141
For example, you can add a toolbar button using the following augmentation:
142
142
143
- ``` tsx
144
- import { addToolbarButton , IconButton } from " yet-another-react-lightbox" ;
145
-
146
- declare module " yet-another-react-lightbox" {
147
- interface Labels {
148
- " My button" ? : string ;
149
- }
150
- }
143
+ ``` jsx
144
+ import { addToolbarButton } from " yet-another-react-lightbox" ;
151
145
152
146
// ...
153
147
154
148
function MyPlugin ({ augment }) {
155
149
augment (({ toolbar, ... restProps }) => ({
156
- toolbar: addToolbarButton (
157
- toolbar ,
158
- " my-button" ,
159
- <IconButton
160
- icon = { MyIcon }
161
- label = " My button"
162
- onClick = { () => {
163
- // ...
164
- }}
165
- />,
166
- ),
150
+ toolbar: addToolbarButton (toolbar, " my-button" , < MyButton / > ),
167
151
... restProps,
168
152
}));
169
153
}
@@ -317,21 +301,34 @@ const { containerRect, setContainerRef } = useContainerRect();
317
301
You can create custom toolbar buttons by using the ` IconButton ` component and
318
302
the ` createIcon ` helper function.
319
303
320
- ``` jsx
304
+ ``` tsx
321
305
import {
322
306
Lightbox ,
323
307
IconButton ,
324
308
createIcon ,
325
309
useLightboxState ,
326
310
} from " yet-another-react-lightbox" ;
327
311
312
+ declare module " yet-another-react-lightbox" {
313
+ interface Labels {
314
+ " My button" ? : string ;
315
+ }
316
+ }
317
+
328
318
const MyIcon = createIcon (" MyIcon" , <path d = " ..." />);
329
319
330
320
function MyButton() {
331
321
const { currentSlide } = useLightboxState ();
332
322
333
323
return (
334
- < IconButton label= " My button" icon= {MyIcon} disabled= {! currentSlide} / >
324
+ <IconButton
325
+ label = " My button"
326
+ icon = { MyIcon }
327
+ disabled = { ! currentSlide }
328
+ onClic = { () => {
329
+ // ...
330
+ }}
331
+ />
335
332
);
336
333
}
337
334
You can’t perform that action at this time.
0 commit comments