Repository URL to install this package:
|
Version:
2.1.14 ▾
|
import React from 'react'
import { toUrlWithProtocol } from '@skava/utils'
import { CategoryBaseComponentProps, CategoryGridProps } from './typings'
import {
StyledLink,
StyledTitle,
StyledMediaCarousel,
StyledFigure,
StyledWrapper,
} from './styled'
function defaultRenderComponent(props: CategoryBaseComponentProps) {
const { src, caption, url, alternateText } = props
const imageUrl = toUrlWithProtocol(url)
const imageSrc =
src !== ''
? toUrlWithProtocol(src)
: 'https://reactdemo.skavaone.com/images/null_image.png'
return (
<StyledLink text={caption} to={imageUrl}>
<StyledFigure caption={caption} src={imageSrc} alt={alternateText} />
</StyledLink>
)
}
function defaultRenderWrapper(props: CategoryGridProps) {
const { className, title, ...remainingProps } = props
return (
<StyledWrapper className={className}>
<StyledTitle>{title}</StyledTitle>
<StyledMediaCarousel
renderItem={defaultRenderComponent}
{...remainingProps}
/>
</StyledWrapper>
)
}
export { defaultRenderWrapper }