Fix #77: added Panel component - #148
Conversation
| 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.
i noticed this one during random code reading - hope the fix as part of this commit is fine
|
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 ) |
hpehl
left a comment
There was a problem hiding this comment.
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.
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.
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.
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.
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.
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.
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