Fix List component styling

This commit is contained in:
John Lyon-Smith
2018-03-19 07:56:06 -07:00
parent 2f4cc3e261
commit bfd86b5b46
3 changed files with 20 additions and 30 deletions

View File

@@ -2,8 +2,6 @@ import Radium from 'radium'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import React, { Component } from 'react' import React, { Component } from 'react'
// TODO: Refactor this to allow setting each border property separately
class Box extends Component { class Box extends Component {
static propTypes = { static propTypes = {
borderTop: PropTypes.object, borderTop: PropTypes.object,
@@ -13,6 +11,7 @@ class Box extends Component {
border: PropTypes.object, border: PropTypes.object,
radius: PropTypes.number, radius: PropTypes.number,
background: PropTypes.string, background: PropTypes.string,
style: PropTypes.object,
children: PropTypes.node, children: PropTypes.node,
} }
@@ -20,7 +19,7 @@ class Box extends Component {
let { let {
children, background, children, background,
borderTop, borderBottom, borderLeft, borderRight, borderTop, borderBottom, borderLeft, borderRight,
border, radius } = this.props border, radius, style } = this.props
const flatten = (border) => { const flatten = (border) => {
if (!border) { if (!border) {
return null return null
@@ -44,9 +43,10 @@ class Box extends Component {
return ( return (
<div style={[ <div style={[
{ height: '100%', width: '100%', borderTop, borderBottom, borderLeft, borderRight }, { height: '100%', width: '100%', boxSizing: 'border-box', borderTop, borderBottom, borderLeft, borderRight },
background && { backgroundColor: background }, background && { backgroundColor: background },
radius && { borderRadius: radius }, radius && { borderRadius: radius },
style,
]}> ]}>
{children} {children}
</div> </div>

View File

@@ -26,7 +26,7 @@ class HeaderButton extends Component {
} }
render() { render() {
const size = sizeInfo.headerHeight - sizeInfo.headerBorderWidth const size = sizeInfo.headerHeight - 2 * sizeInfo.headerBorderWidth
const { onClick, icon, image } = this.props const { onClick, icon, image } = this.props
let content = null let content = null

View File

@@ -6,32 +6,26 @@ import { sizeInfo, colorInfo, fontInfo } from './style'
class List extends Component { class List extends Component {
static propTypes = { static propTypes = {
children: PropTypes.node children: PropTypes.node,
// data: PropTypes.array,
// render: PropTypes.func,
} }
render() { render() {
const { children } = this.props const { children } = this.props
return ( return (
<div style={{
position: 'absolute',
width: '100%',
height: '100%',
fontSize: fontInfo.size.large,
fontFamily: fontInfo.family,
}}>
<Box <Box
border={{ width: sizeInfo.listBorderWidth, color: colorInfo.listBorder }} border={{ width: sizeInfo.listBorderWidth, color: colorInfo.listBorder }}
radius={sizeInfo.formBoxRadius}> radius={sizeInfo.formBoxRadius} style={{
<div style={{ position: 'absolute',
height: '100%', overflowY: 'hidden',
width: '100%', fontSize: fontInfo.size.large,
overflowY: 'scroll', fontFamily: fontInfo.family,
overflow: 'scroll',
}}> }}>
{children} {children}
</div>
</Box> </Box>
</div>
) )
} }
} }
@@ -48,7 +42,7 @@ List.Item = Radium(class ListItem extends Component {
return ( return (
<div style={{ <div style={{
display: 'table-row', width: '100%',
background: active ? colorInfo.listBackgroundActive : 'transparent', background: active ? colorInfo.listBackgroundActive : 'transparent',
':hover': { ':hover': {
background: colorInfo.listBackgroundHover background: colorInfo.listBackgroundHover
@@ -72,7 +66,6 @@ List.Icon = Radium(class ListIcon extends Component {
return ( return (
<img src={source} style={{ <img src={source} style={{
display: 'table-cell',
verticalAlign: 'middle', verticalAlign: 'middle',
width: size, width: size,
height: size, height: size,
@@ -91,11 +84,8 @@ List.Text = Radium(class ListText extends Component {
return ( return (
<span style={{ <span style={{
display: 'table-cell',
width: '100%',
color: fontInfo.color.normal, color: fontInfo.color.normal,
align: 'left', align: 'left',
verticalAlign: 'middle',
textAlign: 'left', textAlign: 'left',
cursor: 'default', cursor: 'default',
}}>{children}</span> }}>{children}</span>