-
Notifications
You must be signed in to change notification settings - Fork 4
Fix #77: added Panel component #148
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 #77: added Panel component #148
Conversation
@@ -55,7 +55,7 @@ protected <C extends BaseComponent<E1, B1>, E1 extends HTMLElement, B1 extends T | |||
|
|||
protected <C extends BaseComponent<E1, B1>, E1 extends HTMLElement, B1 extends TypedBuilder<E1, B1>> C lookupComponent( | |||
boolean lenient) { | |||
return ComponentStore.lookup(componentType, element, false); | |||
return ComponentStore.lookup(componentType, element, lenient); |
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 noticed this one during random code reading - hope the fix as part of this commit is fine
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 fix!
I usually test new components using the showcase. I only write unit test for non-ui related code. If necessary I use mockito to mock UI code (see
|
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.
First of all thanks for your contribution! I left some comments on PR. Please feel free to ask further questions or raise concerns if you have a different opinion.
import static org.patternfly.core.Aria.labelledBy; | ||
import static org.patternfly.style.Classes.*; | ||
|
||
public class Panel extends BaseComponentFlat<HTMLDivElement, Panel> implements Attachable { |
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.
Could you please add a minimal Javadoc comment. I usually copy/paste from the PatternFly component page and add a link to the PatternFly component.
import static org.patternfly.core.Aria.labelledBy; | ||
import static org.patternfly.style.Classes.*; | ||
|
||
public class Panel extends BaseComponentFlat<HTMLDivElement, Panel> implements Attachable { |
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.
Could you please re-arrange the code sections, so that it matches the TemplateComponent
? Static factories should go first, then the instance methods, then add methods, then modifiers, and so on.
} | ||
|
||
public Panel add(PanelHeader header) { | ||
if (this.header != null) { |
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 not sure if we should throw an exception here. I prefer not adding a second header and log an error/warning. Something like Logger.unsupported(ComponentType, Element, String)
. Same for body and footer.
} | ||
|
||
@Override | ||
public void attach(MutationRecord mutationRecord) { |
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.
Attachable is not necessary here. Please remove implements Attachable
and remove this empty method.
} | ||
this.header = header; | ||
element().appendChild(header.element()); | ||
element().appendChild(hr().css(divider).element()); |
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 don't add a divider implicitly. Instead add a addDivider()
method like in https://github.com/patternfly-java/patternfly-java/blob/main/src/main/java/org/patternfly/component/menu/Menu.java#L147
return this; | ||
} | ||
|
||
public Panel addBody(String body) { |
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 addBody()
methods should be renamed to addMain()
. That aligns more to the PatternFly component IMO. And the PanelBody
sub component should be renamed to PanelMain
. But I like the usage of ElementDelegate<>
.
LGTM! Thanks for your contribution @halkosajtarevic Welcome to PatternFly Java π |
@hpehl is there any place where i could add tests? or how would i add them? didn't find any besides the showcase, and will add a PR there too, after this one