Skip to content

Conversation

britt6612
Copy link
Collaborator

@britt6612 britt6612 commented Dec 6, 2022

What does this PR do?

This PR is a second approach at a Feedback component

This PR includes:
StarRating: This is similar to the previous StarRating in which it is made from RadioButtonGroup and can accept all props
ThumbsRating: This is similar to the previous ThumbsRating in which it is made from RadioButtonGroup and can accept all props

NEW
kind prop was introduced to Form in which formfield uses in order to style the label correctly. If a user passes kind='survey' to form then formfield label will use theme.formfield.survey.label

The 2 main stories are unsolicited and solicited in Form folder on storybook

Where should the reviewer start?

What testing has been done on this PR?

local

How should this be manually tested?

local

Do Jest tests follow these best practices?

TODO:

  • 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?

From a discussion with the Grommet maintainers we decided to go with the following in order to simplify the process and make things for flexible in Grommet:

  • add kind to Form
  • if FormField is in a Form with certain kind use that kind styling for the FormField
  • Add theme.formField.feedback to define styling for that kind in the theme (similar to button kinds)

Add dropButton with floating prop

Pros:

  • A user would not have to style a grommet Button inorder for it to be "floating"
  • Out of the Box with open and close behavior
  • Less code on the users side as well as less state being updated on their end

Cons:

  • DropButton is pretty specific in its props with being used with Drop.
  • per backward compatibility we would need to keep dropAlign dropContent so would it make sense to also add layerContent or layerPosition
  • The component it self DropButton name is specific to Drop

Add layerButton with floating prop

Pros:

  • A user would not have to style a grommet Button inorder for it to be "floating"
  • Out of the Box with open and close behavior
  • Less code on the user's side as well as less state being updated on their end

Cons:

  • Essentially the code would be very similar to DropButton so not sure it's worth having another component that does the same behavior.
  • Behavior of the button if the Layer is not interactive is that to opinionated from the Grommet side in how we handle that would be disable the button?

Add floating prop to Button

Pros:

  • A user would not have to style a grommet Button inorder for it to be "floating"

Cons:

  • the risk of it having it obscure content (which we have been wanting to avoid).
  • maybe there isn't a lot of cases to have a floating button. (not sure if this is a con though)

Here is the story with a floating Button and Layer just to show to help us decide on what route to go.

  • Explore LayerButton with floating prop or DropButton with floating prop

What are the relevant issues?

closes grommet/hpe-design-system#3037

Screenshots (if appropriate)

no

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

@britt6612 britt6612 requested a review from jcfilben December 6, 2022 20:33
@britt6612 britt6612 requested a review from taysea December 6, 2022 22:03
@@ -334,7 +336,10 @@ const FormField = forwardRef(
borderColor = (themeBorder && themeBorder.color) || 'border';
}

const labelStyle = { ...formFieldTheme.label };
let labelStyle;
if (formKind === 'survey') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want kind === 'survey' to be hardcoded or do we want something a bit more loose like how button kind works?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

aw okay so if (kind) then do styles rather then === survey

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it might be nice to have a little more flexibility here like how button handles kinds. This would allow people to have 'marketing' forms or other styling variations we haven't thought about

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes changed this to be whatever kindArg they pass

scale = 5,
value,
onChange,
outlineColor,
Copy link
Collaborator

Choose a reason for hiding this comment

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

instead of having fillColor and outlineColor, it'd be nice to just have a single color prop. Where color could be:

  • a string (applies to both fill and outline)
  • object: { fill: string, outline: string }

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good idea

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ill also do the same for thumbs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

