Skip to content

Commit

Permalink
chore(): adss format script and formats files
Browse files Browse the repository at this point in the history
  • Loading branch information
sankhadeeproy007 committed Jun 24, 2019
1 parent 65f0bc7 commit 1e7744d
Show file tree
Hide file tree
Showing 61 changed files with 11,452 additions and 562 deletions.
10,599 changes: 10,599 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
],
"scripts": {
"compile": "rm -rf dist/* && babel . --out-dir dist --ignore node_modules,dist --source-maps ",
"format": "prettier --write \"src/**/*.{js,json}\"",
"transpile": "npm run compile && cp src/basic/Icon/NBIcons.json dist/src/basic/Icon",
"prepublish": "npm run transpile",
"postinstall": "node addEjectScript.js",
Expand Down Expand Up @@ -71,6 +72,7 @@
"typings": "./index.d.ts",
"optionalDependencies": {},
"peerDependencies": {
"prettier": "1.16.4",
"react": ">=16.4.1",
"react-native": ">=0.56.0"
},
Expand Down
38 changes: 19 additions & 19 deletions src/basic/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ class DefaultHeader extends React.Component {
? this.props.expandedIconStyle
: { color: variables.expandedIconStyle }
: this.props.icon && this.props.iconStyle
? this.props.iconStyle
: { color: variables.iconStyle }
? this.props.iconStyle
: { color: variables.iconStyle }
]}
name={
this.props.expanded
? this.props.expandedIcon
? this.props.expandedIcon
: "ios-arrow-up"
: this.props.icon
? this.props.icon
: "ios-arrow-down"
? this.props.icon
: "ios-arrow-down"
}
/>
</View>
Expand Down Expand Up @@ -102,28 +102,28 @@ class AccordionItem extends React.Component {
{this.props.renderHeader ? (
this.props.renderHeader(this.props.item, this.props.expanded)
) : (
<DefaultHeader
title={this.props.item.title}
expanded={this.props.expanded}
headerStyle={this.props.headerStyle}
icon={this.props.icon}
iconStyle={this.props.iconStyle}
expandedIcon={this.props.expandedIcon}
expandedIconStyle={this.props.expandedIconStyle}
/>
)}
<DefaultHeader
title={this.props.item.title}
expanded={this.props.expanded}
headerStyle={this.props.headerStyle}
icon={this.props.icon}
iconStyle={this.props.iconStyle}
expandedIcon={this.props.expandedIcon}
expandedIconStyle={this.props.expandedIconStyle}
/>
)}
</View>
</TouchableWithoutFeedback>
{this.props.expanded ? (
<AccordionSubItem>
{this.props.renderContent ? (
this.props.renderContent(this.props.item)
) : (
<DefaultContent
content={this.props.item.content}
contentStyle={this.props.contentStyle}
/>
)}
<DefaultContent
content={this.props.item.content}
contentStyle={this.props.contentStyle}
/>
)}
</AccordionSubItem>
) : null}
</View>
Expand Down
8 changes: 4 additions & 4 deletions src/basic/Base/NativeBaseComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ import PropTypes from "prop-types";
export default class NativeBaseComponent extends Component {
static contextTypes = {
theme: PropTypes.object,
foregroundColor: PropTypes.string,
foregroundColor: PropTypes.string
};

static propTypes = {
theme: PropTypes.object,
foregroundColor: PropTypes.string,
foregroundColor: PropTypes.string
};

static childContextTypes = {
theme: PropTypes.object,
foregroundColor: PropTypes.string,
foregroundColor: PropTypes.string
};

getChildContext() {
return {
theme: this.props.theme ? this.props.theme : this.context.theme,
theme: this.props.theme ? this.props.theme : this.context.theme
};
}

Expand Down
77 changes: 55 additions & 22 deletions src/basic/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ class Button extends Component {
style: this.getInitialStyle().borderedBtn
};

if(Array.isArray(this.props.style)){
const flattenedStyle = this.props.style.reduce(( accumulator, currentValue ) => accumulator.concat(currentValue), []);
return computeProps({...this.props, style: flattenedStyle}, defaultProps);
if (Array.isArray(this.props.style)) {
const flattenedStyle = this.props.style.reduce(
(accumulator, currentValue) => accumulator.concat(currentValue),
[]
);
return computeProps(
{ ...this.props, style: flattenedStyle },
defaultProps
);
}


return computeProps(this.props, defaultProps);
}
render() {
Expand All @@ -53,16 +58,14 @@ class Button extends Component {
const children =
Platform.OS === "ios"
? this.props.children
: React.Children.map(
this.props.children,
child =>
: React.Children.map(this.props.children, child =>
child && child.type === Text
? React.cloneElement(child, {
uppercase: variables.btnUppercaseAndroidText,
...child.props
})
uppercase: variables.btnUppercaseAndroidText,
...child.props
})
: child
);
);
if (
Platform.OS === "ios" ||
Platform.OS === "web" ||
Expand All @@ -83,30 +86,60 @@ class Button extends Component {
} else {
if (this.props.rounded) {
let buttonStyle = { ...this.prepareRootProps().style };
let buttonFlex = (this.props.full || this.props.block) ? 1 : buttonStyle.flex;
let buttonFlex =
this.props.full || this.props.block ? 1 : buttonStyle.flex;
return (
<View style={[{ maxHeight: buttonStyle.height }, buttonStyle, { paddingTop: undefined, paddingBottom: undefined }]} >
<View
style={[
{ maxHeight: buttonStyle.height },
buttonStyle,
{ paddingTop: undefined, paddingBottom: undefined }
]}
>
<TouchableNativeFeedback
ref={c => (this._root = c)}
background={
this.props.androidRippleColor
? TouchableNativeFeedback.Ripple(this.props.androidRippleColor, true)
: TouchableNativeFeedback.Ripple(variables.androidRippleColor, true)
? TouchableNativeFeedback.Ripple(
this.props.androidRippleColor,
true
)
: TouchableNativeFeedback.Ripple(
variables.androidRippleColor,
true
)
}
{...this.prepareRootProps()}
>
<View style={[styles.childContainer, { paddingTop: buttonStyle.paddingTop, paddingBottom: buttonStyle.paddingBottom, height: buttonStyle.height, flexGrow: buttonFlex }]}>
<View
style={[
styles.childContainer,
{
paddingTop: buttonStyle.paddingTop,
paddingBottom: buttonStyle.paddingBottom,
height: buttonStyle.height,
flexGrow: buttonFlex
}
]}
>
{children}
</View>
</TouchableNativeFeedback>
</View >
</View>
);
} else {
return (
<TouchableNativeFeedback
ref={c => (this._root = c)}
onPress={this.props.onPress}
background={this.props.transparent ? TouchableNativeFeedback.Ripple('transparent') : TouchableNativeFeedback.Ripple(variables.androidRippleColor, false)}
background={
this.props.transparent
? TouchableNativeFeedback.Ripple("transparent")
: TouchableNativeFeedback.Ripple(
variables.androidRippleColor,
false
)
}
{...this.prepareRootProps()}
>
<View {...this.prepareRootProps()}>{children}</View>
Expand Down Expand Up @@ -142,10 +175,10 @@ Button.propTypes = {
const styles = StyleSheet.create({
childContainer: {
flexShrink: 1,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center'
},
flexDirection: "row",
justifyContent: "center",
alignItems: "center"
}
});

const StyledButton = connectStyle(
Expand Down
34 changes: 21 additions & 13 deletions src/basic/CardItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,41 @@ class CardItem extends Component {
render() {
if (this.props.button) {
return (
<TouchableOpacity
ref={c => (this._root = c)}
activeOpacity={0.2}
{...this.props}
>
{this.props.children}
</TouchableOpacity>
<TouchableOpacity
ref={c => (this._root = c)}
activeOpacity={0.2}
{...this.props}
>
{this.props.children}
</TouchableOpacity>
);
} else {
return (
<View ref={c => (this._root = c)} {...this.props}>
{this.props.children}
</View>
<View ref={c => (this._root = c)} {...this.props}>
{this.props.children}
</View>
);
}
}
}

CardItem.propTypes = {
...TouchableOpacity.propTypes,
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),
style: PropTypes.oneOfType([
PropTypes.object,
PropTypes.number,
PropTypes.array
]),
header: PropTypes.bool,
cardBody: PropTypes.bool,
footer: PropTypes.bool,
button: PropTypes.bool,
button: PropTypes.bool
};

const StyledCardItem = connectStyle("NativeBase.CardItem", {}, mapPropsToStyleNames)(CardItem);
const StyledCardItem = connectStyle(
"NativeBase.CardItem",
{},
mapPropsToStyleNames
)(CardItem);

export { StyledCardItem as CardItem };
50 changes: 37 additions & 13 deletions src/basic/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,59 @@ import computeProps from "../utils/computeProps";

class CheckBox extends Component {
static contextTypes = {
theme: PropTypes.object,
theme: PropTypes.object
};

getInitialStyle(variables) {
return {
checkStyle: {
borderColor: this.props.color ? this.props.color : variables.checkboxBgColor,
borderColor: this.props.color
? this.props.color
: variables.checkboxBgColor,
backgroundColor:
this.props.checked === true
? this.props.color ? this.props.color : variables.checkboxBgColor
: "transparent",
},
? this.props.color
? this.props.color
: variables.checkboxBgColor
: "transparent"
}
};
}

prepareRootProps(variables) {
const defaultProps = {
style: this.getInitialStyle(variables).checkStyle,
style: this.getInitialStyle(variables).checkStyle
};

return computeProps(this.props, defaultProps);
}
render() {
const variables = this.context.theme ? this.context.theme["@@shoutem.theme/themeStyle"].variables : variable;
const variables = this.context.theme
? this.context.theme["@@shoutem.theme/themeStyle"].variables
: variable;
const platformStyle = variables.platformStyle;
const platform = variables.platform;
return (
<TouchableOpacity ref={c => (this._root = c)} {...this.prepareRootProps(variables)}>
<TouchableOpacity
ref={c => (this._root = c)}
{...this.prepareRootProps(variables)}
>
<IconNB
style={{
color: this.props.checked === true ? variables.checkboxTickColor : "transparent",
color:
this.props.checked === true
? variables.checkboxTickColor
: "transparent",
fontSize: variables.CheckboxFontSize,
lineHeight: variables.CheckboxIconSize,
marginTop: variables.CheckboxIconMarginTop,
textShadowRadius: 0
}}
name={platform === "ios" && platformStyle !== "material" ? "ios-checkmark" : "md-checkmark"}
name={
platform === "ios" && platformStyle !== "material"
? "ios-checkmark"
: "md-checkmark"
}
/>
</TouchableOpacity>
);
Expand All @@ -55,11 +71,19 @@ class CheckBox extends Component {

CheckBox.propTypes = {
...TouchableOpacity.propTypes,
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),
style: PropTypes.oneOfType([
PropTypes.object,
PropTypes.number,
PropTypes.array
]),
checked: PropTypes.bool,
onPress: PropTypes.func,
onPress: PropTypes.func
};

const StyledCheckBox = connectStyle("NativeBase.CheckBox", {}, mapPropsToStyleNames)(CheckBox);
const StyledCheckBox = connectStyle(
"NativeBase.CheckBox",
{},
mapPropsToStyleNames
)(CheckBox);

export { StyledCheckBox as CheckBox };
Loading

0 comments on commit 1e7744d

Please sign in to comment.