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

Tag size #5914

Merged
merged 4 commits into from
Jan 28, 2022
Merged

Tag size #5914

merged 4 commits into from
Jan 28, 2022

Conversation

MikeKingdom
Copy link
Collaborator

What does this PR do?

Add a size property to Tag

Where should the reviewer start?

Tag.js

What testing has been done on this PR?

Storybook example and jest testcase

How should this be manually tested?

Storybook Type/Tag/Size example

Do Jest tests follow these best practices?

  • screen is used for querying.
  • The correct query is used. (Refer to this list of queries)
  • userEvent is used in place of fireEvent.
  • asFragment() is used for snapshot testing.

Any background context you want to provide?

Greenlake Marketplace designs want a smaller tag so they don't overwhelm and distract from the content on their product cards.

What are the relevant issues?

Screenshots (if appropriate)

image

Do the grommet docs need to be updated?

Yes

Should this PR be mentioned in the release notes?

Yes

Is this change backwards compatible or is it a breaking change?

Backwards compatible

src/js/components/Tag/Tag.js Show resolved Hide resolved
src/js/components/Tag/Tag.js Show resolved Hide resolved
src/js/components/Tag/__tests__/Tag-test.tsx Show resolved Hide resolved
src/js/components/Tag/Tag.js Show resolved Hide resolved
@@ -1489,6 +1489,23 @@ export const generate = (baseSpacing = 24, scale = 6) => {
margin: { right: 'xsmall' },
},
separator: ' : ',
size: {
xsmall: {
pad: { horizontal: 'small' },
Copy link
Member

Choose a reason for hiding this comment

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

Does this padding align with Button for its sizes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Tag has less horizontal padding (that's how it was spec'd in the figma). Button also calculates it as something like ${baseSpacing / 4 - borderWidth} etc rather than using tshirt sizes which we could do if needed, especially once the Figma details are decided.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried to align them to be more consistent. They are a little different than button but that seems reasonable since they better fit the original Tag "medium" design.

<Text size={size} weight="bold">{size}</Text>
<Tag name="Name" value="Value" size={size}/>
<Tag value="Value" size={size}/>
<Tag value="Value" size={size} onRemove={()=>{}}/>
Copy link
Collaborator

Choose a reason for hiding this comment

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

onRemove for size "xsmall" seems bad for accessibility. The clickable target is only 12x12px. Wondering if we shouldn't support onRemove for this size OR at least advise away from it for Design System related patterns.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agree. I don't think xsmall makes sense to have in a case where you want onRemove. I bigger target may make xsmall not really any smaller than small if it does have onRemove. Either way these values were a guess just to get some discussion started :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed the remove button for xsmall to be like the small one. It seems to fit fine and looks decent.

Copy link
Collaborator

Choose a reason for hiding this comment

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

the xsmall remove looks better

"size": "small",
},
"pad": Object {
"horizontal": "small",
Copy link
Collaborator

Choose a reason for hiding this comment

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

This horizontal pad looks disproportionally large than the horizontal pad on other sizes -- is that intentional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It does look a little big but xsmall is too small so it probably needs to be a pixel value (which I think we'd do anyway to be more like how button's padding is done.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I re-did the padding on all but medium so they align better with medium (which was the one originally in Figma.)

@@ -11,23 +11,27 @@ import { Text } from '../Text';

import { StyledRemoveButton, StyledTagButton } from './StyledTag';

const Tag = forwardRef(({ name, value, onRemove, onClick, ...rest }, ref) => {
const Tag = forwardRef(
({ name, value, size, onRemove, onClick, ...rest }, ref) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add size to the grommet docs

@ericsoderberghp ericsoderberghp merged commit 2ab6f2f into master Jan 28, 2022
@ericsoderberghp ericsoderberghp deleted the tag-size branch January 28, 2022 16:46
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

Successfully merging this pull request may close these issues.

None yet

4 participants