"survey": {
"label": {
"margin": {
"vertical": "xsmall",
Copy link
Collaborator

Choose a reason for hiding this comment

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

The spacing between question and input and also between formfields looks off -- would be good to double check the desired value.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same comment as above not sure we want these in our base theme or were just going to comment these out and put in hpe theme

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should include "survey" in the base grommet theme. It's a reasonable concept that I think would be good to provide.

Copy link
Collaborator

@taysea taysea left a comment

Choose a reason for hiding this comment

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

Nice progress, I'm liking the kind approach on Form and then just using FormField inside.

@taysea
Copy link
Collaborator

taysea commented Dec 6, 2022

Between or -- are there any accessibility benefits to using Layer for the feedback vs Drop? I noticed in the DS site we use Layer but we do modal={false}. I don't know the intricacies of accessibility concerns off the top of my head, but if we can implement it the same with Drop then I might be included to use DropButton?

OR

<Button floating onClick={() => setOpen} /> and then just let the user handle their layer as they usually would.

I'm leaning away from Layer button at the moment, pending the accessibility questions I had above.

Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

I like the idea of adding the floating prop to Button. It feels like the other options have more downsides associated with them and may not be routes we want to go. Adding floating to Button seems like a reasonable solution that doesn't add to much extra code or unnecessary work

@@ -334,7 +336,10 @@ const FormField = forwardRef(
borderColor = (themeBorder && themeBorder.color) || 'border';
}

const labelStyle = { ...formFieldTheme.label };
let labelStyle;
if (formKind === 'survey') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it might be nice to have a little more flexibility here like how button handles kinds. This would allow people to have 'marketing' forms or other styling variations we haven't thought about

@britt6612
Copy link
Collaborator Author

britt6612 commented Dec 7, 2022

Between or -- are there any accessibility benefits to using Layer for the feedback vs Drop? I noticed in the DS site we use Layer but we do modal={false}. I don't know the intricacies of accessibility concerns off the top of my head, but if we can implement it the same with Drop then I might be included to use DropButton?

OR

<Button floating onClick={() => setOpen} /> and then just let the user handle their layer as they usually would.

I'm leaning away from Layer button at the moment, pending the accessibility questions I had above.

So also with Layer there is an animation that is nice when it opens and closes. Sort of like a slide in which Drop does not have animation Im sure we could add this though as an enhancement.

As far as accessibility Drop does do a better job with having the focus around the whole Drop content then you can down arrow to see what is in the content. Where as Layer we have to add the autoFocus to the X element which is in our DS guidance. However we do not have Drop in our DS system so I wasn't sure how that would look by adding a new component or introducing it and if users would then question layer vs drop

@britt6612 britt6612 requested a review from jcfilben December 8, 2022 17:37
@britt6612 britt6612 requested a review from taysea December 8, 2022 18:37
Brittany Archibeque added 2 commits December 9, 2022 11:54
@@ -0,0 +1,45 @@
import React from 'react';
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 make this a typescript file? Trying to make sure any new test files that are added are typescript

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this got switched back to a .js file

Copy link
Contributor

@ericsoderberghp ericsoderberghp left a comment

Choose a reason for hiding this comment

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

Looking good! Just a few more comments.

>
<Form
onSubmit={({ value }) => console.log('Submit', value)}
method="post"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need method="post"?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no

</Heading>
</Header>
<Box
// Padding used to prevent focus from being cutoff
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems a bit odd to me. What is cutting the focus off?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

taken out

const PositionedFeedbackBox = styled(Box)`
bottom: 0px;
right: 0px;
position: ${(props) => props.theme.feedback?.buttonContainer?.position};
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does the story need to reach into the theme like this? I would have either expected that to be built in somehow or that those things shouldn't be in the theme at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@@ -937,6 +937,13 @@ export const generate = (baseSpacing = 24, scale = 6) => {
},
margin: { bottom: 'small' },
// round: undefined,
survey: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm OK with the naming being broader than "feedback" on the grommet side. I think it aligns better with what it is for generally.

@@ -1501,6 +1508,18 @@ export const generate = (baseSpacing = 24, scale = 6) => {
xlarge: { ...fontSizing(2) },
xxlarge: { ...fontSizing(4) },
},
thumbsRating: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm inclined to not have these colors here as part of the base theme.

@@ -1663,6 +1682,11 @@ export const generate = (baseSpacing = 24, scale = 6) => {
size: 'medium',
},
},
starRating: {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm inclined to not have this color here as part of the base theme

britt6612 and others added 2 commits December 14, 2022 20:59
Co-authored-by: Eric Soderberg <eric.soderberg@hpe.com>
Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

Just a few more comments, I think it is really close

method="post"
validate="submit"
kind="survey"
onSubmit={(value) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

After clicking Submit I am forced to wait until the Layer closes itself. I feel like you should still be able to close the Layer by hitting 'esc' or something so you are not forced to wait

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 can add esc thats just the pattern I was following from the DS example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added onClickOutside={onClose}

@@ -0,0 +1,45 @@
import React from 'react';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this got switched back to a .js file

return checked ? (
<DislikeFill
color={
theme.thumbsRating?.dislike?.icon?.color ||
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm fine with the naming that is already here. Maybe we could shorten it to thumbsRating.dislike.color because there is nothing else I would expect to be able to change the color on here besides the icon, so icon is already implied. Soft opinion though, flexible either way.

Copy link
Collaborator

@jcfilben jcfilben left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Contributor

@ericsoderberghp ericsoderberghp left a comment

Choose a reason for hiding this comment

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

Just a few.

<FormField label="Comments" htmlFor="comments" name="comments">
<TextArea id="comments" name="comments" />
</FormField>
<Box
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use <Footer /> instead of <Box /> here? It feels more semantic.

{(option) =>
option <= value ? (
<Star
color={theme.starRating?.color || theme.starRating?.color?.fill}
Copy link
Contributor

Choose a reason for hiding this comment

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

This use of theme.starRating.color.fill doesn't align with the typescript definition, where ColorType is just a string or an object with dark/light keys. Can we simplify this to just theme.starRating.color?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

aw yes I see your point wondering if I should make theme.starRating.color.fill its own type so we can have theme.starRating.color where someone can pass dark/light keys and also have the theme.starRating.color.fill and theme.starRating.color.outline if they want different colors depending on which icon is selected or you saying for now just allow one color for the icons regardless of fill out outline?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the theme should just be asking for a color and we should use it appropriately within the StarRating to apply the color where people would typically expect it, as outline for unselected, as fill for selected.

@ericsoderberghp ericsoderberghp merged commit ffedc39 into grommet:master Dec 20, 2022
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.

Feedback Grommet Component
4 participants