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

Consider separate 'Cleared' and 'Unset' values for badges. #42

Closed
fallaciousreasoning opened this issue Jul 17, 2019 · 2 comments
Closed

Comments

@fallaciousreasoning
Copy link
Collaborator

This is semi related to #19.

What the behavior of Badge.clear({ scope: '...' }) should be is a little unclear.

Is the badge for that specific scope now clear or does it display the badge from a parent scope?

Perhaps we should remove separate set/clear methods in favor of something like this:

Badge.set({
    badge: number | boolean | undefined,
    scope: string
});

A badge for a scope can be in one of four states:

  • unset: The badge from a parent scope will be applied (or none, if there is no badge for a parent scope).
  • cleared: No badge is displayed for the scope.
  • flag: A special value indicating a notification dot should be displayed.
  • <number> A non-zero, positive number: The value will be displayed in the badge.

If badge is undefined or not present then the badge for the scope is unset
If badge is a boolean false sets the badge to cleared while true sets it to flag.
If badge is a number 0 sets the badge to cleared while other positive numbers set the badge to that number.

Alternatively, we could introduce separate methods for each value, as in #19.

// 0 sets the badge to cleared, other values set the badge to that value.
Badge.setNumber(<number>, { scope: '...' }); 

// false sets the badge to cleared, true sets the badge to flag.
Badge.setFlag(boolean, { scope: '...' });

// Unsets the badge.
Badge.unset({ scope: '...' });

I think this second approach is more friendly for polyfilling (though both should be polyfillable) if we add a new type (such as glyphs). However, in the second approach, it's less obvious that there is only one badge value active at any time.

@domenic I know you had some thoughts on this.
@marcoscaceres @mgiuca @raymeskhoury

@fallaciousreasoning
Copy link
Collaborator Author

fallaciousreasoning commented Jul 17, 2019

@raymeskhoury floated that we stick with the current Badge.clear({ scope: '...' }) design and add an optional extra noInherit property if we decide we need it in the future.

Badge.clear({
    scope: `/special-scope`,
    noInherit: true
});

which would make the badge for /special-scope not check parent scopes for badges. So maybe we don't need to do anything here.

@fallaciousreasoning fallaciousreasoning changed the title Consider removing Badge.clear() Consider separate 'Cleared' and 'Unset Jul 23, 2019
@fallaciousreasoning fallaciousreasoning changed the title Consider separate 'Cleared' and 'Unset Consider separate 'Cleared' and 'Unset' values for badges. Jul 23, 2019
@fallaciousreasoning
Copy link
Collaborator Author

Resolution on this was that we would start with just unset and (possibly) add a separate cleared value in future, if it seemed like it would be useful. However, with the changes proposed in #55 this will no longer be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant