Skip to content

Commit

Permalink
add image view component
Browse files Browse the repository at this point in the history
  • Loading branch information
VargaJoe committed Oct 9, 2023
1 parent 116cce0 commit ebe4706
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/sensenet/src/components/content/Explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { DocumentViewer } from '../document-viewer'
import { EditBinary } from '../edit/edit-binary'
import { FullScreenLoader } from '../full-screen-loader'
import TreeWithData from '../tree/tree-with-data'
import { BrowseView, EditView, NewView, PermissionView, VersionView } from '../view-controls'
import { BrowseView, EditView, ImageView, NewView, PermissionView, VersionView } from '../view-controls'
import WopiPage from '../wopi-page'

const useStyles = makeStyles((theme: Theme) => {
Expand Down Expand Up @@ -158,7 +158,7 @@ export function Explore({
case 'setpermissions':
return <PermissionView key={activeContent} contentPath={`${rootPath}${activeContent}`} />
case 'image':
return <img src={`${repository.configuration.repositoryUrl}${rootPath}${activeContent}`} alt="" />
return <ImageView key={activeContent} contentPath={`${rootPath}${activeContent}`} />
case 'preview':
return <DocumentViewer key={activeContent} contentPath={`${rootPath}${activeContent}`} />
case 'edit-binary':
Expand Down
18 changes: 18 additions & 0 deletions apps/sensenet/src/components/view-controls/image-view.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* @module ViewControls
*/
import { useRepository } from '@sensenet/hooks-react'
import React, { ReactElement } from 'react'

export interface ImageViewProps {
renderIcon?: (name: string) => ReactElement
handleCancel?: () => void
contentPath: string
}

export const ImageView: React.FC<ImageViewProps> = (props) => {
const { contentPath } = props
const repository = useRepository()

return <img src={`${repository.configuration.repositoryUrl}${contentPath}`} alt="" />
}
1 change: 1 addition & 0 deletions apps/sensenet/src/components/view-controls/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './browse-view'
export * from './edit-view'
export * from './image-view'
export * from './new-view'
export * from './permission-view'
export * from './version-view'

0 comments on commit ebe4706

Please sign in to comment.