Skip to content

Commit

Permalink
AppBar: Use appBarText for text/icon colors
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
nucleogenesis committed Dec 11, 2024
1 parent 44c8236 commit 4ae719c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
12 changes: 8 additions & 4 deletions kolibri/core/assets/src/views/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
<UiToolbar
:removeNavIcon="showAppNavView"
type="clear"
textColor="black"
:textColor="$themeTokens.appBarText || $themeTokens.text"
class="app-bar"
:style="{ height: topBarHeight + 'px' }"
:style="{
height: topBarHeight + 'px',
color: $themeTokens.appBarText || $themeTokens.text,
}"
:raised="false"
:removeBrandDivider="true"
>
Expand All @@ -26,7 +29,7 @@
>
<KIconButton
icon="menu"
:color="$themeTokens.text"
:color="$themeTokens.appBarText || $themeTokens.text"
:ariaLabel="$tr('openNav')"
@click="$emit('toggleSideNav')"
/>
Expand All @@ -49,6 +52,7 @@
<slot name="sub-nav">
<Navbar
v-if="links.length > 0"
:textColor="$themeTokens.appBarText || $themeTokens.text"
:navigationLinks="links"
/>
</slot>
Expand Down Expand Up @@ -94,7 +98,7 @@
<KIcon
icon="person"
:style="{
fill: $themeTokens.text,
fill: $themeTokens.appBarText || $themeTokens.text,
height: '24px',
width: '24px',
margin: '4px',
Expand Down
8 changes: 6 additions & 2 deletions kolibri/core/assets/src/views/Navbar/NavbarLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@
required: true,
validator: validateLinkObject,
},
textColor: {
type: String,
default: null,
},
},
computed: {
tabStyles() {
return {
color: this.$themeTokens.text,
color: this.textColor || this.$themeTokens.text,
':hover': {
'background-color': this.$themeBrand.secondary.v_600,
},
Expand All @@ -81,7 +85,7 @@
activeClasses() {
// return both fixed and dynamic classes
return `router-link-active ${this.$computedClass({
color: this.$themeTokens.text,
color: this.textColor || this.$themeTokens.text,
})}`;
},
},
Expand Down
9 changes: 7 additions & 2 deletions kolibri/core/assets/src/views/Navbar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
ref="navLinks"
:title="link.title"
:link="link.link"
:textColor="textColor || $themeTokens.text"
>
<KIcon
:icon="link.icon"
:color="$themeTokens.text"
:color="textColor || $themeTokens.text"
/>
</NavbarLink>
</ul>
Expand All @@ -27,7 +28,7 @@
:ariaLabel="coreString('moreOptions')"
icon="optionsHorizontal"
appearance="flat-button"
:color="$themeTokens.text"
:color="textColor || $themeTokens.text"
:primary="false"
class="kiconbutton-style"
>
Expand Down Expand Up @@ -81,6 +82,10 @@
return values.every(value => value.link.name);
},
},
textColor: {
type: String,
default: null,
},
},
data() {
return { mounted: false };
Expand Down

0 comments on commit 4ae719c

Please sign in to comment.