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

AppBar: Use appBarText for text/icon colors #12937

Conversation

nucleogenesis
Copy link
Member

Summary

  • NavBar & NavbarLink now take & drill a textColor prop
  • In AppBar, the new token appBarText is passed to textColor
  • In AppBar, it is also used as the default color for icons, the page title, and the user's info

This is done to permit plugins to customize the text in the AppBar so that they can ensure proper contrast with their chosen appBar token's value, which is used as the background.

References

Fixes learningequality/kolibri-instant-schools-plugin#205

Reviewer guidance

QA

Are there any regressions in the default Kolibri bevhaior for the top yellow AppBar? Check each plugin and any sub-routes you can.

The fixes that this allows will be tested upon rebuilding the VF IS plugin w/ this patched on Kolibri.

Code

  • Anything I'm missing where this should be used?
  • I have a patch ready for KDSv4 as well that isn't necessary for this to work but it would keep v4 updated w/ a default. I have included fallbacks for each place where appBarText is used so having them defined in KDS may not be necessary (cc @AlexVelezLl)
  • I have tested this by including the appBarText key in the tokenMapping section of the theme definition in the Instant Schools plugin and w/ that build, all of the colors are shown as expected. Should this be part of the theme itself - or does adding to that mapping jive w/ the way we want to use the theme machinery?

- NavBar & NavbarLink now take & drill a `textColor` prop
- In AppBar, the new token `appBarText` is passed to `textColor`
- In AppBar, it is also used as the default color for icons, the page title, and the user's info

This is done to permit plugins to customize the text in the AppBar so that they can ensure proper contrast with their chosen `appBar` token's value, which is used as the background.
nucleogenesis added a commit to nucleogenesis/kolibri-instant-schools-plugin that referenced this pull request Dec 11, 2024
@@ -10,9 +10,12 @@
<UiToolbar
:removeNavIcon="showAppNavView"
type="clear"
textColor="black"
:textColor="$themeTokens.appBarText || $themeTokens.text"
Copy link
Member Author

Choose a reason for hiding this comment

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

What the usage looks like in the plugin:

learningequality/kolibri-instant-schools-plugin@4f968b5

@nucleogenesis nucleogenesis force-pushed the themeTokens-appBarText-for-is branch from b1e5b68 to 4c0bee9 Compare December 12, 2024 21:13
Copy link
Member

@pcenov pcenov left a comment

Choose a reason for hiding this comment

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

Hi @nucleogenesis - for some reason the top navigation bar is not displayed at all:

2024-12-13_16-12-32.mp4

There are multiple TypeError: Cannot read properties of undefined (reading 'appBar') errors in the console:

2024-12-13_17-18-51

Copy link
Member

@rtibbles rtibbles 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 we can do some small clean up and avoid any || statements by just referencing theme config directly in components.

@@ -57,11 +57,15 @@
required: true,
validator: validateLinkObject,
},
textColor: {
Copy link
Member

Choose a reason for hiding this comment

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

Could we avoid prop drilling here, and just reference the value directly? NavbarLink is only used in the Navbar component, and we remove it from the public API completely in develop, so we can just set it directly to the value we want.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch - just updated this

@@ -81,6 +82,10 @@
return values.every(value => value.link.name);
},
},
textColor: {
Copy link
Member

Choose a reason for hiding this comment

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

Similarly here, Navbar is only used in AppBar, and is also removed from the public API in develop, so I think we can just reference theme variables directly.

@nucleogenesis
Copy link
Member Author

nucleogenesis commented Dec 13, 2024

@pcenov thank you and apologies for the oversight on my end here. I had my devserver running while working on it but didn't see the top bar disappear while making the updates 😅

I've pushed some updates, so should be ready for re-review.

@nucleogenesis nucleogenesis requested a review from pcenov December 13, 2024 19:30
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

Changes make sense to me, and look like a clean minimal diff. Will wait on manual QA for final approval!

Copy link
Member

@pcenov pcenov left a comment

Choose a reason for hiding this comment

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

Thanks @nucleogenesis - no regressions observed while manually testing!

Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

No concerns here.

spec: {
background: {
type: String,
default: themeTokens().appBar,
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to update it here - but if we are going to remove it from the themeTokens in KDS, might just want this to map to something more directly.

@@ -29,6 +29,7 @@

import { validateLinkObject } from 'kolibri.utils.validators';
import useKResponsiveWindow from 'kolibri-design-system/lib/composables/useKResponsiveWindow';
import themeConfig from 'kolibri.themeConfig';
Copy link
Member

Choose a reason for hiding this comment

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

Note to self - this import path will need to be updated when we merge up.

@github-actions github-actions bot added the DEV: backend Python, databases, networking, filesystem... label Dec 16, 2024
@rtibbles rtibbles merged commit 3b9dfdd into learningequality:release-v0.17.x Dec 16, 2024
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem... DEV: frontend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants