Skip to content
This repository has been archived by the owner on May 31, 2021. It is now read-only.

Commit

Permalink
refactor: correct lint errors; update README [Badge] (#339)
Browse files Browse the repository at this point in the history
* fix: 🚨 remove Badge linter errors

* fix: 🚨 rmove DatePicker.test linter errors

* test: 📸 update DatePicker snapshots

* style: remove empty lines

* Revert "test: 📸 update DatePicker snapshots"

This reverts commit 4c7329b.

* Revert "fix: 🚨 rmove DatePicker.test linter errors"

This reverts commit d8d1868.

* [Badge] docs: update README
  • Loading branch information
greatSumini authored Sep 20, 2020
1 parent cf2798e commit 4674a67
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion main/Badge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
| **showZero** | | boolean | true | Set whether to show '0' count number in badge or not |
| **opacityVisible** | | boolean | true | Set application of change in color opacity |
| **variant** | | string |'standard' | Set shape of the badge. Available choices are 'dot' and 'standard' |
| **position** | | string | 'right' | Set position of the badge. Available choices are 'left', 'right' , 'top', 'down'. |
| **badgePlacement** | | string | 'right' | Set position of the badge. Available choices are 'left', 'right' , 'top', 'down'. |
| **border** | | string | | Set border color of the badge. |
| **textColor** | | string | '#FFFFFF' | Set textColor of the count number inside the badge. |

Expand Down
26 changes: 16 additions & 10 deletions main/Badge/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { FC } from 'react';
import styled, { css } from 'styled-components/native';
import { FlattenSimpleInterpolation } from 'styled-components';

import { StyleSheet } from 'react-native';
import styled from 'styled-components/native';

interface StyleProps {
color?: string;
Expand All @@ -11,7 +12,7 @@ interface StyleProps {
textColor?: string;
}

export interface BadgeProps extends StyleProps{
export interface BadgeProps extends StyleProps {
count?: number;
maximumCount?: number;
showZero?: boolean;
Expand All @@ -22,38 +23,43 @@ export interface BadgeProps extends StyleProps{
const StyledView = styled.View<StyleProps>`
position: absolute;
top: -15px;
${(props) => props.badgePlacement}: -10px;
width: auto;
min-width: 45px;
height: 45px;
border-color: ${(props) =>
props.border ? props.border : '#00ff0000'};
border-width: 3px;
background-color: ${(props) => props.color};
border-radius: 50px;
justify-content: center;
align-items: center;
opacity: ${(props) => props.opacity};
${(props): FlattenSimpleInterpolation => css`
${props.badgePlacement}: -10px;
opacity: ${props.opacity};
border-color: ${props.border || '#00ff0000'};
background-color: ${props.color};
`}
`;

const StyledText = styled.Text<StyleProps>`
color: ${(props) => props.textColor};
text-align: center;
padding: 5px;
margin-left: 3px;
margin-right: 3px;
${(props): FlattenSimpleInterpolation => css`
color: ${props.textColor};
`}
`;

const StyledDotView = styled.View<StyleProps>`
position: absolute;
top: -5px;
${(props) => props.badgePlacement}: -5px;
width: 20px;
height: 20px;
background-color: ${(props) => props.color};
border-radius: 50px;
justify-content: center;
align-items: center;
${(props): FlattenSimpleInterpolation => css`
${props.badgePlacement}: -5px;
background-color: ${props.color};
`}
`;

const styles = StyleSheet.create({
Expand Down

0 comments on commit 4674a67

Please sign in to comment.