Skip to content

Commit

Permalink
chore: reogranize getImageSrc exported fn #1542
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-mihok committed Oct 23, 2022
1 parent 5702a12 commit 44c042d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 7 additions & 1 deletion ui/src/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { stylesheet } from 'typestyle'
import { cards, Format, grid } from './layout'
import { formItemWidth } from './theme'
import { bond } from './ui'
import { getImageSrc, lightboxB, LightboxProps } from './parts/lightbox'
import { lightboxB, LightboxProps } from './parts/lightbox'

const
css = stylesheet({
Expand Down Expand Up @@ -66,6 +66,12 @@ export interface Image {
visible?: B
}

export const getImageSrc = ({ type, image, path }: Image) => path
? path
: (image && type)
? `data:image/${type};base64,${image}`
: ''

export const
XImage = ({ model: m }: { model: Image }) => {
const
Expand Down
7 changes: 1 addition & 6 deletions ui/src/parts/lightbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { stylesheet, style } from 'typestyle'
import * as Fluent from '@fluentui/react'
import { clas, cssVar } from '../theme'
import { getColorFromString, isDark } from '@fluentui/react'
import { getImageSrc } from '../image'

export const lightboxB: Box<LightboxProps | null> = box()

Expand Down Expand Up @@ -108,12 +109,6 @@ export interface LightboxProps {
defaultImageIdx?: U
}

export const getImageSrc = ({ type, image, path }: Image) => path
? path
: (image && type)
? `data:image/${type};base64,${image}`
: ''

export const Lightbox = ({ images, defaultImageIdx }: LightboxProps) => {
const
[activeImageIdx, setActiveImageIdx] = React.useState(defaultImageIdx || 0),
Expand Down

0 comments on commit 44c042d

Please sign in to comment.