SlideShare a Scribd company logo
Componentization:
CSS & Angular
David Amend @
Typical Angular project
https://angular.io/guide/styleguide#overall-structural-guidelines
> ng generate component mycomponent
CREATE src/app/componentB/componentB.component.html (30 bytes)
CREATE src/app/componentB/componentB.component.spec.ts (663 bytes)
CREATE src/app/componentB/componentB.component.ts (290 bytes)
CREATE src/app/componentB/componentB.component.scss (0 bytes)
UPDATE src/app/app.module.ts (10744 bytes)
CSS
- Where?
- Reuse?
- Componentize?
CSS in angular business component
#contact-form {
.navigation-buttons {
height: 71px;
padding-top: 30px;
position: relative;
.c-FormLinkButton {
line-height: 41px;
}
> div {
display: inline-block;
vertical-align: middle;
&:last-child {
position: absolute;
right: 0;
}}}
@media only screen and
(max-width: $mobile-max-width) {
.navigation-buttons {
height: 160px;
.c-FormLinkButton {
height: 50px;
line-height: 50px;
}
.c-MobileButton--secondary {
bottom: 10px;
position: absolute;
> a > span {
display: none;
}}
.c-FormButton--next {
top: 30px;
}}}
.target-form /deep/ {
button {
background-color: #1980d0;
border: 0;
border-radius: 3px;
color: #fff;
cursor: pointer;
font-size: 14px;
font-weight: bold;
font-family: Arial, sans-serif;
height: 39px;
min-width: 156px;
padding: 0 20px;
width: 290px;
}
.cta {
margin: 15px 0 15px 0;
}
}
@media screen and
(max-width: $mobile-max-width) {
button {
font-size: 18px;
font-weight: normal;
height: 50px;
width: 100%;
}
.pq .aw-wrapper-webui-de header.aw-pagehead
.aw-pagehead-meta.aw-bg-is-complex .aw-pagehead-metanav .aw-delimiter button {
color: #FE2E2E
}
Bad CSS quality & no reuse
Agenda
1. Style isolation/WC support by Angular
2. CSS Basic Rules
3. Summary
What is your level of CSS skills?
???
???
???
???
Novice
Expert
Angulars
Emulated View Encapsulation
(no Shadow DOM)
- _nghost-c*
- host-(element)
- host-context(.theme)
- ::ng-deepNative
Emulated
None
Angulars
Emulated View Encapsulation
(no Shadow DOM)
Example: setup
@Component({
selector: 'blue-button',
template: ` <h2>Blue</h2>
<button class="blue-button">click </button>`,
styles: [`
.blue-button {
color: blue;
}
h2 { font-size: 2rem;}
`]
}) export class BlueButtonComponent { }
@Component({
selector: 'app-root',
styleUrls:['./app.component.css'],
template: ` <h2>Buttons</h2>
<button class="red-button">click</button>
<blue-button></blue-button>
`})
export class AppComponent {
...
}
Example: Compiled, ngcontent
<app-root _nghost-c0="">
<h2 _ngcontent-c0="">Buttons</h2>
<button _ngcontent-c0="" class="red-button">Button</button>
<blue-button _nghost-c1="" _ngcontent-c0="">
<h2 _ngcontent-c1="">Blue</h2>
<button _ngcontent-c1="" class="blue-button">click</button>
</blue-button>
</app-root>
<style>
.blue-button[_ngcontent-c1] {
color: blue;
}
h2[_ngcontent-c1] {
font-size: 2rem;
}
</style>
.blue-button {
color:blue;
}
h2 { font-size: 2rem;}
:host(.red) h2 {
color: red;
}
<app-root _nghost-c0="">
<h2 _ngcontent-c0="">Button</h2>
<blue-button class=”red” _nghost-c1="" _ngcontent-c0="">
<h2 _ngcontent-c1="">Button</h2>
...
</app-root>
[_nghost-c1] h2[_ngcontent-c1] {
color: red;
}
:host {
padding: 20px;
}
[_nghost-c1] {
padding: 20px;
}
@Component({
selector: 'themeable-button',
template: `
<button>Themeable Button </button>`
, styles: [`
:host-context(.red-theme) button{
background: red;
}
:host-context(.blue-theme) button {
background: blue;
}`]
}) export class ThemeableButtonComponent {}
<root-context class="blue-theme">
<childs> …
<childs>
<themeable-button></themeable-button>
<childs>
</childs>
</root-context>
.blue-theme[_nghost-c1] button[_ngcontent-c1],
.blue-theme [_nghost-c1] button[_ngcontent-c1] {
background: blue;
}
ng-deep
:host ::ng-deep h2
{
color: black;
}
[_nghost-c1] h2 {
color: black;
}
Native
<app-root _nghost-c0="">
<h2 _ngcontent-c0="">Button</h2>
<blue-button class=”red” _nghost-c1="" _ngcontent-c0="">
<h2 _ngcontent-c1="">Button</h2>
...
</app-root>
Shadow Piercing combinators
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/13348719/
https://medium.com/@andreygoncharov/edge-hates-you-attributes-d15faf162939
mike k. Oct 10, 2017
Please, increase the priority of the issue.
The thing is Angular 2+ uses attributes to apply emulated
view encapsulation.
So the application performance may slow down when scaling.
Francois R. Jan 8, 2018 MICROSOFT EDGE TEAM
FYI, some performance improvements in this scenario should start to appear in the next release of Edge as we
improved some key scenarios. We don’t want to claim this issue is fixed yet because we aren’t on par with the other
browsers in all scenarios yet, so we will keep this issue open despite the current improvements, and will report any
further improvement towards our goal in the future as we get the opportunity to work on this further.
Web Components: Acceptance & Performance
<input type="date" name="bday">
<gold-cc-cvc-input card-type="amex"></gold-cc-cvc-input>
<progress value="1" max="4"></progress>
Step 2/4
→ iFrame alternative
→ framework-independant components
→ non corporate design
<video>
http://vic.github.io/prefix-css/
.angular-cli.json
"defaults": {
"component": {
"viewEncapsulation":
"None"
}
CSS Encapsulation: When?
.btn .btn-primary
.btn-xs-block
.btn btn-secondary
.cancel-button
.btn
.loading-contact-button
Problems
→ DOM specific rendering
→ no control of your styles
→ unstructured style components
- CSS first components
- Modular & Extendable by SCSS/Less
→ OOCSS
→ BEM
→ SMACSS
OOCSS
Object Oriented CSS
https://css-tricks.com/methods-organize-css/
Keep structure and skin separate
OOCSS: Structure & Style
<a href="#" class="btn btn-primary btn-lg disabled">click</a>
<a href="#" class="login-submit-button-disabled">Yes</a>
Style Structure
.btn {
display: inline-block;
font-weight: $btn-font-weight;
text-align: center;
white-space: nowrap;
vertical-align: middle;
user-select: none;
border: $btn-border-width solid transparent;
@include button-size($btn-padding-y, $btn-padding-x, $font-size-base, $btn-line-height, $btn-border-radius);
@include transition($btn-transition);
@each $color, $value in $theme-colors {
.btn-#{$color} {
@include button-variant($value, $value);
}
}
&.disabled,
&:disabled {
opacity: $btn-disabled-opacity;
@include box-shadow(none);
}
.row {
@include make-row();
}
> .col,
> [class*="col-"] {
padding-right: 0;
padding-left: 0;
}
}
+ Flex
Separate container and content
<div class=”row”>
<span class=”col-8”>Are you sure?</span>
<a href="#" class="col-4 btn btn-primary btn-lg disabled">click</a>
</div>
ContentContainer
<div>
<span style=”width:60%;”>Are you sure?</span>
<a href="#" class="login-submit-button-disabled">Yes</a>
</div>
OOCSS: Container & Content
Depth of Applicability (DOA) → parent dependencies
Specifity → Which rule is actually applied?
button {
padding: 5px;
}
.btn {
padding: 10px;
}
.btn-lg {
padding: 10px;
}
.btn-xxl {
padding: 20px;
}
https://specificity.keegan.st/
https://jonassebastianohlsson.com/specificity-graph/
https://getbootstrap.com/docs/4.0/dist/css/bootstrap.min.css
https://www.hypovereinsbank.de/etc/designs/hypovereinsbank/css/public.min.css
#sidebar div > button {
padding: 10px;
}
#sidebar div > div.border button.lg {
padding: 20px;
}
BEM
Block, Element, Modifier
<button class="btn">
<div class="btn__dropdown">
<a class="btn__dropdown__li
btn--disabled"
href="#">delete</a>
</div>
</button>
.block {}
.block__element {}
.block--modifier {}
<button class="btn">
<div class="btn__dropdown">
<a class="btn__li
btn--disabled"
href="#">delete</a>
</div>
</button>
.btn {}
.btn__dropdown {}
.btn--disabled {}
SMACSS
Scalable & Modular
Architecture for CSS
SMACSS—Scalable and Modular Architecture for CSS
● vendor/
○ _bootstrap.scss
● base/
○ _functions.scss
○ _mixins.scss
○ _variables.scss
○ _base.scss
■ state
● layout/
○ _grid.scss
○ _header.scss
○ _sidebar.scss
● main.scss
● module/
○ _navigations.scss
■ main-nav
● state
■ sub-nav
■ side-nav
○ _buttons.scss
■ state
○ _forms.scss
→ Separation of Style-Components
→ Style-State-directives
→ ViewEncapsulation.None
Use case considerations of CSS architecture
- Small application
- CSS-skills vary in team
- Integrate multiple frameworks
- Static content pages
Recap
- Corporate Design required. Performance restricted.
.angular-cli.json
"defaults": {
"component": {
"viewEncapsulation":
"None"
}
- Separation of Concerns
- /src/shared/styles/grid[fonts] Style Only Components
- /src/core/functions Angular Functional Components
- /src/core/styles/button/button.scss Style Component
- /src/core/styles/button/button.direcive.ts Angular Style-Support Component
- /src/app/ Angular Business Components
- Write Clean CSS code by OOCSS, BEM, SMACSS
Any Questions?
Ad

Recommended

Evrone.ru / BEM for RoR
Evrone.ru / BEM for RoR
Dmitry KODer
 
Convidar para page !!
Convidar para page !!
Jhonny Batista
 
Make your own wp cli command in 10min
Make your own wp cli command in 10min
Ivelina Dimova
 
20110820 header new style
20110820 header new style
AgentiadeturismInvenio
 
Tmx9
Tmx9
Lukas Mickosz
 
Posts ‹ teslaecoenergy — word press php
Posts ‹ teslaecoenergy — word press php
Miroslav Miskovic
 
Codigo taller-plugins
Codigo taller-plugins
Rocío Valdivia
 
Custom post-framworks
Custom post-framworks
Kiera Howe
 
WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3
Mizanur Rahaman Mizan
 
Work and play with SASS & Compass
Work and play with SASS & Compass
Andreas Dantz
 
Worth the hype - styled components
Worth the hype - styled components
kathrinholzmann
 
SULTHAN's - PHP MySQL programs
SULTHAN's - PHP MySQL programs
SULTHAN BASHA
 
Finding a Better Way to CSS: Navigating Sass with Compass
Finding a Better Way to CSS: Navigating Sass with Compass
Claudina Sarahe
 
$.Template
$.Template
Dave Furfero
 
Document
Document
Naveed Anjum
 
Shortcodes In-Depth
Shortcodes In-Depth
Micah Wood
 
Routing System In Symfony 1.2
Routing System In Symfony 1.2
Alex Demchenko
 
Profit statement 00
Profit statement 00
Sandro Suzart
 
Teddy Bear Blue
Teddy Bear Blue
angeliclv
 
12121212
12121212
Etietop Demas
 
Imageslider
Imageslider
Rajendra Kandel
 
WordPress overloading Gravityforms using hooks, filters and extending classes
WordPress overloading Gravityforms using hooks, filters and extending classes
Paul Bearne
 
RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”
apostlion
 
Date difference[1]
Date difference[1]
shafiullas
 
Drawing images
Drawing images
MfahamedaThabaseem
 
Build a better UI component library with Styled System
Build a better UI component library with Styled System
Hsin-Hao Tang
 
Front-End Methodologies
Front-End Methodologies
Arash Manteghi
 
Jonathan Snook - Falling to pieces: the componentization of the web
Jonathan Snook - Falling to pieces: the componentization of the web
Turing Fest
 
Start your app the better way with Styled System
Start your app the better way with Styled System
Hsin-Hao Tang
 
Real-world component libraries at scale
Real-world component libraries at scale
Stefan Baumgartner
 

More Related Content

What's hot (17)

WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3
Mizanur Rahaman Mizan
 
Work and play with SASS & Compass
Work and play with SASS & Compass
Andreas Dantz
 
Worth the hype - styled components
Worth the hype - styled components
kathrinholzmann
 
SULTHAN's - PHP MySQL programs
SULTHAN's - PHP MySQL programs
SULTHAN BASHA
 
Finding a Better Way to CSS: Navigating Sass with Compass
Finding a Better Way to CSS: Navigating Sass with Compass
Claudina Sarahe
 
$.Template
$.Template
Dave Furfero
 
Document
Document
Naveed Anjum
 
Shortcodes In-Depth
Shortcodes In-Depth
Micah Wood
 
Routing System In Symfony 1.2
Routing System In Symfony 1.2
Alex Demchenko
 
Profit statement 00
Profit statement 00
Sandro Suzart
 
Teddy Bear Blue
Teddy Bear Blue
angeliclv
 
12121212
12121212
Etietop Demas
 
Imageslider
Imageslider
Rajendra Kandel
 
WordPress overloading Gravityforms using hooks, filters and extending classes
WordPress overloading Gravityforms using hooks, filters and extending classes
Paul Bearne
 
RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”
apostlion
 
Date difference[1]
Date difference[1]
shafiullas
 
Drawing images
Drawing images
MfahamedaThabaseem
 
WordPress Theme Design and Development Workshop - Day 3
WordPress Theme Design and Development Workshop - Day 3
Mizanur Rahaman Mizan
 
Work and play with SASS & Compass
Work and play with SASS & Compass
Andreas Dantz
 
Worth the hype - styled components
Worth the hype - styled components
kathrinholzmann
 
SULTHAN's - PHP MySQL programs
SULTHAN's - PHP MySQL programs
SULTHAN BASHA
 
Finding a Better Way to CSS: Navigating Sass with Compass
Finding a Better Way to CSS: Navigating Sass with Compass
Claudina Sarahe
 
Shortcodes In-Depth
Shortcodes In-Depth
Micah Wood
 
Routing System In Symfony 1.2
Routing System In Symfony 1.2
Alex Demchenko
 
Teddy Bear Blue
Teddy Bear Blue
angeliclv
 
WordPress overloading Gravityforms using hooks, filters and extending classes
WordPress overloading Gravityforms using hooks, filters and extending classes
Paul Bearne
 
RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”
apostlion
 
Date difference[1]
Date difference[1]
shafiullas
 

Similar to Componentization css angular (20)

Build a better UI component library with Styled System
Build a better UI component library with Styled System
Hsin-Hao Tang
 
Front-End Methodologies
Front-End Methodologies
Arash Manteghi
 
Jonathan Snook - Falling to pieces: the componentization of the web
Jonathan Snook - Falling to pieces: the componentization of the web
Turing Fest
 
Start your app the better way with Styled System
Start your app the better way with Styled System
Hsin-Hao Tang
 
Real-world component libraries at scale
Real-world component libraries at scale
Stefan Baumgartner
 
CSS Architecture: Writing Maintainable CSS
CSS Architecture: Writing Maintainable CSS
Alexei Skachykhin
 
More of less (take 2)
More of less (take 2)
Guilherme Zühlke O'Connor
 
CSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the Backend
FITC
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Deepak Sharma
 
Css best practices style guide and tips
Css best practices style guide and tips
Chris Love
 
Sencha Touch
Sencha Touch
Craig Walker
 
OOCSS Lightening Talk
OOCSS Lightening Talk
Julie Cameron
 
Writing Scalable and Maintainable CSS
Writing Scalable and Maintainable CSS
Dmitry Sheiko
 
Getting Started with Sass & Compass
Getting Started with Sass & Compass
Rob Davarnia
 
HTML5, CSS3, and other fancy buzzwords
HTML5, CSS3, and other fancy buzzwords
Mo Jangda
 
Rock Solid CSS Architecture
Rock Solid CSS Architecture
John Need
 
"CSS you've never known" by Bohdan Rusinka
"CSS you've never known" by Bohdan Rusinka
Binary Studio
 
Web components with Angular
Web components with Angular
Ana Cidre
 
Speed up the site building with Drupal's Bootstrap Layout Builder
Speed up the site building with Drupal's Bootstrap Layout Builder
DrupalCamp Kyiv
 
Build a better UI component library with Styled System
Build a better UI component library with Styled System
Hsin-Hao Tang
 
Front-End Methodologies
Front-End Methodologies
Arash Manteghi
 
Jonathan Snook - Falling to pieces: the componentization of the web
Jonathan Snook - Falling to pieces: the componentization of the web
Turing Fest
 
Start your app the better way with Styled System
Start your app the better way with Styled System
Hsin-Hao Tang
 
Real-world component libraries at scale
Real-world component libraries at scale
Stefan Baumgartner
 
CSS Architecture: Writing Maintainable CSS
CSS Architecture: Writing Maintainable CSS
Alexei Skachykhin
 
CSS: A Slippery Slope to the Backend
CSS: A Slippery Slope to the Backend
FITC
 
Liberarsi dai framework con i Web Component.pptx
Liberarsi dai framework con i Web Component.pptx
Massimo Artizzu
 
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Cssbestpracticesjstyleguidejandtips 150830184202-lva1-app6892
Deepak Sharma
 
Css best practices style guide and tips
Css best practices style guide and tips
Chris Love
 
OOCSS Lightening Talk
OOCSS Lightening Talk
Julie Cameron
 
Writing Scalable and Maintainable CSS
Writing Scalable and Maintainable CSS
Dmitry Sheiko
 
Getting Started with Sass & Compass
Getting Started with Sass & Compass
Rob Davarnia
 
HTML5, CSS3, and other fancy buzzwords
HTML5, CSS3, and other fancy buzzwords
Mo Jangda
 
Rock Solid CSS Architecture
Rock Solid CSS Architecture
John Need
 
"CSS you've never known" by Bohdan Rusinka
"CSS you've never known" by Bohdan Rusinka
Binary Studio
 
Web components with Angular
Web components with Angular
Ana Cidre
 
Speed up the site building with Drupal's Bootstrap Layout Builder
Speed up the site building with Drupal's Bootstrap Layout Builder
DrupalCamp Kyiv
 
Ad

More from David Amend (14)

Angular 2 : learn TypeScript already with Angular 1
Angular 2 : learn TypeScript already with Angular 1
David Amend
 
Performance monitoring measurement angualrjs single page apps with phantomas
Performance monitoring measurement angualrjs single page apps with phantomas
David Amend
 
Angularjs practical project experiences with javascript development in a bank
Angularjs practical project experiences with javascript development in a bank
David Amend
 
Story about module management with angular.js
Story about module management with angular.js
David Amend
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.js
David Amend
 
Reasons to migrate to modern web development with JavaScript
Reasons to migrate to modern web development with JavaScript
David Amend
 
Thin Server Architecture SPA, 5 years old presentation
Thin Server Architecture SPA, 5 years old presentation
David Amend
 
Javascript & Angular .js for the enterprise, lessons learned, typescript scal...
Javascript & Angular .js for the enterprise, lessons learned, typescript scal...
David Amend
 
Grunt Advanced Vol 2, Plugins Text I/O with fun
Grunt Advanced Vol 2, Plugins Text I/O with fun
David Amend
 
Client Vs. Server Rendering
Client Vs. Server Rendering
David Amend
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
David Amend
 
Grunt js for the Enterprise Vol.1: Frontend Performance with Phantomas
Grunt js for the Enterprise Vol.1: Frontend Performance with Phantomas
David Amend
 
Gwt widget frameworks_presentation
Gwt widget frameworks_presentation
David Amend
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
David Amend
 
Angular 2 : learn TypeScript already with Angular 1
Angular 2 : learn TypeScript already with Angular 1
David Amend
 
Performance monitoring measurement angualrjs single page apps with phantomas
Performance monitoring measurement angualrjs single page apps with phantomas
David Amend
 
Angularjs practical project experiences with javascript development in a bank
Angularjs practical project experiences with javascript development in a bank
David Amend
 
Story about module management with angular.js
Story about module management with angular.js
David Amend
 
Multi modularized project setup with gulp, typescript and angular.js
Multi modularized project setup with gulp, typescript and angular.js
David Amend
 
Reasons to migrate to modern web development with JavaScript
Reasons to migrate to modern web development with JavaScript
David Amend
 
Thin Server Architecture SPA, 5 years old presentation
Thin Server Architecture SPA, 5 years old presentation
David Amend
 
Javascript & Angular .js for the enterprise, lessons learned, typescript scal...
Javascript & Angular .js for the enterprise, lessons learned, typescript scal...
David Amend
 
Grunt Advanced Vol 2, Plugins Text I/O with fun
Grunt Advanced Vol 2, Plugins Text I/O with fun
David Amend
 
Client Vs. Server Rendering
Client Vs. Server Rendering
David Amend
 
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
Client vs Server Templating: Speed up initial load for SPA with Angular as an...
David Amend
 
Grunt js for the Enterprise Vol.1: Frontend Performance with Phantomas
Grunt js for the Enterprise Vol.1: Frontend Performance with Phantomas
David Amend
 
Gwt widget frameworks_presentation
Gwt widget frameworks_presentation
David Amend
 
Grunt.js and Yeoman, Continous Integration
Grunt.js and Yeoman, Continous Integration
David Amend
 
Ad

Recently uploaded (20)

DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
Aarno Aukia
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
What is data visualization and how data visualization tool can help.pptx
What is data visualization and how data visualization tool can help.pptx
Varsha Nayak
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
SAP Datasphere Catalog L2 (2024-02-07).pptx
SAP Datasphere Catalog L2 (2024-02-07).pptx
HimanshuSachdeva46
 
Migrating to Azure Cosmos DB the Right Way
Migrating to Azure Cosmos DB the Right Way
Alexander (Alex) Komyagin
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Artificial Intelligence Workloads and Data Center Management
Artificial Intelligence Workloads and Data Center Management
SandeepKS52
 
Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Tech Services
 
Rierino Commerce Platform - CMS Solution
Rierino Commerce Platform - CMS Solution
Rierino
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Code and No-Code Journeys: The Coverage Overlook
Code and No-Code Journeys: The Coverage Overlook
Applitools
 
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
soulamaabdoulaye128
 
About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
certivoai
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
DevOps for AI: running LLMs in production with Kubernetes and KubeFlow
Aarno Aukia
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
What is data visualization and how data visualization tool can help.pptx
What is data visualization and how data visualization tool can help.pptx
Varsha Nayak
 
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Wondershare PDFelement Pro 11.4.20.3548 Crack Free Download
Puppy jhon
 
SAP PM Module Level-IV Training Complete.ppt
SAP PM Module Level-IV Training Complete.ppt
MuhammadShaheryar36
 
SAP Datasphere Catalog L2 (2024-02-07).pptx
SAP Datasphere Catalog L2 (2024-02-07).pptx
HimanshuSachdeva46
 
Software Testing & it’s types (DevOps)
Software Testing & it’s types (DevOps)
S Pranav (Deepu)
 
How Insurance Policy Management Software Streamlines Operations
How Insurance Policy Management Software Streamlines Operations
Insurance Tech Services
 
Artificial Intelligence Workloads and Data Center Management
Artificial Intelligence Workloads and Data Center Management
SandeepKS52
 
Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Underwriting Software Enhancing Accuracy and Efficiency
Insurance Tech Services
 
Rierino Commerce Platform - CMS Solution
Rierino Commerce Platform - CMS Solution
Rierino
 
UPDASP a project coordination unit ......
UPDASP a project coordination unit ......
withrj1
 
Reimagining Software Development and DevOps with Agentic AI
Reimagining Software Development and DevOps with Agentic AI
Maxim Salnikov
 
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
MOVIE RECOMMENDATION SYSTEM, UDUMULA GOPI REDDY, Y24MC13085.pptx
Maharshi Mallela
 
Code and No-Code Journeys: The Coverage Overlook
Code and No-Code Journeys: The Coverage Overlook
Applitools
 
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
Microsoft Business-230T01A-ENU-PowerPoint_01.pptx
soulamaabdoulaye128
 
About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
About Certivo | Intelligent Compliance Solutions for Global Regulatory Needs
certivoai
 
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Looking for a BIRT Report Alternative Here’s Why Helical Insight Stands Out.pdf
Varsha Nayak
 
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
Smadav Pro 2025 Rev 15.4 Crack Full Version With Registration Key
joybepari360
 

Componentization css angular

  • 2. Typical Angular project https://angular.io/guide/styleguide#overall-structural-guidelines > ng generate component mycomponent CREATE src/app/componentB/componentB.component.html (30 bytes) CREATE src/app/componentB/componentB.component.spec.ts (663 bytes) CREATE src/app/componentB/componentB.component.ts (290 bytes) CREATE src/app/componentB/componentB.component.scss (0 bytes) UPDATE src/app/app.module.ts (10744 bytes) CSS - Where? - Reuse? - Componentize?
  • 3. CSS in angular business component #contact-form { .navigation-buttons { height: 71px; padding-top: 30px; position: relative; .c-FormLinkButton { line-height: 41px; } > div { display: inline-block; vertical-align: middle; &:last-child { position: absolute; right: 0; }}} @media only screen and (max-width: $mobile-max-width) { .navigation-buttons { height: 160px; .c-FormLinkButton { height: 50px; line-height: 50px; } .c-MobileButton--secondary { bottom: 10px; position: absolute; > a > span { display: none; }} .c-FormButton--next { top: 30px; }}} .target-form /deep/ { button { background-color: #1980d0; border: 0; border-radius: 3px; color: #fff; cursor: pointer; font-size: 14px; font-weight: bold; font-family: Arial, sans-serif; height: 39px; min-width: 156px; padding: 0 20px; width: 290px; } .cta { margin: 15px 0 15px 0; } } @media screen and (max-width: $mobile-max-width) { button { font-size: 18px; font-weight: normal; height: 50px; width: 100%; }
  • 4. .pq .aw-wrapper-webui-de header.aw-pagehead .aw-pagehead-meta.aw-bg-is-complex .aw-pagehead-metanav .aw-delimiter button { color: #FE2E2E } Bad CSS quality & no reuse
  • 5. Agenda 1. Style isolation/WC support by Angular 2. CSS Basic Rules 3. Summary
  • 6. What is your level of CSS skills? ??? ??? ??? ??? Novice Expert
  • 8. - _nghost-c* - host-(element) - host-context(.theme) - ::ng-deepNative Emulated None Angulars Emulated View Encapsulation (no Shadow DOM)
  • 9. Example: setup @Component({ selector: 'blue-button', template: ` <h2>Blue</h2> <button class="blue-button">click </button>`, styles: [` .blue-button { color: blue; } h2 { font-size: 2rem;} `] }) export class BlueButtonComponent { } @Component({ selector: 'app-root', styleUrls:['./app.component.css'], template: ` <h2>Buttons</h2> <button class="red-button">click</button> <blue-button></blue-button> `}) export class AppComponent { ... }
  • 10. Example: Compiled, ngcontent <app-root _nghost-c0=""> <h2 _ngcontent-c0="">Buttons</h2> <button _ngcontent-c0="" class="red-button">Button</button> <blue-button _nghost-c1="" _ngcontent-c0=""> <h2 _ngcontent-c1="">Blue</h2> <button _ngcontent-c1="" class="blue-button">click</button> </blue-button> </app-root> <style> .blue-button[_ngcontent-c1] { color: blue; } h2[_ngcontent-c1] { font-size: 2rem; } </style> .blue-button { color:blue; } h2 { font-size: 2rem;}
  • 11. :host(.red) h2 { color: red; } <app-root _nghost-c0=""> <h2 _ngcontent-c0="">Button</h2> <blue-button class=”red” _nghost-c1="" _ngcontent-c0=""> <h2 _ngcontent-c1="">Button</h2> ... </app-root> [_nghost-c1] h2[_ngcontent-c1] { color: red; } :host { padding: 20px; } [_nghost-c1] { padding: 20px; }
  • 12. @Component({ selector: 'themeable-button', template: ` <button>Themeable Button </button>` , styles: [` :host-context(.red-theme) button{ background: red; } :host-context(.blue-theme) button { background: blue; }`] }) export class ThemeableButtonComponent {} <root-context class="blue-theme"> <childs> … <childs> <themeable-button></themeable-button> <childs> </childs> </root-context> .blue-theme[_nghost-c1] button[_ngcontent-c1], .blue-theme [_nghost-c1] button[_ngcontent-c1] { background: blue; }
  • 13. ng-deep :host ::ng-deep h2 { color: black; } [_nghost-c1] h2 { color: black; } Native <app-root _nghost-c0=""> <h2 _ngcontent-c0="">Button</h2> <blue-button class=”red” _nghost-c1="" _ngcontent-c0=""> <h2 _ngcontent-c1="">Button</h2> ... </app-root> Shadow Piercing combinators
  • 14. https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/13348719/ https://medium.com/@andreygoncharov/edge-hates-you-attributes-d15faf162939 mike k. Oct 10, 2017 Please, increase the priority of the issue. The thing is Angular 2+ uses attributes to apply emulated view encapsulation. So the application performance may slow down when scaling. Francois R. Jan 8, 2018 MICROSOFT EDGE TEAM FYI, some performance improvements in this scenario should start to appear in the next release of Edge as we improved some key scenarios. We don’t want to claim this issue is fixed yet because we aren’t on par with the other browsers in all scenarios yet, so we will keep this issue open despite the current improvements, and will report any further improvement towards our goal in the future as we get the opportunity to work on this further.
  • 15. Web Components: Acceptance & Performance <input type="date" name="bday"> <gold-cc-cvc-input card-type="amex"></gold-cc-cvc-input> <progress value="1" max="4"></progress> Step 2/4
  • 16. → iFrame alternative → framework-independant components → non corporate design <video> http://vic.github.io/prefix-css/ .angular-cli.json "defaults": { "component": { "viewEncapsulation": "None" } CSS Encapsulation: When? .btn .btn-primary .btn-xs-block .btn btn-secondary .cancel-button .btn .loading-contact-button Problems → DOM specific rendering → no control of your styles → unstructured style components
  • 17. - CSS first components - Modular & Extendable by SCSS/Less → OOCSS → BEM → SMACSS
  • 20. OOCSS: Structure & Style <a href="#" class="btn btn-primary btn-lg disabled">click</a> <a href="#" class="login-submit-button-disabled">Yes</a> Style Structure
  • 21. .btn { display: inline-block; font-weight: $btn-font-weight; text-align: center; white-space: nowrap; vertical-align: middle; user-select: none; border: $btn-border-width solid transparent; @include button-size($btn-padding-y, $btn-padding-x, $font-size-base, $btn-line-height, $btn-border-radius); @include transition($btn-transition); @each $color, $value in $theme-colors { .btn-#{$color} { @include button-variant($value, $value); } } &.disabled, &:disabled { opacity: $btn-disabled-opacity; @include box-shadow(none); } .row { @include make-row(); } > .col, > [class*="col-"] { padding-right: 0; padding-left: 0; } } + Flex
  • 22. Separate container and content <div class=”row”> <span class=”col-8”>Are you sure?</span> <a href="#" class="col-4 btn btn-primary btn-lg disabled">click</a> </div> ContentContainer <div> <span style=”width:60%;”>Are you sure?</span> <a href="#" class="login-submit-button-disabled">Yes</a> </div>
  • 23. OOCSS: Container & Content Depth of Applicability (DOA) → parent dependencies Specifity → Which rule is actually applied? button { padding: 5px; } .btn { padding: 10px; } .btn-lg { padding: 10px; } .btn-xxl { padding: 20px; } https://specificity.keegan.st/ https://jonassebastianohlsson.com/specificity-graph/ https://getbootstrap.com/docs/4.0/dist/css/bootstrap.min.css https://www.hypovereinsbank.de/etc/designs/hypovereinsbank/css/public.min.css #sidebar div > button { padding: 10px; } #sidebar div > div.border button.lg { padding: 20px; }
  • 25. <button class="btn"> <div class="btn__dropdown"> <a class="btn__dropdown__li btn--disabled" href="#">delete</a> </div> </button> .block {} .block__element {} .block--modifier {} <button class="btn"> <div class="btn__dropdown"> <a class="btn__li btn--disabled" href="#">delete</a> </div> </button> .btn {} .btn__dropdown {} .btn--disabled {}
  • 27. SMACSS—Scalable and Modular Architecture for CSS ● vendor/ ○ _bootstrap.scss ● base/ ○ _functions.scss ○ _mixins.scss ○ _variables.scss ○ _base.scss ■ state ● layout/ ○ _grid.scss ○ _header.scss ○ _sidebar.scss ● main.scss ● module/ ○ _navigations.scss ■ main-nav ● state ■ sub-nav ■ side-nav ○ _buttons.scss ■ state ○ _forms.scss
  • 28. → Separation of Style-Components → Style-State-directives → ViewEncapsulation.None
  • 29. Use case considerations of CSS architecture - Small application - CSS-skills vary in team - Integrate multiple frameworks - Static content pages
  • 30. Recap - Corporate Design required. Performance restricted. .angular-cli.json "defaults": { "component": { "viewEncapsulation": "None" } - Separation of Concerns - /src/shared/styles/grid[fonts] Style Only Components - /src/core/functions Angular Functional Components - /src/core/styles/button/button.scss Style Component - /src/core/styles/button/button.direcive.ts Angular Style-Support Component - /src/app/ Angular Business Components - Write Clean CSS code by OOCSS, BEM, SMACSS