Change angular material material theme dynamically - angular-material

I am new to angular and wanted to change the angular material themes dyamically ,I know how to make differnt themes that is by making scss file ,define 3 colors, include mat properties and functions, but then I was adding that file refrence statically in angular.json, but if I have many custom angular material themes I want to refrence the css files dynamalically.
So is there any easy quick and rather optimized way to do that?
P.S I have gone through many post and docs but seems to be confusing in order when it comes to change the theme dyamically like for example if I have toggle then how to refrence the different style rather than the default one?
Any answer would be higly appreciated..!!

One solution is to build the material color palette in real time. These are the necessary steps:
Define the color palette in CSS variables and then access them.
Assign these variables to the material angular theme.
Using the "tinycolor" library we create a service to generate the
palette based on a color.
With JavaScript we update the CSS variables in the DOM.
Here you have an example:
https://stackblitz.com/edit/angular-material-theming-playground

Related

How to apply Custom Styling XF.Material controls

I am using XF.Material library for my Xamarin Forms project, as per the instructions I have created Material Resources in App.xaml and passed configuration name as a parameter to the initializer. bur for some reason I do not see any application-specific style (Colors and Fonts) instead it is using Material style (Purple color).
I have also tried creating MaterialConfiguration instance in the code-behind and assigned it to the initializer but still, it is not taking any custom style.
Yes, I have added the plist entry as per the instructions.....
What am I missing any idea???
UPDATE:
I have tried adding dynamic configuration like below but snackbar did not take it!!

AngularDart custom SVG mat-icon

I'm trying to register custom SVG icons to use as Material icons, specifically national flags.
In Angular I would use MatIconRegistry.addSvgIcon(..) in conjunction with DomSanitizer.
In AngularDart I've found DomSanitizationService, but so far I'm unable to find the equivalent of MatIconRegistry.
We use a mix-in if you want to override any material-icons in an angular_component here: https://github.com/dart-lang/angular_components/blob/7f254c89cbbd512cc284a7e9d03bb687f9948bd9/angular_components/lib/material_icon/_mixins.scss#L51
If you are just working with icons separately and it isn't overriding one that is already included. I suggest just working with the SVG itself outside of material-icon.

create application without any theme

Hi I am new to Vaadin and I was looking about the theme.
In Vaadin, is it possible to to develop application without any theme?
I will apply theme only if any theming is required. So that it should look
normal html components.Currently I am using vaadin7 and I know how to customize
themes to the components which I dont need. I need to develop the applications without having any themes.
You can create a "empty" theme and use this one. (Means, one which does not inherit from any other theme)
https://vaadin.com/book/-/page/themes.html
But be aware that the themes also influence the way the vaadin buttons are drawn, scroll behaviour of panels, and many many other things.
To prevent breaking basic stuff, there exists a base theme which only holds the minimal css/sass rules for vaadin.
Look in section 8.4.4. Built-in Themes
of https://vaadin.com/book/-/page/themes.creating.html

is it possible to create simple application without any theme?

I am new to Vaadin. I wanted to create s simple page which should not have
any theme. When I run the simple application, it default takes reeinder theme.
So is it possible to create a simple theme without having any themes?
So it looks white background, normal html button, normal html labels,etc.
If needed, I shall use my own themes which could be created out of CSS file.
Yes,
it is possible to use a empty theme.
You must just create a empty css or sass file and then specify to use that theme.
You can then add the styles you need to the file.
You will then of course have to use the standard html buttons and so on.
The vaadin default buttons (and most components) depend on a proper theme.
This link might help you see what you will have to do when you wish to start with a completely new theme: https://vaadin.com/de/wiki/-/wiki/Main/Vaadin+Theme+Tips+and+Tricks#section-Vaadin+Theme+Tips+and+Tricks-CreatingACompletelyNewLookNFeel
Perhaps starting with the base theme would be the middle way to go.
VAADIN/themes/base/styles.css

Dart, Polymer and Foundation CSS

I tried mixing polymer web component w/dart and Foundation CSS framework and so far things simple things are working like button, grid, menu. I guess if i run into an issue, I just need to port the javascript I need to dart. Anyone try this or thinking of trying this?
This was trick to get CSS to leak into component.
class ClickCounter ... {
...
bool get applyAuthorStyles => true;
...
http://i.stack.imgur.com/oNoGR.png
Yes I try this too.
The first thing I tried was create one style file for each component and use the sass #extends to make each component style, my goal was to abstract the zurb, so if I want change the theme, or css framework I just need change the sass file.
But zurb-foundation depends on a base file that have to be include, I can't create one file just for buttons, because de buttons in foundation depend on variables seted in the main file, this generate a huge file with redundant css for each component.
The second thing I tried was warp the basic components, like button, lets say a
<x-button></x-button>
Then in my sass file I include the zurb button file, and make x-button #extends .button or #include .button that make buttons and x-button with the same look. This work for basic elements.
The other way is to applyAuthorStyles and let the css leak
I'm not sure what is the best way, because each approach has its pitfalls.
Why I wrap basic components? To have common behavior and API. For example: enable and disable components, in a form. All my basic components in polymer (x-button, x-input, etc) extends from my framework class, in this framework class I have the common behavior enable and disable, so I can progamattic enable and disable components with the same API.
This is a slow work in proggress, more for fun, and I stop working on this because I need to spend more time creating applications and not creating frameworks. Unfortunately there is no good component framework for Dart as in Javascript like ExtJs and Dojo.
But the Idea was make a component set (with common behavior) and use sass frameworks to the visual effect, maybe abstract the css framework in a way it can be plug and change the look and feel of the application, and that is not easy because some components have specific html markup

Resources