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

Theme editor #5995

Merged
merged 9 commits into from
Mar 16, 2023
Merged

Theme editor #5995

merged 9 commits into from
Mar 16, 2023

Conversation

nickgrato
Copy link
Contributor

@nickgrato nickgrato commented Mar 13, 2023

Adding some updates to the color and json inputs. If the json input needs to scale anymore I would submit to the idea of breaking off into a new json theme input but I feel like for this low hanging fruit tickets this should suffice ( keeping in mind this page may be re-written in the near future as well).

  • Adding default theme JSON to theme editor
  • styling colors inputs
  • adding titles / copy

Base automatically changed from content-requests to master March 13, 2023 16:50
Copy link
Contributor

@johnshaughnessy johnshaughnessy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic inserted here is at the wrong layer. If you're trying to ship this today because you have bigger fish to fry, don't let me stop you. If you're not sure how to move it to a higher layer, then we should pair to do that so that you don't repeat this pattern for future changes you want to make to the admin panel.

src/schema.toml Show resolved Hide resolved
@@ -325,12 +388,14 @@ class ConfigurationEditor extends Component {
const displayPath = path.join(" > ");
return (
<div key={displayPath} className={this.props.classes.colorInput}>
{descriptor.name === "Background Color" && <h3 className="heading-sm mb-24">Nametags</h3>}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels wrong to insert logic like this here and in service-editor (for handling themes). It belongs at a higher level. It would not be difficult to move it up (to where we decide to render the themes section). It just means we won't blindly render the controls for that chunk of config variables.

That being said, I understand this was meant to be done as quickly as possible, and you're still getting familiar with the admin panel.

If this code still exists in 6 months, if there are additional incremental changes planned for the admin panel, or if what I'm saying isn't clear, then we should move this logic to a higher level. If what I'm describing is unclear, then I'm happy to chat through it.

margin="normal"
/>

{isTheme && (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking this still might be good here. I have ideas on how to make this more flexible in the future. but because the button ties in so much with the inputs hooks and current value it seems logical to keep in the component for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to lift the currentValue out from the TextField but in theory that's how I would want to handle this. Conceptually this part is meant to be a presentational component. When I added the json validation way back when, I didn't know how to do that logic at the higher level so I just stuffed it in here. If you figure out how to handle the logic in a container component, please lift both the code you added (the button and themes specific stuff) AND the JSON validation stuff I added a while back.

But I don't mind if you don't do that now.

}
}

renderThemeSection(theme, config) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnshaughnessy here is the new theme section.

@nickgrato nickgrato temporarily deployed to hc-bio March 15, 2023 03:02 — with GitHub Actions Inactive
Copy link
Contributor

@johnshaughnessy johnshaughnessy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's state in renderLongTextInput that should be pulled out.

Specifically, I think the renderThemeSection function could call renderLongTextInput directly (instead of renderConfigurable) and handle things like the default value and the reset to default theme button.

But, it's not a big deal and I don't want to force the issue.

<form onSubmit={this.onSubmit.bind(this)}>
<h3 className="heading-sm mb-24">Nametags</h3>
{getInput(configurables[0])}
{getInput(configurables[1])}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you know which configurables you need to render (theme.nametag-color and theme.nametag-text-color) -- it might be better to specify them by path rather than by index.

Something like

const configurable = (path) => {
  const descriptor = getDescriptors( path.split(".")[0] ).find( ([path, desc]) => desc.path === path )[1];
  return this.renderConfigurable(path, descriptor, getConfigValue(config, path));
}

// and in place of getInput, we would write:
configurable("theme.nametag-color")
configurable("theme.nametag-text-color")
...
configurable("theme.themes")

margin="normal"
/>

{isTheme && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to lift the currentValue out from the TextField but in theory that's how I would want to handle this. Conceptually this part is meant to be a presentational component. When I added the json validation way back when, I didn't know how to do that logic at the higher level so I just stuffed it in here. If you figure out how to handle the logic in a container component, please lift both the code you added (the button and themes specific stuff) AND the JSON validation stuff I added a while back.

But I don't mind if you don't do that now.

@nickgrato nickgrato merged commit 8b64fe4 into master Mar 16, 2023
@nickgrato nickgrato deleted the theme_editor branch March 16, 2023 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants