Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Badge refractor #1545

Merged
merged 5 commits into from
Nov 3, 2018
Merged

Badge refractor #1545

merged 5 commits into from
Nov 3, 2018

Conversation

iRoachie
Copy link
Collaborator

@iRoachie iRoachie commented Nov 1, 2018

Motivation

The Badge is a component that doesn't get as much use as it could. This PR aims to make the badge more useful as well as highlighting use cases where it may be good to use a badge.

BREAKING CHANGES

  • wrapperStyle has been removed. Was kind of pointless and misleading since we don't use the term wrapper anywhere in other components. containerStyle now functions as what was wrapperStyle and a new prop badgeStyle replaces what was containerStyle in a similar fashion to the Button component.
  • The element prop which was undocumented was removed. Just use the value prop
  • Badges can no longer render children. Instead, if you want a custom component you can use the value prop which now supports rendering react components (thanks to renderNodehelper).

Features

  • Adds "mini badge" which functions as a status indicator when no value is provided.
  • Adds status prop which is a convenience prop for styling the background via badgeStyle for quick and commonly used scenarios

API

// Standard badge
<Badge value="99+" status="error" />
<Badge value={<Text>My Custom Badge</Text>}/>

// Mini badge
<Badge status="success" />
<Badge status="error" />
<Badge status="primary" />
<Badge status="warning" />

// Avatar with mini badge
<View>
  <Avatar
    source={{
      uri: 'https://randomuser.me/api/portraits/men/41.jpg',
    }}
    size="large"
  />

  <Badge
    status="success"
    containerStyle={{ position: 'absolute', top: -5, right: -5 }}
  />
</View>

Screenshots

screen shot 2018-11-01 at 1 21 28 pm

@iRoachie iRoachie added this to the 1.0.0 milestone Nov 1, 2018
@codecov
Copy link

codecov bot commented Nov 1, 2018

Codecov Report

Merging #1545 into next will decrease coverage by 0.07%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##             next    #1545      +/-   ##
==========================================
- Coverage   75.72%   75.64%   -0.08%     
==========================================
  Files          33       33              
  Lines         618      616       -2     
  Branches       86       82       -4     
==========================================
- Hits          468      466       -2     
  Misses        129      129              
  Partials       21       21
Impacted Files Coverage Δ
src/badge/badge.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 364e1a7...eb97e8e. Read the comment docs.

Badges when they have a few characters are circuclar. As the value is
longer, they'll keep the same height and grow horizontally.
Copy link
Collaborator

@xavier-villelegier xavier-villelegier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a neeeaaat PR, tests, docs, clean code. That's a 💯
giphy

@iRoachie iRoachie merged commit 3dc362d into next Nov 3, 2018
@iRoachie iRoachie deleted the badge-upgrade branch November 3, 2018 02:38
nurdiansyah added a commit to deboxlibrary/react-native-elements that referenced this pull request Nov 6, 2018
* commit '0126436f5f0f37e0340b0c1da32bdea5605cb6df': (43 commits)
  feat(Card): Remove flexDirection prop
  feat(Card): Remove fontFamily prop
  test: Add tests for withTheme
  test: Fix searcbar error being logged to console
  fix: Hoist statics for withTheme hoc (react-native-elements#1554)
  fix: Use library for calculating statusBar height (react-native-elements#1553)
  ref: Badge component (react-native-elements#1545)
  Set default prop for type (react-native-elements#1546)
  docs: Fix paragraphs links in docs (react-native-elements#1536)
  docs(website): Make image preview section reusable
  feat: Add button types (react-native-elements#1540)
  fix: Rounded buttons on android now work correctly (react-native-elements#1538)
  ci: Run travis against node stable
  fix: Make button height consistent when using loading
  ci: Update husky and lint-staged
  feat: Add AntDesign to list of available icon sets (react-native-elements#1529)
  docs(website): Add central place to show supported icon sets (react-native-elements#1532)
  feat(Input): Allow label to be a React element (react-native-elements#1531)
  ci: Remove expo ci from PRs (react-native-elements#1528)
  fix(Button): Make the padding consistent (react-native-elements#1505)
  ...
iRoachie added a commit that referenced this pull request Dec 9, 2018
Badge sizes were much too big compared to actual badges in apps.
This commit more realigns with the sizes before the badge refractor in #1545.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants