Repository URL to install this package:
Version:
0.9.6 ▾
|
import React from 'react'
import { Empty } from 'atoms/Empty'
import { omit } from '@skava/modules/___dist/utils/omit'
import { CardProps } from './typings'
import { ExpandableState as CardState } from './State'
import {
CardWrapper,
ToggleButton,
DefaultWrapperView,
ExpandedWrapperView,
} from './styled'
const knownProps = Object.freeze([
'children',
'renderWrap',
'renderToggleButton',
'renderDefaultView',
'renderExpandedView',
])
/**
* @description only renders toggle button
*/
function renderToggleButton(props: CardProps, state: CardState) {
console.debug('[ExpandableCard] renderToggleButton')
// @note was props.state for some reason (huh)
return <ToggleButton onClick={state.handleToggle} text="toggle" />
}
/**
* @description the first view of the Expandable card
*/
function renderDefaultView(props: CardProps, state: CardState) {
return (
<DefaultWrapperView className="def-view">Default View!</DefaultWrapperView>
)
}
/**
* @description the Expandable view of the card
*/
function renderExpandedView(props: CardProps, state: CardState) {
return (
<ExpandedWrapperView className="open-view">
Expandable View!
</ExpandedWrapperView>
)
}
/**
* @description only renders wrappers
*/
function renderWrap(props: CardProps, state: CardState) {
const { children, ...remainingProps } = props
return <CardWrapper {...remainingProps}>{children}</CardWrapper>
}
export { renderWrap, renderToggleButton, renderDefaultView, renderExpandedView }