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

Enable User Brew theme selection #3321

Merged
merged 144 commits into from
Jul 30, 2024

Conversation

dbolack-ab
Copy link
Collaborator

@dbolack-ab dbolack-ab commented Feb 23, 2024

This adds the UI elements to the metadata selector for users to select brews tagged as theme or Theme as a brew's theme.

It also swaps in use of the CSS endpoints ( with small changes ) from #3303

Added Endpoints:

/theme/:renderer/:id/ - This endpoint provides a JSON object consisting of snippets (.snippets) and styles (.styles) from the referenced combination of renderer and id. Both members return an array of contents from the referenced theme and its entire parental tree from oldest to newest.

The '.styles' member is an array of strings. Each generation should lead with a comment naming the source followed by any style content.

The `.snippets` member is an array of snippets menu object(s). Empty generations will yield an empty array member.

Testing:

  • Loads a Legacy Brew correctly
  • Loads a Blank Themed Brew correctly
  • Loads a 5ePHB Themed Brew correctly
  • Loads a 5eDMG Themed Brew correctly
  • Shows Traditional and User Brews on the theme selector with a V3 brew.
  • Loads a brew using a User Brew Theme correctly
  • Hot loads changes between User Brew and Traditional themes in metadata editor
  • Hot loads changes between renderers (should be forced to Legacy 5ePHB theme if Legacy is chosen)
  • Gracefully fails when a User brew theme'd brew loads and its theme is no longer available - should show error in theme selector
  • Correctly shows inherited Traditional Theme snippets
  • Supports nested User Themes in combination with nested Traditional Themes (Ex: Current brew -> User Theme 1 -> User Theme 2 -> User Theme 3 -> 5eDMG -> 5ePHB -> Blank)
  • Loads themes saved on Google Drive
  • Displays current brew's style tags on top of any inherited themes.

This has been implemented three different ways to allow for comparison
and discussion

- /api/css/:id : This returns the style frontmatter of the referenced
  document as a text/css document.
/api/theme/:id : This returns an object with the reference'd object's
theme and style frontmatter.
/api/csstheme/:id : This returns the stylye frontmatter of the
referenced document as a text/css document and adds the theme as an
@import ( if not using the legacy renderer )
This adds a comment/field ( depending on endpoint ) that reports the
name of the Brew being used as a theming source.
This consolidates the style/theme endpoint to a singular method, adds
interpretation of static themes, and allow parent theme recursion.

I am not 100% sure this will order styles correctly.
This updates the theme picker to include brews tagged as themes owned by
the user.

Some supporting functions were updated. User themes are loaded on /edit
and added to the request.
@import statements are just not working. Uploaded for other eyes.
@dbolack-ab dbolack-ab marked this pull request as draft February 23, 2024 05:10
@dbolack-ab dbolack-ab marked this pull request as ready for review February 23, 2024 20:46
@dbolack-ab dbolack-ab marked this pull request as draft February 23, 2024 23:48
@dbolack-ab
Copy link
Collaborator Author

@calculuschild calculuschild temporarily deployed to homebrewery-pr-3321 July 27, 2024 07:31 Inactive
@calculuschild calculuschild temporarily deployed to homebrewery-pr-3321 July 27, 2024 23:17 Inactive
@dbolack-ab
Copy link
Collaborator Author

I'm guessing the original intention is to make it back to default as phb or blank...

No. This was my intent.
Falling back to a seemingly arbitrary theme is bad form.

So the brew failing into no theme is expected behaviour? Because that seems unnacceptable to me.

Let me get this straight.

You think it would be better to reassign the theme of a Brew to an arbitrary brew instead of removing theming and informing the user?

As a user I would find that infuriating.

@dbolack-ab
Copy link
Collaborator Author

dbolack-ab commented Jul 28, 2024

So the brew failing into no theme is expected behaviour? Because that seems unnacceptable to me.

I agree with you. It is bad design if an invalid or missing option just visually breaks the website. It should at least show some kind of default or fallback value.

No styling is a fallback value. It is the penultimate fallback.

@calculuschild
Copy link
Member

calculuschild commented Jul 28, 2024

You think it would be better to reassign the theme of a Brew to an arbitrary brew instead of removing theming and informing the user?

Not reassign their selection to an arbitrary theme. Just dont show a broken webpage if the one they pick doesn't exist. The app should have some robustness against errors like this.

Same reason we put the brewRenderer in an iFrame. If a user messes up their HTML, allowing the whole webpage to crash would be bad design.

No styling is a fallback value. It is the penultimate fallback.

If No Styling is the penultimate, then I'm curious what you would consider the ultimate fallback after that?

In any case, the Blank theme was kind of designed to be that minimum styling that is essentially "no style" while still appearing like a functioning page. I think it makes sense to display Blank if the currently-selected option doesn't exist.

No, I dont mean change the selection out from under the user. But don't just show a broken page either. That would drive people crazy, and give the impression our site has just broken.

