Skip to content

Commit

Permalink
active border color, width added.
Browse files Browse the repository at this point in the history
  • Loading branch information
yasaricli committed Aug 5, 2019
1 parent dfddce3 commit 4ee8825
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export default class Dots extends Component {
passiveDotWidth: PropTypes.number,
activeDotWidth: PropTypes.number,
passiveColor: PropTypes.string,
activeColor: PropTypes.string
activeColor: PropTypes.string,

// active Border
activeBorder: PropTypes.bool,
activeBorderColor: PropTypes.string,
activeBorderWidth: PropTypes.number
};
}

Expand All @@ -36,7 +41,12 @@ export default class Dots extends Component {
passiveDotWidth: 10,
activeDotWidth: 15,
passiveColor: '#CCCCCC',
activeColor: '#016bd8'
activeColor: '#016bd8',

// Borders
activeBorder: false,
activeBorderWidth: 3,
activeBorderColor: '#FFF'
};

componentWillReceiveProps({ active }) {
Expand All @@ -63,17 +73,33 @@ export default class Dots extends Component {
}

dotStyle(isActive) {
const { activeDotWidth, passiveDotWidth, activeColor, passiveColor } = this.props;
const {
activeDotWidth,
passiveDotWidth,
activeColor,
passiveColor,
activeBorder,
activeBorderWidth,
activeBorderColor
} = this.props;
const width = isActive ? activeDotWidth : passiveDotWidth;

return {
let style = {
width,
height: width,
backgroundColor: isActive ? activeColor : passiveColor,
borderRadius: width,
marginHorizontal: 2,
marginTop: isActive ? -width / 6 : 0
};

// active Border Styles.
if (activeBorder && isActive) {
style.borderWidth = activeBorderWidth;
style.borderColor = activeBorderColor;
}

return style;
}

render() {
Expand Down

0 comments on commit 4ee8825

Please sign in to comment.