@@ -212,6 +212,7 @@ const EmptyGalleryTemplate: StoryFn<GalleryProps> = () => {
212212export const EmptyGallery = EmptyGalleryTemplate . bind ( { } ) ;
213213
214214const SingleItemGalleryTemplate : StoryFn < GalleryProps > = ( ) => {
215+ const mobile = useMobile ( ) ;
215216 const [ open , setOpen ] = React . useState ( false ) ;
216217
217218 const handleToggle = React . useCallback ( ( ) => {
@@ -227,13 +228,60 @@ const SingleItemGalleryTemplate: StoryFn<GalleryProps> = () => {
227228 name : 'Corgi image' ,
228229 } ) ;
229230
231+ const renderActions = React . useCallback (
232+ ( file : GalleryFile ) => {
233+ const result : GalleryItemAction [ ] = [
234+ {
235+ id : 'clipboard' ,
236+ title : file . type === 'text' ? 'Copy text' : 'Copy link' ,
237+ icon : < Icon data = { Link } size = { mobile ? 18 : 16 } /> ,
238+ render : ( buttonProps ) => {
239+ return (
240+ < CopyToClipboard
241+ onCopy = { ( ) =>
242+ alert ( file . type === 'text' ? 'Text copied!' : 'Link copied!' )
243+ }
244+ text = { file . type === 'text' ? file . text : file . url || '' }
245+ >
246+ { ( ) => {
247+ if ( mobile ) {
248+ return < Button { ...buttonProps } /> ;
249+ }
250+ return (
251+ < ActionTooltip
252+ title = { file . type === 'text' ? 'Copy text' : 'Copy link' }
253+ >
254+ < Button { ...buttonProps } />
255+ </ ActionTooltip >
256+ ) ;
257+ } }
258+ </ CopyToClipboard >
259+ ) ;
260+ } ,
261+ } ,
262+ ] ;
263+
264+ if ( file . type !== 'text' ) {
265+ result . push ( {
266+ id : 'new-tab' ,
267+ title : 'Open in new tab' ,
268+ icon : < Icon data = { ArrowUpRightFromSquare } size = { mobile ? 18 : 16 } /> ,
269+ href : file . url ,
270+ } ) ;
271+ }
272+
273+ return result ;
274+ } ,
275+ [ mobile ] ,
276+ ) ;
277+
230278 return (
231279 < React . Fragment >
232280 < Button onClick = { handleOpen } view = "action" size = "l" >
233281 Open gallery
234282 </ Button >
235283 < Gallery open = { open } onOpenChange = { handleToggle } >
236- < GalleryItem { ...imageGalleryItem } />
284+ < GalleryItem { ...imageGalleryItem } actions = { renderActions ( files [ 0 ] ) } />
237285 </ Gallery >
238286 </ React . Fragment >
239287 ) ;
0 commit comments