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

Add custom limit to CountBadge #935

Merged

Conversation

alanbsmith
Copy link
Member

@alanbsmith alanbsmith commented Jan 7, 2021

Summary

Resolves #936

This PR adds functionality for custom limits to format the displayed count in CountBadge. I also added a test and updated the docs.

Checklist

  • branch has been rebased on the latest master commit
  • tests are changed or added
  • yarn test passes
  • all (dev)dependencies that the module needs is added to its package.json
  • code has been documented and, if applicable, usage described in README.md
  • module has been added to canvas-kit-react and/or canvas-kit-css universal modules, if
    applicable
  • design approved final implementation
  • a11y approved final implementation
  • code adheres to the API & Pattern guidelines

Additional References

Screen Shot 2021-01-07 at 10 36 49 AM

@alanbsmith alanbsmith added enhancement New feature or request ready for review Code is ready for review labels Jan 7, 2021
@alanbsmith alanbsmith added this to In Progress in Current Sprint (7/20 - 8/9) via automation Jan 7, 2021
@project-bot project-bot bot moved this from In Progress to Needs Review in Current Sprint (7/20 - 8/9) Jan 7, 2021
@mannycarrera4
Copy link
Contributor

LGTM 👍

@cypress
Copy link

cypress bot commented Jan 7, 2021



Test summary

560 0 1 0


Run details

Project canvas-kit
Status Passed
Commit 593d193 ℹ️
Started Jan 7, 2021 5:45 PM
Ended Jan 7, 2021 5:50 PM
Duration 04:50 💡
OS Linux Ubuntu Linux - 18.04
Browser Electron 80

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard


const formattedCount = count < 1000 ? `${count}` : '999+';
const formattedCount = count < limit ? `${count}` : `${limit - 1}+`;
Copy link
Member Author

Choose a reason for hiding this comment

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

Note: The math here won't work if numbers are negative. haha

We could validate the limit here "needs to be greater than 0" or something like that, but I kind of want to keep the badge as dumb as possible.

@alanbsmith alanbsmith removed this from Needs Review in Current Sprint (7/20 - 8/9) Jan 7, 2021
@alanbsmith alanbsmith linked an issue Jan 7, 2021 that may be closed by this pull request
@alanbsmith alanbsmith merged commit 37cfd15 into Workday:master Jan 7, 2021
alanbsmith added a commit to alanbsmith/canvas-kit that referenced this pull request Feb 16, 2021
75e909f (upstream/master, master) feat(common): Add useIsRTL hook to common module (Workday#971)
771a215 fix(tabs): Remove event.preventDefault from TabList (Workday#969)
b7f87a1 Update Pagination component (Workday#954)
91acada Roll back to `pull_request`
69cc4b4 fix: Add crossorigin to font preloads (Workday#967)
ea5dbd8 ci: Use pull_request_target in GH Actions
159da10 docs: Fix Story names and extra imports (Workday#966)
8dcc951 docs: Improve documentation (Workday#964)
221fa1c feat: Add closeButtonAriaLabel to Modal Component (Workday#959)
339be74 ci: Remove jest code-coverage threshold (Workday#957)
6491da3 docs: Add compound component doc (Workday#937)
d7ec090 feat: Add window config option to inherit or override mono font family (Workday#916)
968130a chore: Bump ini from 1.3.5 to 1.3.7 (Workday#931)
27504a1 feat(skeleton): Add option for different skeleton colors (Workday#939)
3ba2da8 chore: Update @workday/canvas-system-icons-web dependency (Workday#940)
37cfd15 Add custom limit to CountBadge (Workday#935)
3634149 chore(form-field): Update FormField Readme (Workday#930)
42b9235 fix: Fix create component scripts (Workday#929)
b3ee342 docs: Standardize README badges for Labs components (Workday#928)
@alanbsmith alanbsmith mentioned this pull request Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready for review Code is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an optional custom limit to CountBadge
3 participants