-
Notifications
You must be signed in to change notification settings - Fork 605
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
Fix react warning on visiting add page and align radio button sections in git import and deploy image forms with current UXD #3372
Fix react warning on visiting add page and align radio button sections in git import and deploy image forms with current UXD #3372
Conversation
/lgtm |
@divyanshiGupta The radio button is being used in the Deploy Image form as well. Don't you think the position of the input field looks a bit off? |
Yes, it was because |
/cc @openshift/team-devconsole-ux |
@divyanshiGupta: GitHub didn't allow me to request PR reviews from the following users: /cc. Note that only openshift members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/assign I'm sorry to have to do this to you @divyanshiGupta but I think we need to make a few changes here to clean this up more. It'll expand out a bit from what you have done. I'll compile the list and comment back when I have it. |
@andrewballantyne sure, no problem. I have tagged UX for the same reason so that it can be confirmed what all we need to add/change. |
Fixing the code issue is relatively simple... a rebranding of props and a more consolidated rendering will get us a cleaner implementation. Suggest making use of first-class naming in React and addressing the content as
I think we can clean up things and just render all the children (as-needed) after the radio button, indenting the children content all at once to align it with the radio buttons:
|
The style issues for the radio buttons is a bit annoying from what I can see. The radio circle itself is not centred despite Patternfly's attempt at doing so. This appears to be an issue with bootstrap styles conflicting with Patternfly styles. There is the following style at play:
Which misaligns the circle down a few pixels making the centring logic of Patternfly not work out. I recommend we just override it by adding a class to the RadioButtonField's FormGroup:
Which will allow Patternfly to centre based on their flex |
The badge is a problem on its own... it takes up more space than the label does. The easiest way I can think of solving this would be for us to just make it take up no space and "be centred". Now this can be done by the use of the css CSS would be something like:
|
/hold cancel If you have any questions, please let me know @divyanshiGupta - I've tossed a WIP onto your PR while you work out these changes. |
@andrewballantyne I added this comment to Karthik's PR some time back -
<RadioButtonField name="registry" label="Image Section">
<RadioButtonOption
label={imageRegistryType.External.label}
value={imageRegistryType.External.value}
helpertext="Some help text"
>
<ImageSearch />
</RadioButtonOption>
<RadioButtonOption
label={imageRegistryType.Internal.label}
value={imageRegistryType.Internal.value}
helpertext="Some help text"
>
<ImageStream projects={projects} imageStreams={imageStreams} />
</RadioButtonOption>
</RadioButtonField>
We had a bug for addressing some of the issues but later we decided we'll handle it as a tech debt. I see that we are already looking for some refactoring here so thought why not toss this idea in. I think if we simplify the APIs of |
Definitely an interesting prospect. We could go down this path. If we go more declarative, I'd prefer if we expanded the rendering to allow for a React Node or a function. That way the function can echo back if it's selected, and you can decide if you want to render it. Given your example, it could be something like this:
Would definitely be an interesting opportunity to address this. It would require a bigger interface modification than I had hoped for. Perhaps we push this to tech debt for the time being. |
@andrewballantyne @rohitkrai03 thanks for the suggestions. I was also thinking of refactoring this code but it seemed like a big refactor that is why I avoided doing it in this PR and wanted to keep this PR for only cosmetic changes. I can create a ticket for the refactoring work in Jira and raise a separate PR. |
@divyanshiGupta @andrewballantyne @serenamarie125 |
@sunilmalagi We are using pf radio button already. Will fix the issue by using a custom class to override the button margin. |
@sunilmalagi can you please specify which text? |
@divyanshiGupta |
Unfortunately, you do need to do this change: #3372 (comment) The radio buttons need to align themselves with the first line of text: This is happening because to solve the issue of alignment in the previous design, Giftson top-aligned the radio button... and made use of the bootstrap styles to push the radio button down - but this doesn't align with the other use of radio buttons. This isn't a standard way of us addressing radio buttons. Patternfly wants to vertically align it in the label, and our label right now can be a multi-line label:
This field cannot be used with the current styles. It'll never align. See the styles for the resources section for our override that will need to be removed.
|
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.
Here is my review on the code.
Please let me know if you have any questions or concerns.
<div className="odc-resource-section__badge-wrapper"> | ||
<span className="odc-resource-section__inline-badge"> |
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.
Perhaps make both of these spans, since the styles:
&__badge-wrapper {
display: inline;
Are just getting rid of the div
s block nature anyways. And div
s for the most part are nothing but block containers.
} | ||
.odc-resource-section { | ||
&__badge-wrapper { | ||
display: inline; |
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.
Per my other comment, perhaps remove this line.
.odc-radio-button input[type='radio'] { | ||
margin-top: 0; | ||
} | ||
|
||
.odc-radio-button__helper-text { | ||
padding: var(--pf-global--spacer--md) 0; | ||
line-height: 1em; | ||
} | ||
|
||
.odc-radio-button__displayed-field { | ||
padding: var(--pf-global--spacer--md) 0 var(--pf-global--spacer--md) 1.8rem; | ||
} |
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.
Please update this, making use of our SCSS style. See frontend/packages/dev-console/src/components/import/section/ResourceSection.scss
for an example of how to nest items.
If you're unfamiliar with the inner workings of SCSS and the parent selector, please see https://sass-lang.com/documentation/style-rules/parent-selector.
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.
Thanks for the reference. Was not sure if we can nest selectors as well.
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.
Ah yeah, I guess documentation only goes so far.
So the way SCSS nesting works is:
.my-class {
.my-inner-class { }
&.my-modifier { }
input[type=radio] { }
}
Gives us this CSS in the end (if there were properties inside them):
// top-level properties for the first dom element
.my-class {}
// two dom elements, one nested inside the other
.my-class .my-inner-class {}
// one dom element with a modifier class
.my-class.my-modifier {}
// two dom elements, inner one being an radio input
.my-class input[type=radio] {}
&
is merely append to the selector (aka don't use a space)
@sunilmalagi ^^ |
@andrewballantyne Are you suggesting to do the refactor work in this PR? |
I recommend doing my refactor or something similar... you need to get the label to be a single line item for Patternfly to do it's own thing. EDIT: @divyanshiGupta if you can fix this issue cleverly without breaking the other use-case of radio, that'll also be acceptable. |
@andrewballantyne I have addressed all the requested changes. Refactored the code and did a little bit of css tweaks to resolve the alignment issues. PTAL. @sunilmalagi ^^ |
@divyanshiGupta Looks Good.. thank you for doing it.. |
@@ -22,12 +22,12 @@ type ResourceSectionProps = { | |||
|
|||
const createHelpText = (k8sModel: K8sKind, helpText: string) => { | |||
return ( | |||
<> | |||
<div style={{ lineHeight: '1em' }}> |
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 easiest way to know when to use lineHeight
is (almost) never :)
What you have done here is take 2 paragraphs and try to condense them down to 1 font-size in line height. The browser is stopping you from doing this to the full extent :)
What was the goal here? Just to make them more condensed?
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, because in UXD it seems the spacing between them is less than what is shown here by default. So thought of reducing line height. You are right though, its more of a hack :P
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.
Recommend going with a more css approach, turning both <p>
into <div>
s and using a Patternfly spacer var(--pf-global--spacer--sm)
on the top one. Instead of a line-height
:)
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 :)
@@ -23,10 +23,10 @@ type ResourceSectionProps = { | |||
const createHelpText = (k8sModel: K8sKind, helpText: string) => { | |||
return ( | |||
<> | |||
<p> | |||
<div style={{ paddingBottom: 'var(--pf-global--spacer--xs)' }}> |
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.
lol - use your SCSS file. Inline should be avoided in all cases possible.
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 I can do that but here it doesn't seem necessary because it is only a single style, also this is only targeted at this and is not used anywhere else. Inline styles are being used in a lot of other places in console.
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 add inline css when no more than one style is required and it is not going to be used anywhere else. In this case having a inline css or a class seemed to have equal weight. Updated anyways.
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 don't agree; inline styles are a poor way to write maintainable code. If UX came back and asked us to add more styles (colour the resource name, for instance), you don't have a nice spot to put them, you have to refactor your styles into a css file and then add the new styles (or just clutter up the React code some more). Static styles (imo) have no purpose being written inline.
It's convenient to use the style
attribute, I understand that, but we are not writing code that we're going to toss out. We're writing code we'll have to maintain; best write it in such a fashion that we don't have to rewrite for small additions.
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.
/lgtm
/assign @christianvogt |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, christianvogt, divyanshiGupta, gijohn The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
2 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/test e2e-gcp-console |
Jira Issues - https://jira.coreos.com/browse/ODC-2174 & https://jira.coreos.com/browse/ODC-2172