Skip to content

Commit 9aaf7d0

Browse files
authored
Merge pull request #2955 from StoDevX/header-section-module
Add new module: <InfoHeader/>
2 parents 841adf9 + 70dbbdc commit 9aaf7d0

File tree

4 files changed

+72
-62
lines changed

4 files changed

+72
-62
lines changed

modules/info-header/index.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// @flow
2+
import * as React from 'react'
3+
import {View, Text, StyleSheet} from 'react-native'
4+
import * as c from '@frogpond/colors'
5+
6+
const styles = StyleSheet.create({
7+
content: {
8+
backgroundColor: c.white,
9+
borderWidth: StyleSheet.hairlineWidth,
10+
borderTopColor: c.iosHeaderTopBorder,
11+
borderBottomColor: c.iosHeaderBottomBorder,
12+
marginBottom: 10,
13+
},
14+
title: {
15+
fontSize: 16,
16+
fontWeight: 'bold',
17+
paddingTop: 15,
18+
paddingHorizontal: 15,
19+
},
20+
message: {
21+
fontSize: 14,
22+
paddingTop: 5,
23+
paddingBottom: 15,
24+
paddingHorizontal: 15,
25+
},
26+
})
27+
28+
type Props = {
29+
message: string,
30+
title: string,
31+
}
32+
33+
export class InfoHeader extends React.PureComponent<Props> {
34+
render() {
35+
return (
36+
<View style={styles.content}>
37+
<Text style={styles.title}>{this.props.title}</Text>
38+
<Text style={styles.message}>{this.props.message}</Text>
39+
</View>
40+
)
41+
}
42+
}

modules/info-header/package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "@frogpond/info-header",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"author": "",
7+
"license": "ISC",
8+
"scripts": {
9+
"test": "jest"
10+
},
11+
"peerDependencies": {
12+
"react": "^16.4.2",
13+
"react-native": "^0.55.4"
14+
},
15+
"dependencies": {
16+
"@frogpond/colors": "^1.0.0"
17+
}
18+
}

source/views/building-hours/report/overview.js

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
*/
66

77
import * as React from 'react'
8-
import {ScrollView, View, StyleSheet, Text} from 'react-native'
8+
import {ScrollView, View} from 'react-native'
99
import moment from 'moment-timezone'
10-
import * as c from '@frogpond/colors'
10+
import {InfoHeader} from '@frogpond/info-header'
1111
import {
1212
TableView,
1313
Section,
@@ -26,28 +26,6 @@ import type {TopLevelViewPropsType} from '../../types'
2626
import {summarizeDays, formatBuildingTimes, blankSchedule} from '../lib'
2727
import {submitReport} from './submit'
2828

29-
const styles = StyleSheet.create({
30-
helpWrapper: {
31-
backgroundColor: c.white,
32-
borderWidth: StyleSheet.hairlineWidth,
33-
borderTopColor: c.iosHeaderTopBorder,
34-
borderBottomColor: c.iosHeaderBottomBorder,
35-
marginBottom: 10,
36-
},
37-
helpTitle: {
38-
fontSize: 16,
39-
fontWeight: 'bold',
40-
paddingTop: 15,
41-
paddingHorizontal: 15,
42-
},
43-
helpDescription: {
44-
fontSize: 14,
45-
paddingTop: 5,
46-
paddingBottom: 15,
47-
paddingHorizontal: 15,
48-
},
49-
})
50-
5129
type Props = TopLevelViewPropsType & {
5230
navigation: {state: {params: {initialBuilding: BuildingType}}},
5331
}
@@ -203,13 +181,10 @@ export class BuildingHoursProblemReportView extends React.PureComponent<
203181

204182
return (
205183
<ScrollView>
206-
<View style={styles.helpWrapper}>
207-
<Text style={styles.helpTitle}>Thanks for spotting a problem!</Text>
208-
<Text style={styles.helpDescription}>
209-
If you could tell us what the new times are, we&rsquo;d greatly
210-
appreciate it.
211-
</Text>
212-
</View>
184+
<InfoHeader
185+
message="If you could tell us what the new times are, we&rsquo;d greatly appreciate it."
186+
title="Thanks for spotting a problem!"
187+
/>
213188

214189
<TableView>
215190
{schedules.map((s, i) => (

source/views/dictionary/report/editor.js

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @flow
22
import * as React from 'react'
3-
import {ScrollView, View, Text, StyleSheet} from 'react-native'
3+
import {ScrollView} from 'react-native'
4+
import {InfoHeader} from '@frogpond/info-header'
45
import {
56
TableView,
67
Section,
@@ -9,7 +10,6 @@ import {
910
} from '@frogpond/tableview'
1011
import {submitReport} from './submit'
1112
import type {WordType} from '../types'
12-
import * as c from '@frogpond/colors'
1313
import type {TopLevelViewPropsType} from '../../types'
1414

1515
type Props = TopLevelViewPropsType & {
@@ -65,13 +65,10 @@ export class DictionaryEditorView extends React.PureComponent<Props, State> {
6565
keyboardDismissMode="on-drag"
6666
keyboardShouldPersistTaps="always"
6767
>
68-
<View style={styles.helpWrapper}>
69-
<Text style={styles.helpTitle}>Thanks for spotting a problem!</Text>
70-
<Text style={styles.helpDescription}>
71-
If you could tell us what the word and definition should be,
72-
we&rsquo;d greatly appreciate it.
73-
</Text>
74-
</View>
68+
<InfoHeader
69+
message="If you could tell us what the word and definition should be, we&rsquo;d greatly appreciate it."
70+
title="Thanks for spotting a problem!"
71+
/>
7572

7673
<TableView>
7774
<Section header="WORD">
@@ -120,25 +117,3 @@ const DefinitionCell = ({text, onChange = () => {}}: TextFieldProps) => (
120117
value={text}
121118
/>
122119
)
123-
124-
const styles = StyleSheet.create({
125-
helpWrapper: {
126-
backgroundColor: c.white,
127-
borderWidth: StyleSheet.hairlineWidth,
128-
borderTopColor: c.iosHeaderTopBorder,
129-
borderBottomColor: c.iosHeaderBottomBorder,
130-
marginBottom: 10,
131-
},
132-
helpTitle: {
133-
fontSize: 16,
134-
fontWeight: 'bold',
135-
paddingTop: 15,
136-
paddingHorizontal: 15,
137-
},
138-
helpDescription: {
139-
fontSize: 14,
140-
paddingTop: 5,
141-
paddingBottom: 15,
142-
paddingHorizontal: 15,
143-
},
144-
})

0 commit comments

Comments
 (0)