Access primary color of prebuilt schemes - angular-material

I set up a new project using
ng new app
ng add #angular/material
I included the following line in styles.css:
#import '~#angular/material/prebuilt-themes/deeppurple-amber.css';
I want to apply the primary color of the deeppurple-amber theme to a <p> element.
How can I extract the primary color of a prebuilt scheme and apply it to my own component in Angular 6??

Instead of importing the pre-built theme, include the content of the pre-built theme instead.
#import '~#angular/material/theming';
// Include non-theme styles for core.
#include mat-core();
// Define a theme.
$primary: mat-palette($mat-deep-purple);
$accent: mat-palette($mat-amber, A200, A100, A400);
$theme: mat-light-theme($primary, $accent);
// Include all theme styles for the components.
#include angular-material-theme($theme);
You can then access the palettes and colors and theme your own components.

Related

Bootstrap 5.2.3 adding custom color to map

I am trying to add an extra color to my Bootstrap 5.2.3 project, but it's not generating the bg-* or text-* classes.
I tried using the Bootstrap 5.1 solutions found on GitHub, like these:
$starorange: #df711b;
$custom-theme-colors: (
"starorange": $starorange
);
$theme-colors: map-merge($theme-colors, $custom-theme-colors);
$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value");
$utilities-colors: map-merge($utilities-colors, $theme-colors-rgb);
$utilities-text-colors: map-loop($utilities-colors, rgba-css-var, "$key", "text");
$utilities-bg-colors: map-loop($utilities-colors, rgba-css-var, "$key", "bg");
#import "bootstrap";
But using < div class = "bg-starorange" > text < / div > does absolutely nothing. The bg-starorange class is not being generated.
So I went to the Bootstrap 5.2.3 docs and read that for this version, it should just be:
#import "variables.scss";
$custom-colors: (
"purple": $purple
);
// Merge the maps
$theme-colors: map-merge($theme-colors, $custom-colors);
#import "~bootstrap/scss/bootstrap";
The purple var is coming from the variables.scss file which is imported earlier and just includes some colors, but no maps etc.
When I use bg-purple on a div, I dont see anything in the dev tools inspector, when I do a global search in the whole project for "bg-purple" nothing is found. What am I doing wrong?

How to customize elements in angular dart

I'm trying to change style of tabs in Angular Dart using SCSS but it's not working. I don't see anything wrong.
Dart code contains
#Component(
selector: 'x-product-params-screen',
styleUrls: const ['element/tabs.css', 'element/buttons.css'],
templateUrl: 'scr_product_config.html',
...
element/tabs.scss contains
#import 'package:angular_components/css/material/material';
#import 'package:angular_components/material_tab/mixins';
#include tab-panel-accent-color('.tab-panel', $mat-red);
#include tab-panel-tab-strip-width('material-tab-panel', 300px);
#include tab-strip-color('material-tab-panel', '#ff0000', '#ff00ff');
and template scr_product_config.html contains
<material-tab-panel *ngIf="product.parts.length > 1">
<material-tab *ngFor="let part of product.parts"
[label]="part.name"
[part]="part">
<x-part-config
[part]="part"
(onConfigure)="onConfigure($event)">
</x-part-config>
</material-tab>
</material-tab-panel>
But neighter strip width nor tab color change.
The first thing to look at when debugging such issue is what HTML you have and what CSS was generated. I do not see class tab-panel in your HTML, but other than that it looks good and very similar to the example, and it seems to run fine there.
So maybe there is something else in your app that is overriding some styles?

Override bootstrap breakpoints in rails [duplicate]

