Skip to content
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

Refactor sidebar renders into methods (prep for mwc-list conversion) #7453

Merged
merged 2 commits into from
Oct 27, 2020

Conversation

donkawechico
Copy link
Contributor

@donkawechico donkawechico commented Oct 22, 2020

Proposed change

The sidebar render code is large and can be a bit difficult to reason about. This PR extracts the various "sections" of sidebar into their own render methods for better readability.

This is the first step toward converting sidebar to using mwc-list instead of paper-listbox. Related PR: #7326

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@donkawechico donkawechico marked this pull request as ready for review October 22, 2020 20:34
@bramkragten
Copy link
Member

You didn't change any actual logic here right?

@donkawechico
Copy link
Contributor Author

donkawechico commented Oct 23, 2020

You didn't change any actual logic here right?

95% true. I arguably "changed the logic" with how items in edit mode are rendered. That is, I converted this flattened, in-line pattern:

protected oneRenderToRuleThemAll() {
  return html`
    <div>Spacer</div>
    ${this.isEditMode ? "Render items in edit mode" : "Render items in normal mode"}
    <div>Another Spacer</div>
    ${this.isEditMode ? "Do some edit thing" : ""}
  `
}

And refactored into self-contained / parallel renderer structures:

protected renderItems() {
  return html`
    this.editMode ? this.renderEditModeItems() : this.renderNormalModeItems()
  `;
}

protected renderEditModeItems() {
  return html`
    <div>Spacer</div>
    Render items in edit mode
    <div>Another Spacer</div>
    Do some edit thing
  `;
}

protected renderNormalMode() {
  return html`
    <div>Spacer</div>
    Render items in normal mode
    <div>Another Spacer</div>
  `;
}

In other words, you should be able to ignore everything except _renderAllPanels().

@donkawechico donkawechico force-pushed the sidebar-refactor branch 2 times, most recently from 9eb5235 to 899d1ca Compare October 23, 2020 22:27
@donkawechico donkawechico added this to the 0.117.0 milestone Oct 27, 2020
@bramkragten bramkragten removed this from the 0.117.0 milestone Oct 27, 2020
@bramkragten bramkragten merged commit efe97e8 into dev Oct 27, 2020
@bramkragten bramkragten deleted the sidebar-refactor branch October 27, 2020 19:12
@bramkragten bramkragten mentioned this pull request Nov 11, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jul 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants