summaryrefslogtreecommitdiff
path: root/client/src/lib/components/definition.js
blob: b6b78f5237d963775e896ac42e52c6e1a71dbb30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import React, { Component } from 'react';
import {
  StyleSheet,
  View,
} from 'react-native';

import ClearText from './text'

export default class Definition extends Component {
  render() {
    let { labelStyle, contentStyle, label, children, contentIsView, ...others } = this.props
    let content;
    if (contentIsView) {
      content = (
        <View style={[styles.contentView, contentStyle]}>{children}</View>
      )
    }
    else {
      content = (
        <ClearText style={[styles.content, contentStyle]}>{children}</ClearText>
      )
    }
    return (
      <View style={styles.item} {...others}>
        <ClearText style={[styles.label, labelStyle]}>{label}</ClearText>
        {content}
      </View>
    )
  }
}

const styles = StyleSheet.create({
  item: {
    justifyContent: 'flex-start',
    flexDirection: 'row',
    width: '100%',
    paddingBottom: 0,
  },
  label: {
    width: 80,
    minWidth: 80,
    textAlign: 'left',
    color: '#bbb',
  },
  content: {
    flex: 1,
    textAlign: 'left'
  },
  contentView: {
    flex: 1,
  },
})