I'm trying to use jqtouch theming which is based on SASS and COMPASS. I have a file custom.scss with the most simple code, one import and one variable to overwrite:
#import 'jqtouch';
// Override variables
$base-color: #fe892a;/* The default base which is later used for toolbar, list, and button backgrounds.*/
When I now compile the scss file to css, it will basically just generate the jqtouch css with my filename. The color specification is nowhere to be seen, although the variable is definitley correct per documentation (Official Guide) and in the jqtouch.scss file, which I import for costumizing.
I'm running Sass 3.2.9 and Compass 0.12.2 on a Windows machine.
I've tried it with more variables and different file imports, but the result is always, that my override values are not incorporated.
The ruby config file for compass seems to be unsuspicious.
Does anyone have an idea what goes wrong in the process so that my override values are ignored?
You're setting the color after it has already been used. Basically, what you're trying to do is this:
$color: red;
.foo {
background: $color;
}
$color: green;
Depending on how jqtouch is written, you might not be able to modify the colors at all. You need the variables to be set as a default in order to overwrite them ahead of time:
$color: green;
$color: red !default; // red is only used if $color is not already set
.foo {
background: $color; // color is green
}
So your code should be written as such:
// Override variables
$base-color: #fe892a;/* The default base which is later used for toolbar, list, and button backgrounds.*/
#import 'jqtouch';

Bourbon's #font-face mixin

I'm new to Bourbon & SASS and trying to use the #font-face mixin to add a font I downloaded (Museo Sans) to my Rails 3 app.
Bourbon provides the following examples:
#include font-face(SourceSansPro, '/fonts/Source_Sans_Pro/SourceSansPro-Regular');
#include font-face(SourceSansPro, '/fonts/Source_Sans_Pro/SourceSansPro-Bold', bold);
#include font-face(SourceSansPro, '/fonts/Source_Sans_Pro/SourceSansPro-Italic', normal, italic);
// Rails asset-pipeline - place fonts in app/assets/fonts/
#include font-face(SourceSansPro, 'Source_Sans_Pro/SourceSansPro-Regular', normal, $asset-pipeline: true);
What I did:
// application.css.scss
#import "bourbon";
#import "fonts";
// fonts.css.scss
#include font-face(MuseoSans, '/fonts/MuseoSans/MuseoSans_500-webfont', normal, $asset-pipeline: true);
* {
font-family: MuseoSans;
}
The fonts are in assets/fonts/MuseoSans/ with filenames like MuseoSans_500-webfont.eot, .ttf, etc. I get the impression you can leave off the extension and Bourbon is supposed to pick up all the files.
I've tried a lot of different variants of the above to no avail. I know that Bourbon and the files are working because when I set the font-family to $helvetica I see a change on the page.
If anyone can provide the proper code, or a GitHub project that I could look at, I'd be much obliged.
Try removing the leading "/fonts" in your in your path like:
#include font-face(MuseoSans, 'MuseoSans/MuseoSans_500-webfont', normal, $asset-pipeline: true);
I had some issues working with this mixin as well - I would get IOerrors if the following files were not present in the fonts directory: "myfont.eot?#iefix" and "myfont.svg#myfont."
However, when I added those files, I found that they were not getting precompiled (i.e. they lacked a MD5 thumb print and weren't present in the asset manifest), so I decided to override this mixin and rewrite it using modified asset-path methods.

Sharing mixins between scss files in rails 3.1

I'm trying to refer to a mixin defined in one file (application.css.scss) in another (home.css.scss). I have tried importing application into home but still get an "Undefined mixin" error.
Is there a way to automatically import all of my files, or what is the best way to manage imports between files?
I haven't been able to make the jump to 3.1 yet, but using Compass & Sass for quite a while, I've found it's best to try to manage mixin/definition sass separately from your actual CSS generating sass. In this way, the mixin files can be treated freely like code libraries, included wherever necessary, without them repeatedly generating CSS rules.
So you might have:
/* my-mixin-concern.scss */
$default_foo: 123px !default;
#mixin some-concern($foo: $default_foo) {
// do something
}
/* application.scss */
$default_foo: 321px; // optionally, pre-set the default value before import.
#import 'my-mixin-concern';
p { #include some-concern; }
/* home.scss */
#import 'my-mixin-concern';
body.home p { #include some-concern(9000px); }
In this way you are explicitly importing all requirements for each scss file, similarly to how you would do so in a code library.
Pure Rails Solution
Step 1. Rename
application.css -> application.css.scss
Step 2. Refactor
// application.css.scss
/*
*= require_self
*/
#import "mixins.css.csss"
#import "project.css.scss"

Resources