This commit is contained in:
Florian Bouillon 2021-04-26 11:07:11 +02:00
commit 58a48b28fd
5 changed files with 42 additions and 81 deletions

View File

@ -12,6 +12,22 @@
border-color $grayLight border-color $grayLight
.header
padding 16px
+ .body
padding-top 0
.title
font-weight bold
font-size rem(18)
margin 0 0 8px
.subtitle
font-size rem(16)
margin 0
// BODY // BODY
.body .body
padding 0 16px 16px padding 16px

View File

@ -1,13 +0,0 @@
@import "../../config.styl"
.header
padding 16px
.title
font-weight bold
font-size rem(18)
margin 0 0 8px
.subtitle
font-size rem(16)
margin 0

View File

@ -1,56 +0,0 @@
import React from 'react'
import { buildClassName } from '../../Util'
import css from './BoxHeader.module.styl'
import Row from '../../Row'
import Col from '../../Col'
import Text from '../../Text'
export interface Props {
title?: string
titleColSize?: number
subtitle?: string
titleClassName?: string
}
export default class BoxHeader extends React.Component<Props> {
public render = () => (
<>
<div data-t="true" className={buildClassName(
css.header
)}>
<Row nomargin justify="space-between">
<Col>
{this.props.title && (
<Text className={buildClassName(css.title, this.props.titleClassName)}>{this.props.title}</Text>
)}
{this.props.subtitle && (
<Text className={css.subtitle}>{this.props.subtitle}</Text>
)}
</Col>
{this.props.children && (
<Col nogrow>
<Row justify="flex-end">
{this.props.children}
</Row>
</Col>
)}
</Row>
</div>
</>
)
}
/*
Header
delimiter?: boolean
picture?: string // url
category?: string // subtitle but above title
title string
subtitle string
center?: boolean // if Center children is not used
children?: content
*/

View File

@ -1,9 +1,11 @@
import React from 'react' import React from 'react'
import BoxHeader from './BoxHeader'
import { buildClassName } from '../Util' import { buildClassName } from '../Util'
import css from './Box.module.styl' import css from './Box.module.styl'
import Row from '../Row'
import Col from '../Col'
import Text from '../Text'
interface Props { interface Props {
@ -37,14 +39,27 @@ export default class Box extends React.Component<Props> {
className={buildClassName(css.box, this.props.className, [css.outline, this.props.outline])} className={buildClassName(css.box, this.props.className, [css.outline, this.props.outline])}
> >
{(this.props.headerButtons || this.props.title || this.props.titleColSize || this.props.subtitle || this.props.delimiter || this.props.titleClassName) && ( {(this.props.headerButtons || this.props.title || this.props.titleColSize || this.props.subtitle || this.props.delimiter || this.props.titleClassName) && (
<BoxHeader <div className={buildClassName(
title={this.props.title} css.header
titleColSize={this.props.titleColSize} )}>
subtitle={this.props.subtitle} <Row nomargin justify="space-between">
titleClassName={this.props.titleClassName} <Col>
> {this.props.title && (
{this.props.headerButtons} <Text className={buildClassName(css.title, this.props.titleClassName)}>{this.props.title}</Text>
</BoxHeader> )}
{this.props.subtitle && (
<Text className={css.subtitle}>{this.props.subtitle}</Text>
)}
</Col>
{this.props.children && (
<Col nogrow>
<Row justify="flex-end">
{this.props.headerButtons}
</Row>
</Col>
)}
</Row>
</div>
)} )}
{this.props.children && ( {this.props.children && (
<div className={buildClassName([css.body, !this.props.noPadding])}> <div className={buildClassName([css.body, !this.props.noPadding])}>

View File

@ -3,14 +3,13 @@ import { X } from 'react-feather'
import Text from '../Text' import Text from '../Text'
import Box from '../Box' import Box from '../Box'
import Row from '../Row' import Row from '../Row'
import { Props as HeaderProps } from '../Box/BoxHeader'
import css from './Popup.module.styl' import css from './Popup.module.styl'
interface Props { interface Props {
children: React.ReactNode children: React.ReactNode
onClose?: () => void onClose?: () => void
header?: HeaderProps header?: Box['props']
} }
export default class Popup extends React.Component<Props> { export default class Popup extends React.Component<Props> {