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

Consume more tokens from arches theme, add dark mode toggle #91

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

jacobtylerwalls
Copy link
Member

@jacobtylerwalls jacobtylerwalls commented Sep 10, 2024

Fix header skip closes #87
Add dark mode toggle closes #91

@@ -74,7 +74,7 @@ router.beforeEach(async (to, _from, next) => {

<style scoped>
main {
font-family: sans-serif;
font-family: system-ui, sans-serif;
Copy link
Member Author

@jacobtylerwalls jacobtylerwalls Sep 10, 2024

Choose a reason for hiding this comment

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

With this change, there's now a difference (on my local browser) between semibold and bold. (sans-serif in my browser was lacking a weight value for 600). Which means: we can preset the font weight for button labels to 600/semibold without it being too loud (it was looking the same as bold)

Then we'll have a default for button labels that looks good both in the controlled list manager (arches chrome) and here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Eh I'd say remove system-ui, as that varies from system to system and pulls us away from a unified experience. https://infinnie.github.io/blog/2017/systemui.html

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I saw that also, but I can't remember if I saw that before or after I made this addition, 😄 . I'll back it out. You have a good point we're building a unified experience, not a blog for a law office.

@@ -13,11 +15,15 @@ const { $gettext } = useGettext();
as="a"
:label="$gettext('Register')"
:href="arches.urls.signup"
:severity="SECONDARY"
Copy link
Member Author

Choose a reason for hiding this comment

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

Wanted to deemphasize these buttons.

<span v-if="user">{{ greeting }}</span>
<Button
style="margin-left: 1rem"
:label="$gettext('Sign out')"
Copy link
Member Author

@jacobtylerwalls jacobtylerwalls Sep 10, 2024

Choose a reason for hiding this comment

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

Without using the label prop, it wasn't using the tokens for button label font weight (not noticeable until I started overriding that weight via the theme)

@jacobtylerwalls jacobtylerwalls linked an issue Sep 10, 2024 that may be closed by this pull request
@jacobtylerwalls jacobtylerwalls changed the title Consume more tokens from arches theme Consume more tokens from arches theme, add dark mode toggle Sep 10, 2024
@chrabyrd
Copy link
Contributor

chrabyrd commented Oct 7, 2024

looks like some webpack failures in the CI?

@jacobtylerwalls
Copy link
Member Author

That's expected, since this depends on themes/default.ts in archesproject/arches#11319. I could update this branch to depend on it, but that seems like avoidable churn?

Copy link
Contributor

@chrabyrd chrabyrd left a comment

Choose a reason for hiding this comment

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

For whatever reason, the toggle doesn't work for me. Also would it go into this ticket or a followup to have the basic search component handle theming?

CHANGELOG.md Outdated Show resolved Hide resolved
arches_lingo/media/js/views/root.js Outdated Show resolved Hide resolved
arches_lingo/media/js/views/root.js Outdated Show resolved Hide resolved
@@ -74,7 +74,7 @@ router.beforeEach(async (to, _from, next) => {

<style scoped>
main {
font-family: sans-serif;
font-family: system-ui, sans-serif;
Copy link
Contributor

Choose a reason for hiding this comment

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

Eh I'd say remove system-ui, as that varies from system to system and pulls us away from a unified experience. https://infinnie.github.io/blog/2017/systemui.html

@jacobtylerwalls jacobtylerwalls linked an issue Nov 1, 2024 that may be closed by this pull request
@jacobtylerwalls
Copy link
Member Author

Also would it go into this ticket or a followup to have the basic search component handle theming?

Let's do a follow up, could be good to onboard another team member onto theming stuff?

@jacobtylerwalls
Copy link
Member Author

For whatever reason, the toggle doesn't work for me.

Yowza! I guess... do you have any manual overrides of the dev/8.0.x arches theme? I know on your system you did some deep dives into css reset for vue, so I'm wondering if you had any artifacts from that lying around, like css layers or something.

@chrabyrd
Copy link
Contributor

chrabyrd commented Nov 1, 2024

boo failing builds

@chrabyrd
Copy link
Contributor

chrabyrd commented Nov 1, 2024

For whatever reason, the toggle doesn't work for me.

Yowza! I guess... do you have any manual overrides of the dev/8.0.x arches theme? I know on your system you did some deep dives into css reset for vue, so I'm wondering if you had any artifacts from that lying around, like css layers or something.

oh huh. after you pulled main into the branch things are working now 🎉

Copy link
Contributor

@chrabyrd chrabyrd left a comment

Choose a reason for hiding this comment

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

Looks good! Some minor nits will probably fall out once this is moved out of lingo, but I'm not worrying about those now.

There's some additional complexity that's fallen out of this review, but happy to chat or kick parts of it to a follow-up 👍

Copy link
Contributor

@chrabyrd chrabyrd Nov 1, 2024

Choose a reason for hiding this comment

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

isDarkModeEnabled works! (🎉 ). However, regardless of if its value, the theme when the page is loaded is always light. I was able to solve this locally via

onMounted(() => {
    if (isDarkModeEnabled.value) {
        toggleDarkMode();
    }
});

However, this may not be the right solution. There's further complexity to add that may nullify that pattern. Namely, I can set the toggle to dark, see the change, refresh the page, and it's automatically set back to light. My guess is that either cookies or localstorage need to be leveraged to persist this through page refreshes.

If we wanted to get really fancy we could add a column to the User model to support preferred theme, but that's probably overkill at this point. And we'd still need something on the browser to persist for anonymous user so /shrug that's not an entirely baked idea.

If this component is changed to read from cookies/localstorage on mount, it'd be more readable to change the toggle method to accept an arg so it can be explicitly set the mode. This will also support adding other themes later. However I'm not married to this pattern, YAGNI and whatnot /shrug. Regardless, reading from cookies/localstorage nullifies the simple code laid out above.

But this reveals another titchy thing: we're handling all of theming in this component. If I have a cookie ( or bit of localstorage ) saved that says I prefer dark mode, I'd expect the application to handle this regardless of the presence or absence of the header / DarkModeToggle. Like in reports and whatnot. It could be argued that the ability to switch themes should be handled in this component of course, but the ability to query a preferred theme and apply it should be handled at a deeper level.

Perhaps even in core since it's touching the <html> element, but I don't feel strongly about that yet.

@jacobtylerwalls
Copy link
Member Author

boo failing builds

I'll update the github action. Maybe we need the updateproject command to yell about this again when the github templates change?

@jacobtylerwalls
Copy link
Member Author

The actions are dense; better to just call out the tiny change in the upgrade instructions.

@chrabyrd
Copy link
Contributor

chrabyrd commented Nov 1, 2024

The actions are dense; better to just call out the tiny change in the upgrade instructions.

IMO it should be automated, part of the updateproject command. The odds that people have changed their project's specific actions are low, but we should definitely call out a warning as part of the initial update project warning. Happy to crank this out in core. WDYT?

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.

Add dark mode toggle Arches Lingo header is <h2>
2 participants