How do I reference the brand color in inline (app specific) css on the index.html - sap-fiori

I have a habit of putting custom css that is app specific in the inline head <style> tags of index.html. This way I can adapt SAP defined classes differently across apps.
Is there a way to reference the brand color (and any other defined color) from the UI Theme that is used from within the inline CSS?

Have you tried the css class "sapBrandColor" or "sapUshellShellBrand"? However, according to the docs you should use "sapThemeBrand-asColor".
Here is the right documentation:
CSS Classes for Theme Parameters
List of Supported CSS Classes

Related

run time styles in angular material design

When I changed the css style in the internal css component using angular2 material design, all components changed to the same style.
Ex:
When I used this line in internal css component, all components implemented the same style.
::ng-deep .ng-star-inserted > td:nth-child(1) { color:#3f51b5 }
How I can fix this problem ?
Thanks
what do you mean with 'internal css component'? You mean the css file of a particular component or the styles.css file that applies to all components? If you want the css rule to apply to only one component then you should put it in the css file that comes with that component, not in styles.css. To prevent your problem from happening please do the following:
In the css file of the particular component add !important after the color css style rule and remove ::ng-deep.
.ng-star-inserted > td:nth-child(1) { color:#3f51b5 !important}

styling "pseudo-element" using Dart lang

I'm building a ctusom element with DART, and styling it without using seperate css file, using the ..style as below:
innerInput = new InputElement()
..style.color= '#FF8F66'
..style.fontFamily='openSansItalic';
I want to use "pseudo-element" styling, like styling the 'placeholder', 'before', 'after' ,... is there a way to do it using dart, or I've to use separate css file, thanks
Seems these can only be read using code innerInput.getComputedStyle(':after').content but not changed but you can create stylesheet rules by code (like the one built from CSS) How to create CSS keyframe rule in Dart

Dynamic SASS generation

I am working on a multi tenant app where I'd like each Tenant to control the colors of specific elements. For example, I'd imaging have a form w/ color pickers where users could control items such as site background color, navbar colors, etc.
I have a baseline SASS(.scss) file which sets the default color scheme. My questions are:
How would I then load the "dynamic" theme .scss file?
If I had model fields like Tenant.nav_bar_link_color, how would I load those values into the SASS theme file?
Would I be able to/should I somehow precompile the Tenant specific themes into the asset pipeline?
You could add a class to the body element of the main application. This could be like
<body class="">
Then programmatically add a class such as "scheme-red" or "scheme-blue" to this body element based on their selection of a theme.
In your SASS you would then have different color schemes that override the defaults.
After some research, I think the method outline here makes most sense:
User generated custom css
Basically i'll store the Tenant controlled CSS values in the DB, and then render them out in the head as overrides against my default SASS file....

How do I use CSS to style my form components?

How does Vaadin use CSS that was written purely for HTML elements (e.g. styling and layout of body, h1, etc elements) and use that exact CSS style in Vaadin?
Does one need to make changes on the CSS to map to corresponding Vaadin elements, or can one use that CSS as is?
You can use the CSS as is, but you'll (naturally) have to tell Vaadin which CSS classes to use by calling
myComponent.setStyleName("myStyleClass");
or
myComponent.addStyleName("myStyleClass");
The difference between the two is that setStyleName replaces all existing styles with the provided one and addStyleName doesn't replace anything but adds the provided style for the component.
You can also modify your CSS to override default Vaadin styles, for example
.v-panel .v-panel-content {
background: yellow;
}
would change every Panel's background color to yellow.
I recommend that you create a new theme which is based on an existing Vaadin theme. Here's how to:
Create a directory in the VAADIN/themes/ directory (eg. VAADIN/themes/myTheme).
Create styles.css in your theme directory.
Add #import "../runo/styles.css"; to the beginning of your styles.css (you can replace runo by any other existing theme).
Call setTheme(myTheme); in your Vaadin application class.
If you want to apply application-wide styles, override the Vaadin component CSS definitions in your styles.css. If you don't know the names of the CSS classes, you can use firebug and check the HTML elements' classes.
If you want to create a component-specific style, define it in styles.css and call setStyleName or addStyleName methods.
See the CSS entry in the Book of Vaadin here.
As far as I can tell from looking at the demos, Vaadin just generates HTML, so yes.
Does one need to make changes on the CSS to map to corresponding Vaadin elements, or can one use that CSS as is?
You can use your own CSS styles (just as it is) and it can use for either individual components (as said by "miq*" earlier) or entire page. `
Here is a link for more info:
https://vaadin.com/book/-/page/themes.css.html

How can I access Rails objects in Sass?

In a Rails 3.1.0 project, I have Companies with a few customizable attributes like background_color and link_color. I want to be able to set some Sass variables like so:
$background_color: <%= #company.background_color %>
$link_color: <%= #company.link_color
...
This doesn't work because #company is nil when Sass does its thing. I'm not sure how to go about solving this in a way that's dynamic (companies can be created and colors can be changed and the views update immediately). Any suggestions?
I can think of a couple approaches off the top of my head:
Serve your stylesheet through a controller.
Use CSS classes to configure the colors and serve just that CSS through a controller, inlined partial, or a CSS #import.
Serving your stylesheet through a controller is pretty straightforward so there's not much to say. This might be a bit ugly and cumbersome.
For the second one, you'd add a couple extra CSS classes:
.custom-bg {
background-color: some-default-bg;
}
.link-fg {
color: some-default-fg;
}
/*...*/
Then any element that need to use the custom background color would need their usual CSS classes and custom-bg; similar shenanigans would be needed for the other configurable values. To supply the customized CSS, you could inline a <style> element into your HTML using a standard ERB partial or you could serve the CSS through a controller (either through <style src="..."> or #import). So you'd fake the SASSy goodness with old school multiple CSS classes in your HTML.
There's also JavaScript. You'd need some way to identify the elements that need their colors adjusted and then adjust them directly with things like this:
$('.need-custom-background').css('background-color', '...');
I think you might be able to do something just like what you have there, but you need to change the extensions of the files to '.css.scss.erb'
To follow up on this, I did create a stylesheet controller but it was rather contrived to get Sass parsing and asset pipeline load paths all working correctly. I ended up dumping that and reorganizing the styles so I could generate a static stylesheet for each company which gets regenerated and uploaded to S3 on company update.
Well, if you mean a dynamic object like a model loaded via a controller, you can't really, at least not very easily. This is because unlike HTML ERB templates, the SASS ones are generally rendered once and served statically unless something changes in the code or they are re-precompiled via rake (depending on your environment configs). But you can access some helper methods, global objects, and use some ruby in there by renaming the file with an "erb" extension e.g. application.css.scss.erb. See
https://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets
How can I use Ruby/Rails variables inside Sass?)
If you need styles based on dynamically loaded objects, like models, you can...
Write CSS styles literally in the template
Compile the stylesheets dynamically. See the top-rated answer here: How do I create dynamic CSS in Rails?
For some use cases you might accomplish the same thing by leveraging Rails/SASS's import path hierarchy (i.e. SASS #import 'partial_name_with_no_path' will search the importing SASS files folder first and then fall back to the top level - You can configure this as well).

Resources