Use multiple themes in spring boot vaadin application - css

By default we can apply styling to vaadin spring boot applications by annotating UI class with#Theme(themename). In my particular situation i annotated with #Theme(ValoTheme.THEME_NAME) ,but it's not over. Unfortunately, i didn't figured out how to set background for layout without dealing with css and extra files(And it seems the only solution unavoidable).
How to use both themes valotheme and custom (just for setting up background image) at the same time?
Many thanks for suggestions

You can extend a Vaadin theme in your own custom theme. If you extend the Valo theme in your theme, then you get Valo theme plus your own customization and additions:
#import "../valo/valo.scss";
#mixin mytheme {
#include valo;
// your own scss here
}

After enumorous attempts to get it done, i was forced to switch over css styling files. With that being said - i had to combine ValoTheme and my own "style".
For Spring Boot Devs: Initially Spring Boot won't generate any presets for custom styles (vaadin plugin for Eclipse and Netbeans does it), so you have to create folders manually:
src/main/webapp/VAADIN/themes/<yourthemename>/ and place necessary css files there.
Quicktip:
Time-less consuming way:
Make new vaadin project from here: Link
Locate theme folder and copy-paste to your project
Also do not forget to annotate UI with #Theme("myTheme")
Hope this helps someone

Related

Angular global class how to implement it?

I am very new to Angular and currently I am trying to add styling to an existing project.
The project has been constructed using components. So for each page there are 4 files,
mypage.component.css
mypage.component.html
mypage.component.spec.ts
mypage.component.ts
I can easily style the page by adding the styles to the css file in the component and the page style works perfectly.
However the issue is there are many pages that require the same styles again and again.
I can copy and paste the same styles to each css file and it works.
But this is not the most elegant or efficient way to do this.
I want to know what the correct way to add a global.css file so that it can be accessed by each page. So that way the css is only written once.
I have googled but haven't found anything that explains how to do it in simple ways.
Thanks
Angular adds the style.css/scss file by default to your project once you created it using the ng new command, and include it within the angular.json config file to be available across the components of the project.
So you can add any global styles within src/styles.css(or scss) file, to be implemented everywhere.
you can add your generic css into style.css/style.scss.

Possible to use custom css when using a Nativescript core theme?

i'm busy with a Nativescript app, i'm using the core dark theme but would like to add some font-awesome glyphicons and custom css. I import the core dark theme in my global app.css but don't seem to be able to do anything more in that file after importing the theme... I've tried to add page-specific css by adding a component-common.css to a specific page but when I add the styleUrls: [...] declaration to the component declaration I always get a runtime error... Is it possible at all to use custom css ontop of the core Nativescript theme? If so how would I go about it (using css files not inline in the xml)?
Yes, it is possible to use both a theme and custom CSS files.
For example, check this sample where in the same time theme has been applied to the top CSS file.
Better check (and/or post) your runtime error - it might show you the reason why the app is throwing. Perhaps due to non-existing paths for your styleeUrls !?

How to provide Vaadin addon #StyleSheets for different themes

I created a widget, lets call it Vaadin addon, and included a css-file using the stylesheet annnotation: #StyleSheet({ "custom.css" })
Now I'm wondering how to handle the usage within different themes. My first idea was, to write the css like this:
.valo .mybutton { background: red;}
.reindeer .mybutton {background: yellow;}
The problem is, if my application theme extends the reindeer theme, the html will not contain any reindeer class name, same with valo. I didn't found documentation on this topic.. (what I read is this post)
Is this the right approach though? You have to define look of your component for each theme available on your own and decide what is the best visual representation of your component in that given theme. If that theme changes, you have to change your add-on too. If there is new theme, you will have to update your component too.
More suitable approach might be just to use standard vaadin css classes, thus letting theme decide how your component will look. You just define structure of your component and logical parts from which it consists using standard vaadin classes. This way, your component will fit perfectly no matter what theme is used, also it is prepared for any number of new custom themes to be published. I do not say you should not include styles to your add-on, i just say you should consider not tying your add-on to any concerte themes.

Integrate startbootstrap-sb-admin-2 UI to Yii2 application

I found this Bootstrap UI from http://startbootstrap.com/template-overviews/sb-admin-2/ and I would like that my Yii2 application would look like it.
How do I integrate that sb-admin-2 UI to my Yii2 application? I already have a UI and I have tinkered the html and css of my app but I still find it dry and boring. That's why I want to use the sb-admin-2 UI from Start Bootstrap but I have no idea how to start.
I have read the instructions at their GitHub page but I still have a hard time understanding it.
Your help would be of great help. Please let me know your thoughts.
I think that perhaps you are mis-understanding what a bootstrap theme is. It is simply a collection of css rules that you can apply to your content to make them look cool. You have to generate the content yourself. A bootstrap theme is not a module, or widget, or anything else like that.
To use it you just need to make sure to include the stylesheet, then apply the classes you want to the elements you have in your admin views. Have a look at the demo; it shows you all the different styles you can apply from the theme.
Yii have a guide to including css and js assets.
You can try Yii2 SB Admin 2
Installation
composer require nullref/yii2-sb-admin-2 "*"
For integration new Theme in Yii2 you must do:
create asset bundles for each functionality (forms, tables, wizards)
create extended widgets for theme
extend ActiveFileds - very complicated!!!
create layouts
All this pieces, theme (css, js, imiges ) include in new module like Theme[Name]
Also very nice, if implement theme in Gii templates.

CSS in vaadin plugin for grails

I am using the vaadin plugin for grails, and am trying to define some custom styles. Where within my grails appliction should I put the .css? My Vaadin application is in /vaadin/ I have tried creating a /vaadin/themes/mytheme/ folder and then putting my styles.css file in there, but still had no luck. Any help would be greatly appreciated. New to grails and new to vaadin, and am pulling my hair out over small stuff like this and can't get any of the actual legwork done until I can figure these things out..
Any way of doing inline styling would be fine with me too, at this point. I really just need some way to write explicit style..
Thanks
You need to put it into /web-app/VAADIN/themes/mytheme
You can have a look at the completed addressbook tutorial (with added Gorm and Spring Security Core support)
With the latest version of the plugin:
The name of the file must be styles.css (or styles.scss, which will then be compiled to styles.css by the command grails prod war)
The file must be located in /web-app/VAADIN/themes/mytheme , where the last part is the name of your style
In your UI file, use the #Theme annotation, for example
#Theme("mytheme")
#VaadinUI(path = '/')
class MyUI extends UI {
// ...
In VaadinConfig.groovy, specify the styles used by the application:
themes = ['mytheme']

Resources