Skip to content

Commit

Permalink
Bump prettier to 1.13.3 and add .prettierrc
Browse files Browse the repository at this point in the history
  • Loading branch information
oblador committed May 30, 2018
1 parent c202027 commit 1bcb30a
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 132 deletions.
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5"
}
28 changes: 16 additions & 12 deletions Examples/IconExplorer/IconList.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const styles = StyleSheet.create({
backgroundColor: 'white',
},
searchBar: {
marginTop: (Platform.OS === 'android' ? 0 : 64),
marginTop: Platform.OS === 'android' ? 0 : 64,
padding: 3,
paddingLeft: 8,
flexDirection: 'row',
Expand All @@ -24,7 +24,7 @@ const styles = StyleSheet.create({
searchBarInput: {
fontSize: 15,
flex: 1,
height: (Platform.OS === 'android' ? 45 : 30),
height: Platform.OS === 'android' ? 45 : 30,
},
row: {
flexDirection: 'row',
Expand All @@ -50,7 +50,9 @@ export default class IconList extends PureComponent {
constructor(props) {
super(props);

const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
const ds = new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2,
});
this.state = {
filter: '',
dataSource: ds.cloneWithRows(this.props.iconSet.glyphs),
Expand All @@ -59,10 +61,10 @@ export default class IconList extends PureComponent {

componentDidMount() {
if (Platform.OS === 'osx') {
this._searchListner = DeviceEventEmitter.addListener('onSearchIcons',
(e) => this.searchIcons(e.query.toLowerCase())
this._searchListner = DeviceEventEmitter.addListener('onSearchIcons', e =>
this.searchIcons(e.query.toLowerCase())
);
console.log({_searchListner: this._searchListner})
console.log({ _searchListner: this._searchListner });
}
}

Expand Down Expand Up @@ -117,14 +119,18 @@ export default class IconList extends PureComponent {
placeholder="Search an icon..."
style={styles.searchBarInput}
onFocus={() =>
this.refs.listview && this.refs.listview.getScrollResponder().scrollTo(0, 0)}
this.refs.listview &&
this.refs.listview.getScrollResponder().scrollTo(0, 0)
}
/>
</View>
)}
)}
<View style={styles.separator} />
<ListView
dataSource={this.state.dataSource}
renderRow={(rowData, sectionID, rowID) => this._renderRow(rowData, sectionID, rowID)}
renderRow={(rowData, sectionID, rowID) =>
this._renderRow(rowData, sectionID, rowID)
}
automaticallyAdjustContentInsets={false}
keyboardDismissMode="on-drag"
keyboardShouldPersistTaps="always"
Expand All @@ -141,9 +147,7 @@ export default class IconList extends PureComponent {
<View>
<View style={styles.row}>
<Icon name={rowData[0]} size={20} style={styles.icon} />
<Text style={styles.text}>
{rowData.join(', ')}
</Text>
<Text style={styles.text}>{rowData.join(', ')}</Text>
</View>
<View style={styles.separator} />
</View>
Expand Down
165 changes: 100 additions & 65 deletions Examples/IconExplorer/IconSetList.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,30 @@ const GLYPH_MAPS = {
Zocial: ZocialGlyphs,
};

const ICON_SETS = _.map({
Entypo,
EvilIcons,
Feather,
FontAwesome,
Foundation,
Ionicons,
MaterialIcons,
MaterialCommunityIcons,
Octicons,
Zocial,
}, (component, name) => ({ name, component }))
.map(iconSet => {
// Some icons have multiple names, so group them by glyph
const glyphMap = GLYPH_MAPS[iconSet.name];
iconSet.glyphs = _.values(_.groupBy(Object.keys(glyphMap), name => glyphMap[name]));
return iconSet;
});
const ICON_SETS = _
.map(
{
Entypo,
EvilIcons,
Feather,
FontAwesome,
Foundation,
Ionicons,
MaterialIcons,
MaterialCommunityIcons,
Octicons,
Zocial,
},
(component, name) => ({ name, component })
)
.map(iconSet => {
// Some icons have multiple names, so group them by glyph
const glyphMap = GLYPH_MAPS[iconSet.name];
iconSet.glyphs = _.values(
_.groupBy(Object.keys(glyphMap), name => glyphMap[name])
);
return iconSet;
});

const BUTTONS = [
{
Expand All @@ -89,29 +95,47 @@ const BUTTONS = [

const STYLING = [
{ name: 'github', size: 40, color: '#333' },
{ name: 'heart', size: 30, color: 'white', containerStyle: {
backgroundColor: '#e0284f',
borderRadius: 23,
paddingHorizontal: 8,
paddingTop: 9,
paddingBottom: 7,
} },
{ name: 'star', size: 20, color: '#FF0000', containerStyle: {
borderRadius: 20,
padding: 7,
borderWidth: 3,
backgroundColor: '#FFDD00',
borderColor: '#165E00',
} },
{ name: 'font', size: 20, color: 'white', containerStyle: {
borderRadius: 5,
padding: 5,
backgroundColor: '#47678e',
} },
{
name: 'heart',
size: 30,
color: 'white',
containerStyle: {
backgroundColor: '#e0284f',
borderRadius: 23,
paddingHorizontal: 8,
paddingTop: 9,
paddingBottom: 7,
},
},
{
name: 'star',
size: 20,
color: '#FF0000',
containerStyle: {
borderRadius: 20,
padding: 7,
borderWidth: 3,
backgroundColor: '#FFDD00',
borderColor: '#165E00',
},
},
{
name: 'font',
size: 20,
color: 'white',
containerStyle: {
borderRadius: 5,
padding: 5,
backgroundColor: '#47678e',
},
},
];

const INLINE = [
(<Text>This text has <FontAwesome name="rocket" /> inline <FontAwesome name="hand-peace-o"> icons!</FontAwesome></Text>),
<Text>
This text has <FontAwesome name="rocket" /> inline{' '}
<FontAwesome name="hand-peace-o"> icons!</FontAwesome>
</Text>,
];

const styles = StyleSheet.create({
Expand Down Expand Up @@ -166,8 +190,12 @@ export default class IconSetsList extends PureComponent {
return (
<ListView
dataSource={this.state.dataSource}
renderSectionHeader={(data, section) => this._renderSectionHeader(data, section)}
renderRow={(rowData, sectionID, rowID) => this._renderRow(rowData, sectionID, rowID)}
renderSectionHeader={(data, section) =>
this._renderSectionHeader(data, section)
}
renderRow={(rowData, sectionID, rowID) =>
this._renderRow(rowData, sectionID, rowID)
}
initialListSize={15}
/>
);
Expand All @@ -176,38 +204,46 @@ export default class IconSetsList extends PureComponent {
_renderSectionHeader(data, section) {
return (
<View style={styles.sectionHeader}>
<Text style={styles.sectionHeaderTitle}>
{section.toUpperCase()}
</Text>
<Text style={styles.sectionHeaderTitle}>{section.toUpperCase()}</Text>
</View>
);
}

_renderRow(rowData, sectionID, rowID) {
switch (sectionID) {
case 'iconSets': return (
<TouchableHighlight onPress={() => this._pressRow(rowID)} underlayColor="#eee">
case 'iconSets':
return (
<TouchableHighlight
onPress={() => this._pressRow(rowID)}
underlayColor="#eee"
>
<View>
<View style={styles.row}>
<Text style={styles.text}>{rowData.name}</Text>
<Text style={styles.glyphCount}>{rowData.glyphs.length}</Text>
</View>
<View style={styles.separator} />
</View>
</TouchableHighlight>
);
case 'buttons':
return (
<View>
<View style={styles.row}>
<Text style={styles.text}>
{rowData.name}
</Text>
<Text style={styles.glyphCount}>
{rowData.glyphs.length}
</Text>
<FontAwesome.Button
name={rowData.icon}
backgroundColor={rowData.backgroundColor}
color={rowData.color}
onPress={() =>
Alert.alert('You pressed "' + rowData.text + '"')
}
>
{rowData.text}
</FontAwesome.Button>
</View>
<View style={styles.separator} />
</View>
</TouchableHighlight>
);
case 'buttons': return (
<View>
<View style={styles.row}>
<FontAwesome.Button name={rowData.icon} backgroundColor={rowData.backgroundColor} color={rowData.color} onPress={() => Alert.alert('You pressed "' + rowData.text + '"')}>{rowData.text}</FontAwesome.Button>
</View>
<View style={styles.separator} />
</View>
);
);
case 'styling':
return (
<View>
Expand All @@ -222,13 +258,12 @@ export default class IconSetsList extends PureComponent {
case 'inline':
return (
<View>
<View style={styles.row}>
{rowData}
</View>
<View style={styles.row}>{rowData}</View>
<View style={styles.separator} />
</View>
);
default: return false;
default:
return false;
}
}

Expand Down
12 changes: 7 additions & 5 deletions Examples/IconExplorer/index.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,28 @@ function RouteMapper(route, navigationOperations, onComponentRef) {
_navigator = navigationOperations;
if (route.name === 'list') {
return (
<View style={{flex: 1}}>
<View style={{ flex: 1 }}>
<Ionicons.ToolbarAndroid
style={styles.toolbar}
titleColor="white"
title={route.title} />
title={route.title}
/>
<IconSetList navigator={navigationOperations} />
</View>
);
} else if (route.name === 'iconSet') {
return (
<View style={{flex: 1}}>
<View style={{ flex: 1 }}>
<Ionicons.ToolbarAndroid
actions={[]}
navIconName="md-arrow-back"
onIconClicked={navigationOperations.pop}
style={styles.toolbar}
titleColor="white"
title={route.title} />
title={route.title}
/>
<IconList
style={{flex: 1}}
style={{ flex: 1 }}
navigator={navigationOperations}
iconSet={route.iconSet}
/>
Expand Down
6 changes: 1 addition & 5 deletions Examples/IconExplorer/index.ios.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import React, { PureComponent } from 'react';
import {
AppRegistry,
NavigatorIOS,
StyleSheet,
} from 'react-native';
import { AppRegistry, NavigatorIOS, StyleSheet } from 'react-native';

import IconSetList from './IconSetList';

Expand Down
28 changes: 19 additions & 9 deletions Examples/IconExplorer/index.osx.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@ class Welcome extends PureComponent {
render() {
return (
<View style={styles.welcomeWrapper}>
<Text style={styles.welcomeText}>Choose an icon set on the left side</Text>
<Text style={styles.welcomeText}>
Choose an icon set on the left side
</Text>
</View>
);
}
}

class IconExplorer extends PureComponent {

constructor() {
super();
this.state = {
Expand All @@ -61,15 +62,24 @@ class IconExplorer extends PureComponent {
const { iconSet, iconSetTitle, layout } = this.state;

return (
<View style={styles.container} onLayout={(e) => this.setState({layout: e.nativeEvent.layout})}>
<View
style={styles.container}
onLayout={e => this.setState({ layout: e.nativeEvent.layout })}
>
<View style={styles.leftPanel}>
<IconSetList navigator={{ push: (route) => this.setState({ iconSet: route.iconSet }) }}/>
<IconSetList
navigator={{
push: route => this.setState({ iconSet: route.iconSet }),
}}
/>
</View>
<View style={[styles.rightPanel, { width: layout.width - LEFT_PANEL_WIDTH }]}>
{(iconSet
? (<IconList iconSet={iconSet} />)
: (<Welcome />)
)}
<View
style={[
styles.rightPanel,
{ width: layout.width - LEFT_PANEL_WIDTH },
]}
>
{iconSet ? <IconList iconSet={iconSet} /> : <Welcome />}
</View>
</View>
);
Expand Down
Loading

0 comments on commit 1bcb30a

Please sign in to comment.