简体   繁体   中英

Vaadin: How To Customize The Valo Theme

I'm new to SCSS and I'm asking myself how to customize the Valo Theme in a Vaadin application. I read the topic in the Book of Vaadin but I just cannot find an example for it. My style structure is based on the official Vaadin dashboard demo :

@import "../valo/valo";
@import "common";
@import "views/login";
@import "views/dashboardview";
@import "views/schedule";
@import "views/sales";
@import "views/transactions";
@import "views/reports";

// Optimize the CSS output
$v-included-components: remove($v-included-components, accordion);
$v-included-components: remove($v-included-components, colorpicker);
$v-included-components: remove($v-included-components, grid);
$v-included-components: remove($v-included-components, popupview);
$v-included-components: remove($v-included-components, progressbar);
$v-included-components: remove($v-included-components, slider);
$v-included-components: remove($v-included-components, splitpanel);
$v-included-components: remove($v-included-components, tree);
$v-included-components: remove($v-included-components, treetable);
$v-included-components: remove($v-included-components, twincolselect);

// Main layout padding
$view-padding: round($v-unit-size / 1.5) !default;

// Slight adjustment to menu background-color
$valo-menu-background-color: #414B56;

@mixin dashboard {
  @include valo;
  @include dashboard-common;
  @include dashboard-login-view;
  @include dashboard-dashboard-view;
  @include dashboard-schedule-view;
  @include dashboard-sales-view;
  @include dashboard-transactions-view;
  @include dashboard-reports-view;
}

After compiling the SCSS I've got the styles.css file where I just customized a few entries for the Valo Menu. Example:

Original:

.mytheme .v-menubar-user-menu  > .v-menubar-menuitem img.v-icon {
    width: 56px;
    height: 56px;

    border-radius: 29px;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05);
    display: block;
    margin: 0 auto 0.3em;
    border: 1px solid #c5c5c5;
}

Customized:

.mytheme .v-menubar-user-menu  > .v-menubar-menuitem img.v-icon {
    width: 69px;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05);
    display: block;
    margin: 0 auto 0.3em;
    border: 1px solid #c5c5c5;
}

Now how (and where) can I define these rules, so the SCSS compiler takes the changes automatically? Otherwise everytime I compile the Theme my changes are lost.

Regards

As described in the Book of Vaadin you add your own code at the end of your mixin .

The actual theme should be defined as follows, as a mixin that includes the base theme.

 @import "../valo/valo.scss"; @mixin mytheme { @include valo; /* An actual theme rule */ .v-button { color: blue; } } 

In your case something along the lines:

@mixin dashboard {
  // ...
  .v-menubar-user-menu  > .v-menubar-menuitem img.v-icon {
     width: 69px;
     height: auto;
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM