-
Notifications
You must be signed in to change notification settings - Fork 1k
add form context kind for survey #6529
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 form context kind for survey #6529
Conversation
@@ -334,7 +336,10 @@ const FormField = forwardRef( | |||
borderColor = (themeBorder && themeBorder.color) || 'border'; | |||
} | |||
|
|||
const labelStyle = { ...formFieldTheme.label }; | |||
let labelStyle; | |||
if (formKind === 'survey') { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/js/components/__tests__/__snapshots__/components-test.js.snap
Outdated
Show resolved
Hide resolved
"survey": { | ||
"label": { | ||
"margin": { | ||
"vertical": "xsmall", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
Between or -- are there any accessibility benefits to using 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. |
There was a problem hiding this 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') { |
There was a problem hiding this comment.
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
So also with 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 |
@@ -0,0 +1,45 @@ | |||
import React from 'react'; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
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
There was a problem hiding this 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" |
There was a problem hiding this comment.
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"
?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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}; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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: { |
There was a problem hiding this comment.
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
Co-authored-by: Eric Soderberg <eric.soderberg@hpe.com>
There was a problem hiding this 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) => { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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 || |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
There was a problem hiding this 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 |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Co-authored-by: Eric Soderberg <eric.soderberg@hpe.com>
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 propsThumbsRating: This is similar to the previous ThumbsRating in which it is made from
RadioButtonGroup
and can accept all propsNEW
kind
prop was introduced to Form in whichformfield
uses in order to style the label correctly. If a user passeskind='survey'
toform
thenformfield
label will usetheme.formfield.survey.label
The 2 main stories are
unsolicited
andsolicited
in Form folder on storybookWhere 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.userEvent
is used in place offireEvent
.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
dropButton
with floating propPros:
Box
withopen
andclose
behaviorCons:
dropAlign
dropContent
so would it make sense to also addlayerContent
orlayerPosition
DropButton
name is specific to DropAdd
layerButton
with floating propPros:
Box
withopen
andclose
behaviorCons:
DropButton
so not sure it's worth having another component that does the same behavior.button
?Add
floating
prop to ButtonPros:
Cons:
Here is the story with a floating
Button
andLayer
just to show to help us decide on what route to go.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