New 2 Flashcards
embedded styles takes precedence over any CSS styles except . . .
styles that are marked with !important
a methodology for systematically organizing our styles
SMACSS
allows us to ship our components knowing that the styles of the component will (most likely) not be overridden by other styles in target applications
style isolation
each component will have a unique host property attached. . . when?
upon application startup (or at build-time with AOT)
how Angular provides the isolated styles
will then inject the styles directly into the page header as a style tag
how can you style the host of the component you’re in?
the special :host pseudo-class selector
if we want our component styles to cascade to all child elements of a component, but not to any other element on the page
:host /deep/ h2 {
color: red;
}
allow a component to apply a style to elements outside of it
the :host-context selector
(one use case - theme classes)
:host-context(.red-theme) .btn-theme { background: red; } :host-context(.blue-theme) .btn-theme { background: blue; }
CSS variable in Sass
$border-color: red;
Sass lets you make a reference to the parent style . . .
using the & syntax
sometimes we want global styles, that are applied to all elements of a page
we can add those to our angular-cli.json config
pattern for separation of components into . . .
Container Components vs Presentational Components
Container Components
These components know how to retrieve data from the service layer. Note that the top-level component of a route is usually a Container Component
Presentational Components
These components simply take data as input and know how to display it on the screen. They also can emit custom events
one way to prevent multiple requests to the backend on an observable
using publishLast().refCount()