@dbolack-ab
Copy link
Collaborator Author

You think it would be better to reassign the theme of a Brew to an arbitrary brew instead of removing theming and informing the user?

Not reassign their selection to an arbitrary theme. Just dont show a broken webpage if the one they pick doesn't exist. The app should have some robustness against errors like this.

Same reason we put the brewRenderer in an iFrame. If a user messes up their HTML, allowing the whole webpage to crash would be bad design.

Unless some of your rearrangement has broken existing behavior ( hadn't last I checked ) it does not break the site. I'm unsure where this assertion comes from.

If No Styling is the penultimate, then I'm curious what you would consider the ultimate fallback after that?

There is none. No styling drops you back at the default behavior for your browser

No, I dont mean change the selection out from under the user. But don't just show a broken page either. That would drive people crazy, and give the impression our site has just broken.

Again with this broken site thing.

@calculuschild
Copy link
Member

calculuschild commented Jul 28, 2024

The site isn't functionally broken, but visually broken, which is just as bad if a user can't tell the difference. With a full page of text, my first impression is that something crashed in the background, which is not the message we want to give. To me this is a bad user experience that we should avoid.

image

I think we are in agreement that it should fall back to looking "unstyled". But what "unstyled" looks like is the question under debate.

The "browser default" as you call the above is not actually the browser default. We have CSS on the site that basically strips all of the browser defaults out, unsetting every property, to make it easier to build custom stuff. So this is even more unstyled than what people are used to. Browser defaults would at least have white background with black text, some line spacing, functioning headers, bold and italics, etc.

The Blank theme is closer to Chrome defaults, which I do think conveys "unstyled", whereas the screenshot above conveys "broken" because it is missing most of the browser defaults people expect.

image

@calculuschild calculuschild temporarily deployed to homebrewery-pr-3321 July 28, 2024 20:45 Inactive
@calculuschild calculuschild temporarily deployed to homebrewery-pr-3321 July 28, 2024 20:47 Inactive
Now that we have a dedicated /theme/ route for the recursive theming, the CSS endpoint can be simpler for only getting the `style` of a single brew. naturalcrit#3075 already has this simpler version, but no testing, so I have copied this into a comment there for implementation when it is ready.
@calculuschild calculuschild temporarily deployed to homebrewery-pr-3321 July 28, 2024 21:53 Inactive
This PR adds tests which means we are now covering a larger % of the codebase. Raise the coverage thresholds to match.
@calculuschild calculuschild temporarily deployed to homebrewery-pr-3321 July 28, 2024 22:00 Inactive
@calculuschild calculuschild temporarily deployed to homebrewery-pr-3321 July 28, 2024 22:03 Inactive
@calculuschild calculuschild temporarily deployed to homebrewery-pr-3321 July 29, 2024 16:30 Inactive
@calculuschild
Copy link
Member

calculuschild commented Jul 29, 2024

Regarding the missing theme error, this seems like a good use of the error notifications we have-- pop an error that gives the id of the missing theme and any other info that would help resolve it.

Regarding what is displayed for the brew (or if the brew is shown at all), i'm not sure. Maybe just default to the Blank theme, which is more agnostic than defaulting to PHB, since there is a solid chance that if someone is extensively using themes they want to avoid looking like the PHB.

I have added a proper popup if a theme, or any theme in the inheritance chain, fails to load. In this case, the brewRenderer falls back to displaying the unstyled Blank theme (but does not change the user's selection in the menu).

image

@dbolack-ab
Copy link
Collaborator Author

Regarding the missing theme error, this seems like a good use of the error notifications we have-- pop an error that gives the id of the missing theme and any other info that would help resolve it.
Regarding what is displayed for the brew (or if the brew is shown at all), i'm not sure. Maybe just default to the Blank theme, which is more agnostic than defaulting to PHB, since there is a solid chance that if someone is extensively using themes they want to avoid looking like the PHB.

I have added a proper popup if a theme, or any theme in the inheritance chain, fails to load. In this case, the brewRenderer falls back to displaying the unstyled Blank theme (but does not change the user's selection in the menu).

image

This lines up with my expectations and desires though it looks like we have to take a slightly more convoluted route to get there than I had in my head.

@calculuschild calculuschild merged commit 607244d into naturalcrit:master Jul 30, 2024
2 checks passed
@5e-Cleric
Copy link
Member

After deployment of v3.14 bugs were reported, specially heroku error pages, due to timeout errors on load of undefined themes. Patch was rolled back. After fixing, was deployed again now, crashes seem to be avoided, but snippet bar seems to vanish for /new and homepage. Furthermore, custom theme brews appear to fail to show at theme dropdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Has been discussed and an approach is agreed upon 🔍 R2 - Reviewed - Needs Help 🫱 PR is okayed but is stuck on an obstacle sub-epic Sub-task of an Epic UI/UX User Interface, user experience
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Custom Brew Themes
7 participants