SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Doing More With

 How a meta-language can help you
take control of your stylesheets and
help improve your style productivity.
David Engel
•   UofM grad
•   .NET and PHP developer
•   Tipping Canoe alumnus
•   Experienced “backend” developer
       PHP, C#, C++, MySQL, TransactSQL, Sphinx
• Relatively new to “frontend” development
       CSS, jQuery, LESS, UX, design
CSS

        Cascading Style Sheets

• describes look & formatting of a document
  that has been created using markup
• separate style and content
• avoid specificity by harnessing the cascade
OOCSS

          Object Oriented CSS

• separate structure and skin
• separate container and content
OOCSS

#button {                           #box {
  width: 100px;                       width: 200px;
  height: 25px;                       height: 400px;
  background: #ccc;                   background: #ccc;
  border: 1px solid #333;             border: 1px solid #333;
  border-radius: 5px;                 border-radius: 5px;
}                                   }




<a id="button" href="">blah</a>
<div id="box">blah</div>
OOCSS
becomes…
.button {                                 .skin {
  width: 100px;                             background: #ccc;
  height: 25px;                             border: 1px solid #333;
}                                           border-radius: 5px;
.box {                                    }
  width: 200px;
  height: 400px;
}


<a class="button skin" href="">blah</a>
<div class="box skin">blah</div>
OOCSS


Use classes for styling hooks!

Use ids for behavioral hooks!
DRY CSS
     Don’t Repeat Yourself (Jeremy Clarke)
1. Group reusable CSS properties together
2. Use logical names for groups
3. Add selectors (not a fan of ALL-CAPS)
#WHITE-BACKGROUND,
.large-white-background,
.medium-white-background
{
  background-color: #fff;
  border-color: #bbb;
}
DRY CSS
          What are we still missing?
• Descendent selectors break OOCSS – so what?
     (the “OO” part of OOCSS is garbage anyways)

• No variables
• No mixins
• No inheritance
LESS
•   variables      •   comparitors
•   mixins         •   type/unit checking
•   nesting        •   color functions
•   operations     •   math functions
•   functions      •   string embedding
•   switches       •   Namespaces
•   overloads      •   Javascripting!!!
LESS: Variables


@maxim-green:#8dc63f;

.color-green{
   color:@maxim-green;
}
LESS: Mixins
• Gives us inheritance!
.rounded-corners{
  border-radius: 5px;
  -webkit-border-radius: 5px;
  -moz-border-radius: 5px;
}
#header {
  .rounded-corners;
}
LESS: Mixins
Parametric mixins extend this functionality
.rounded-corners (@radius) {
   border-radius: @radius;
   -webkit-border-radius: @radius;
   -moz-border-radius: @radius;
}
#header {
   .rounded-corners(5px);
}
LESS: Mixins
Parametric mixins can also have default values
.rounded-corners (@radius: 5px) {
   border-radius: @radius;
   -webkit-border-radius: @radius;
   -moz-border-radius: @radius;
}
#header {
   .rounded-corners;
}
LESS: Nesting
    Nesting gives us a kind of namespacing for specificity of
                           inheritance
#header {
      h1 {      font-size: 26px;
                font-weight: bold;
         }
         p{     font-size: 12px;
                a{      text-decoration: none;
                        &:hover { border-width: 1px }
                }
         }
}
LESS: Nesting
… and Scope
@red : red;
#header {
      @red: #BF2E1A;
      h1 {color: @red;   // yields #BF2E1A
      }
}
h1 {color: @red;         // yields red
}
LESS: Operations
• add, subtract, divide and multiply properties

@red: # BF2E1A;
@main-margin: 4px;

#footer{
  color: @red + #001100;
  margin-left: @main-margin * 3;
}
LESS: Functions
Take arguments into your mixins…

.box-shadow (@x: 0, @y: 0, @blur: 1px, @color: #000) {
  box-shadow: @x @y @blur @color;
  -moz-box-shadow: @x @y @blur @color;
  -webkit-box-shadow: @x @y @blur @color;
}
.box-shadow(3px, 7px);
LESS: Functions
…or use the @arguments variable to take it all!

.box-shadow (@x: 0, @y: 0, @blur: 1px, @color: #000) {
  box-shadow: @arguments;
  -moz-box-shadow: @arguments;
  -webkit-box-shadow: @arguments;
}
.box-shadow(3px, 7px);
LESS: Imperative Programming
This is a kind of switch (note the “all” selector)…
.color-mixin (dark, @color) {
  color: darken(@color, 10%);
}
.color-mixin (light, @color) {
  color: lighten(@color, 10%);
}
.color-mixin (@_, @color) {
  display: block;
}
LESS: Imperative Programming
…that we can call like so:

@light-switch: light;
@dark-switch: dark;
.light-class {
  .color-mixin(@light-switch, #888);
}
.dark-class {
  .color-mixin(@dark-switch, #888);
}
LESS: Overloads
“Arity” for the geeks (and Java and .NET folks)
.fade-mixin (@a-color) {
  color: @a-color;
}
.fade-mixin (@a-color, @b-color) {
  color: fade(@a-color, @b-color);
}
#solid-color{
  .fade-mixin(blue);
}
#faded-color{
  .fade-mixin(blue, green);
}
LESS: Guarded mixins
• uses “when” and can use “and” “,” and “not”
• can also use the keywords “true” and “false”

.back-white{background-color:white;}
.back-black{background-color:black;}
.back-red{background-color:red;}
.mixin (@a) when (@a > 10), (@a < -10){
          .back-white;}
.mixin (@a) when (@a = 10) and (@a = true){
          .back-red;}
.mixin (@a) when (@a < 11) and (@a > -11) and not(@a = 10){
          .back-black;}
LESS: Guarded mixins
• Comparitors can be very useful
• Eg. Code reuse between media types


@media: mobile;
.mixin (@a) when (@media = mobile) { ... }
.mixin (@a) when (@media = desktop) { ... }
.mixin (@a) when (@media = print) { ... }
LESS: Type checking
• iscolor           • isstring            • isurl
• isnumber          • iskeyword
.color-mixin (@a) when (isnumber(@a)) {
        color: @a + #001100;}
.color-mixin (@a) when (iscolor(@a)) {
        color: @a}
h1{
 .color-mixin(red);}
h2{
 .color-mixin(#842210);}
LESS: Unit checking
• ispixel      • ispercentage • isem




.mixin (@a) when (ispixel(@a)) {}
.mixin (@a) when (isem(@a)) {}
.mixin (@a) when (ispercentage(@a)) {}
LESS: Colour Functions
lighten(@color, 10%);     // return a color which is 10% *lighter* than @color
darken(@color, 10%);       // return a color which is 10% *darker* than @color

saturate(@color, 10%); // return a color 10% *more* saturated than @color
desaturate(@color, 10%); // return a color 10% *less* saturated than @color

fadein(@color, 10%); // return a color 10% *less* transparent than @color
fadeout(@color, 10%); // return a color 10% *more* transparent than @color
fade(@color, 50%);   // return @color with 50% transparency

spin(@color, 10);       // return a color with a 10 degree larger in hue than @color
spin(@color, -10);      // return a color with a 10 degree smaller hue than @color

mix(@color1, @color2); // return a mix of @color1 and @color2
LESS: Math Functions

       ceil
      floor
     round
   percentage
LESS: Extract Colour Properties
hue(@color);
saturation(@color);
lightness(@color);
alpha(@color);

eg.

@old-color:#27BA19;
@new-color: hsl(hue(@old-color), 45%, 90%);
LESS: Embedding Strings
• For those of you familiar with XSLT or Ruby
• Use curly braces to embed the text
• Use tilde ~ to escape strings that require quotes

  @base-url: "http://www.maximinc.com/";
  @green-color: #8dc63f;
  #header{
     background: @ green-color url("@{base-url}images/img.png");
  }
  #footer{
    filter: ~"alpha(opacity = (@{opacityPercentage}))";
  }
LESS: Javascripting!!!
• Use backticks to embed your JS in the CSS
• Escape strings, embed, interpolate, etc.
• I haven’t played with this feature yet, but here’s an
  untested example:

  @var1: `"LESS ".toLowerCase()`;
  @var2: `"ooooooh".toUpperCase() + '!'`;
  @var3: ~`"@{var1: }" + "@{var2: }" + '!'`;
LESS Elements
•   .gradient              •   .rotation
•   .bw-gradient           •   .scale
•   .bordered              •   .transition
•   .drop-shadow           •   .inner-shadow
•   .rounded               •   .box-shadow
•   .border-radius         •   .columns
•   .opacity               •   .translate
•   .transition-duration
LESS: Precompilers
LESS needs to be pre-compiled into CSS using…
 • simpless                              • less.app
 • lessphp                               • …others
                       OR
to compile on the fly while developing use…
<link rel="stylesheet/less" type="text/css" href="styles.less">
<script src="http://lesscss.googlecode.com/files/less-1.0.30.min.js"></script>
LESS: SIMPLESS
•   SimpLESS compiles less into minified css
•   works with Twitter bootstrap
•   self-updates
•   compiles on the fly (monitored polling)
•   multi-platform
•   free
•   open source
LESS: SIMPLESS
This is what I do…
1. I code my LESSS in a separate project
2. I let SimpLESS monitor the local file to
   compile CSS on the fly
3. I commit minified CSS to my main project
4. I reference the minified CSS using with the
   SVN version tagged on in my html
<link media="screen" href=http://www.example.com/css/style.min.css?1994
         type="text/css" rel="stylesheet“>
LESS: Eclipse plugin
I personally use the Xtext plugin – here are some
               install instructions…
   http://www.normalesup.org/~simonet/soft/ow/eclipse-less.en.html


You can use the LESS compiler in
Eclipse, however I manage all my compilation
externally as I also use LESS with .NET and
Classic ASP code (yes!)
Useful links
              LESS
    http://www.lesscss.org
           SimpLESS
http://wearekiss.com/simpless
         LessElements
   http://lesselements.com
         Winnipeg PHP
   http://winnipegphp.com
         Tipping Canoe
http://www.tippingcanoe.com
          David Engel
 davidengel.dev@gmail.com
          (developed using LESS)
  http://www.maximinc.com

Weitere ähnliche Inhalte

Was ist angesagt?

Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & CompassRob Davarnia
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compassNick Cooley
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESSItai Koren
 
CSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsCSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsSanjoy Kr. Paul
 
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassBringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassClaudina Sarahe
 
Getting Sassy with CSS
Getting Sassy with CSSGetting Sassy with CSS
Getting Sassy with CSSJulie Cameron
 
Performant, accessible animations with CSS & a dash of JavaScript
Performant, accessible animations with CSS & a dash of JavaScriptPerformant, accessible animations with CSS & a dash of JavaScript
Performant, accessible animations with CSS & a dash of JavaScriptsoyarsauce
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sassKnoldus Inc.
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASSJon Dean
 
CSS Walktrough Internship Course
CSS Walktrough Internship CourseCSS Walktrough Internship Course
CSS Walktrough Internship CourseZoltan Iszlai
 
HTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventionsHTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventionsKnoldus Inc.
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction SassZeeshan Ahmed
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)emrox
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Startededgincvg
 
Sass and compass workshop
Sass and compass workshopSass and compass workshop
Sass and compass workshopShaho Toofani
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compassdrywallbmb
 

Was ist angesagt? (20)

Getting Started with Sass & Compass
Getting Started with Sass & CompassGetting Started with Sass & Compass
Getting Started with Sass & Compass
 
Less vs sass
Less vs sassLess vs sass
Less vs sass
 
Advanced sass/compass
Advanced sass/compassAdvanced sass/compass
Advanced sass/compass
 
Sass, Compass
Sass, CompassSass, Compass
Sass, Compass
 
SASS is more than LESS
SASS is more than LESSSASS is more than LESS
SASS is more than LESS
 
CSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and ConsCSS Less framework overview, Pros and Cons
CSS Less framework overview, Pros and Cons
 
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and CompassBringing sexy back to CSS: SASS/SCSS, LESS and Compass
Bringing sexy back to CSS: SASS/SCSS, LESS and Compass
 
Getting Sassy with CSS
Getting Sassy with CSSGetting Sassy with CSS
Getting Sassy with CSS
 
Performant, accessible animations with CSS & a dash of JavaScript
Performant, accessible animations with CSS & a dash of JavaScriptPerformant, accessible animations with CSS & a dash of JavaScript
Performant, accessible animations with CSS & a dash of JavaScript
 
Compass/Sass
Compass/SassCompass/Sass
Compass/Sass
 
Deep dive into sass
Deep dive into sassDeep dive into sass
Deep dive into sass
 
Introduction to SASS
Introduction to SASSIntroduction to SASS
Introduction to SASS
 
CSS Walktrough Internship Course
CSS Walktrough Internship CourseCSS Walktrough Internship Course
CSS Walktrough Internship Course
 
HTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventionsHTML5, CSS, JavaScript Style guide and coding conventions
HTML5, CSS, JavaScript Style guide and coding conventions
 
Css3
Css3Css3
Css3
 
Simple introduction Sass
Simple introduction SassSimple introduction Sass
Simple introduction Sass
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
 
Sass and Compass - Getting Started
Sass and Compass - Getting StartedSass and Compass - Getting Started
Sass and Compass - Getting Started
 
Sass and compass workshop
Sass and compass workshopSass and compass workshop
Sass and compass workshop
 
Finding your way with Sass+Compass
Finding your way with Sass+CompassFinding your way with Sass+Compass
Finding your way with Sass+Compass
 

Andere mochten auch

Simpósio Hanseníase - Hanseníase - dermatologista Carla
Simpósio Hanseníase - Hanseníase - dermatologista CarlaSimpósio Hanseníase - Hanseníase - dermatologista Carla
Simpósio Hanseníase - Hanseníase - dermatologista Carlalascounic
 
Aula de hanseníase
Aula de hanseníaseAula de hanseníase
Aula de hanseníaseIsmael Costa
 
Hanseníase do conceito ao tratamento SLIDS
Hanseníase do conceito ao tratamento SLIDSHanseníase do conceito ao tratamento SLIDS
Hanseníase do conceito ao tratamento SLIDSsara moura
 
Campanha Nacional de Hanseníase 2015
Campanha Nacional de Hanseníase 2015Campanha Nacional de Hanseníase 2015
Campanha Nacional de Hanseníase 2015Ministério da Saúde
 

Andere mochten auch (7)

Hanseníase
HanseníaseHanseníase
Hanseníase
 
Hanseníase
HanseníaseHanseníase
Hanseníase
 
Simpósio Hanseníase - Hanseníase - dermatologista Carla
Simpósio Hanseníase - Hanseníase - dermatologista CarlaSimpósio Hanseníase - Hanseníase - dermatologista Carla
Simpósio Hanseníase - Hanseníase - dermatologista Carla
 
Aula de hanseníase
Aula de hanseníaseAula de hanseníase
Aula de hanseníase
 
Hanseníase do conceito ao tratamento SLIDS
Hanseníase do conceito ao tratamento SLIDSHanseníase do conceito ao tratamento SLIDS
Hanseníase do conceito ao tratamento SLIDS
 
HanseníAse.Ppt
HanseníAse.PptHanseníAse.Ppt
HanseníAse.Ppt
 
Campanha Nacional de Hanseníase 2015
Campanha Nacional de Hanseníase 2015Campanha Nacional de Hanseníase 2015
Campanha Nacional de Hanseníase 2015
 

Ähnlich wie Doing More With Less

Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3 Wynn Netherland
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Anam Hossain
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and howmirahman
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application DesignBryce Kerley
 
LeSS in action
LeSS in actionLeSS in action
LeSS in actionPu Shiming
 
Keep calm and let's play CSS3
Keep calm and let's play CSS3Keep calm and let's play CSS3
Keep calm and let's play CSS3A2 Comunicação
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid PrototypingEven Wu
 
Less(CSS Pre Processor) Introduction
Less(CSS Pre Processor) IntroductionLess(CSS Pre Processor) Introduction
Less(CSS Pre Processor) Introductionrushi7567
 
LESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introductionLESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introductionrushi7567
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsKaelig Deloumeau-Prigent
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPressJames Steinbach
 
Agile CSS development with Compass and Sass
Agile CSS development with Compass and SassAgile CSS development with Compass and Sass
Agile CSS development with Compass and SassAndrea Verlicchi
 

Ähnlich wie Doing More With Less (20)

Big Design Conference: CSS3
Big Design Conference: CSS3 Big Design Conference: CSS3
Big Design Conference: CSS3
 
Accelerated Stylesheets
Accelerated StylesheetsAccelerated Stylesheets
Accelerated Stylesheets
 
Less css
Less cssLess css
Less css
 
Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01Css preprocessor-140606115334-phpapp01
Css preprocessor-140606115334-phpapp01
 
CSS preprocessor: why and how
CSS preprocessor: why and howCSS preprocessor: why and how
CSS preprocessor: why and how
 
CSS Extenders
CSS ExtendersCSS Extenders
CSS Extenders
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
Advanced Technology for Web Application Design
Advanced Technology for Web Application DesignAdvanced Technology for Web Application Design
Advanced Technology for Web Application Design
 
LeSS in action
LeSS in actionLeSS in action
LeSS in action
 
Keep calm and let's play CSS3
Keep calm and let's play CSS3Keep calm and let's play CSS3
Keep calm and let's play CSS3
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
 
Less(CSS Pre Processor) Introduction
Less(CSS Pre Processor) IntroductionLess(CSS Pre Processor) Introduction
Less(CSS Pre Processor) Introduction
 
LESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introductionLESS(CSS Pre Processor) introduction
LESS(CSS Pre Processor) introduction
 
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive NewsMobile-first OOCSS, Sass & Compass at BBC Responsive News
Mobile-first OOCSS, Sass & Compass at BBC Responsive News
 
Theming and Sass
Theming and SassTheming and Sass
Theming and Sass
 
LESS CSS
LESS CSSLESS CSS
LESS CSS
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPress
 
Why less?
Why less?Why less?
Why less?
 
Agile CSS development with Compass and Sass
Agile CSS development with Compass and SassAgile CSS development with Compass and Sass
Agile CSS development with Compass and Sass
 
PostCss
PostCssPostCss
PostCss
 

Kürzlich hochgeladen

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Kürzlich hochgeladen (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Doing More With Less

  • 1. Doing More With How a meta-language can help you take control of your stylesheets and help improve your style productivity.
  • 2. David Engel • UofM grad • .NET and PHP developer • Tipping Canoe alumnus • Experienced “backend” developer PHP, C#, C++, MySQL, TransactSQL, Sphinx • Relatively new to “frontend” development CSS, jQuery, LESS, UX, design
  • 3. CSS Cascading Style Sheets • describes look & formatting of a document that has been created using markup • separate style and content • avoid specificity by harnessing the cascade
  • 4. OOCSS Object Oriented CSS • separate structure and skin • separate container and content
  • 5. OOCSS #button { #box { width: 100px; width: 200px; height: 25px; height: 400px; background: #ccc; background: #ccc; border: 1px solid #333; border: 1px solid #333; border-radius: 5px; border-radius: 5px; } } <a id="button" href="">blah</a> <div id="box">blah</div>
  • 6. OOCSS becomes… .button { .skin { width: 100px; background: #ccc; height: 25px; border: 1px solid #333; } border-radius: 5px; .box { } width: 200px; height: 400px; } <a class="button skin" href="">blah</a> <div class="box skin">blah</div>
  • 7. OOCSS Use classes for styling hooks! Use ids for behavioral hooks!
  • 8. DRY CSS Don’t Repeat Yourself (Jeremy Clarke) 1. Group reusable CSS properties together 2. Use logical names for groups 3. Add selectors (not a fan of ALL-CAPS) #WHITE-BACKGROUND, .large-white-background, .medium-white-background { background-color: #fff; border-color: #bbb; }
  • 9. DRY CSS What are we still missing? • Descendent selectors break OOCSS – so what? (the “OO” part of OOCSS is garbage anyways) • No variables • No mixins • No inheritance
  • 10. LESS • variables • comparitors • mixins • type/unit checking • nesting • color functions • operations • math functions • functions • string embedding • switches • Namespaces • overloads • Javascripting!!!
  • 12. LESS: Mixins • Gives us inheritance! .rounded-corners{ border-radius: 5px; -webkit-border-radius: 5px; -moz-border-radius: 5px; } #header { .rounded-corners; }
  • 13. LESS: Mixins Parametric mixins extend this functionality .rounded-corners (@radius) { border-radius: @radius; -webkit-border-radius: @radius; -moz-border-radius: @radius; } #header { .rounded-corners(5px); }
  • 14. LESS: Mixins Parametric mixins can also have default values .rounded-corners (@radius: 5px) { border-radius: @radius; -webkit-border-radius: @radius; -moz-border-radius: @radius; } #header { .rounded-corners; }
  • 15. LESS: Nesting Nesting gives us a kind of namespacing for specificity of inheritance #header { h1 { font-size: 26px; font-weight: bold; } p{ font-size: 12px; a{ text-decoration: none; &:hover { border-width: 1px } } } }
  • 16. LESS: Nesting … and Scope @red : red; #header { @red: #BF2E1A; h1 {color: @red; // yields #BF2E1A } } h1 {color: @red; // yields red }
  • 17. LESS: Operations • add, subtract, divide and multiply properties @red: # BF2E1A; @main-margin: 4px; #footer{ color: @red + #001100; margin-left: @main-margin * 3; }
  • 18. LESS: Functions Take arguments into your mixins… .box-shadow (@x: 0, @y: 0, @blur: 1px, @color: #000) { box-shadow: @x @y @blur @color; -moz-box-shadow: @x @y @blur @color; -webkit-box-shadow: @x @y @blur @color; } .box-shadow(3px, 7px);
  • 19. LESS: Functions …or use the @arguments variable to take it all! .box-shadow (@x: 0, @y: 0, @blur: 1px, @color: #000) { box-shadow: @arguments; -moz-box-shadow: @arguments; -webkit-box-shadow: @arguments; } .box-shadow(3px, 7px);
  • 20. LESS: Imperative Programming This is a kind of switch (note the “all” selector)… .color-mixin (dark, @color) { color: darken(@color, 10%); } .color-mixin (light, @color) { color: lighten(@color, 10%); } .color-mixin (@_, @color) { display: block; }
  • 21. LESS: Imperative Programming …that we can call like so: @light-switch: light; @dark-switch: dark; .light-class { .color-mixin(@light-switch, #888); } .dark-class { .color-mixin(@dark-switch, #888); }
  • 22. LESS: Overloads “Arity” for the geeks (and Java and .NET folks) .fade-mixin (@a-color) { color: @a-color; } .fade-mixin (@a-color, @b-color) { color: fade(@a-color, @b-color); } #solid-color{ .fade-mixin(blue); } #faded-color{ .fade-mixin(blue, green); }
  • 23. LESS: Guarded mixins • uses “when” and can use “and” “,” and “not” • can also use the keywords “true” and “false” .back-white{background-color:white;} .back-black{background-color:black;} .back-red{background-color:red;} .mixin (@a) when (@a > 10), (@a < -10){ .back-white;} .mixin (@a) when (@a = 10) and (@a = true){ .back-red;} .mixin (@a) when (@a < 11) and (@a > -11) and not(@a = 10){ .back-black;}
  • 24. LESS: Guarded mixins • Comparitors can be very useful • Eg. Code reuse between media types @media: mobile; .mixin (@a) when (@media = mobile) { ... } .mixin (@a) when (@media = desktop) { ... } .mixin (@a) when (@media = print) { ... }
  • 25. LESS: Type checking • iscolor • isstring • isurl • isnumber • iskeyword .color-mixin (@a) when (isnumber(@a)) { color: @a + #001100;} .color-mixin (@a) when (iscolor(@a)) { color: @a} h1{ .color-mixin(red);} h2{ .color-mixin(#842210);}
  • 26. LESS: Unit checking • ispixel • ispercentage • isem .mixin (@a) when (ispixel(@a)) {} .mixin (@a) when (isem(@a)) {} .mixin (@a) when (ispercentage(@a)) {}
  • 27. LESS: Colour Functions lighten(@color, 10%); // return a color which is 10% *lighter* than @color darken(@color, 10%); // return a color which is 10% *darker* than @color saturate(@color, 10%); // return a color 10% *more* saturated than @color desaturate(@color, 10%); // return a color 10% *less* saturated than @color fadein(@color, 10%); // return a color 10% *less* transparent than @color fadeout(@color, 10%); // return a color 10% *more* transparent than @color fade(@color, 50%); // return @color with 50% transparency spin(@color, 10); // return a color with a 10 degree larger in hue than @color spin(@color, -10); // return a color with a 10 degree smaller hue than @color mix(@color1, @color2); // return a mix of @color1 and @color2
  • 28. LESS: Math Functions ceil floor round percentage
  • 29. LESS: Extract Colour Properties hue(@color); saturation(@color); lightness(@color); alpha(@color); eg. @old-color:#27BA19; @new-color: hsl(hue(@old-color), 45%, 90%);
  • 30. LESS: Embedding Strings • For those of you familiar with XSLT or Ruby • Use curly braces to embed the text • Use tilde ~ to escape strings that require quotes @base-url: "http://www.maximinc.com/"; @green-color: #8dc63f; #header{ background: @ green-color url("@{base-url}images/img.png"); } #footer{ filter: ~"alpha(opacity = (@{opacityPercentage}))"; }
  • 31. LESS: Javascripting!!! • Use backticks to embed your JS in the CSS • Escape strings, embed, interpolate, etc. • I haven’t played with this feature yet, but here’s an untested example: @var1: `"LESS ".toLowerCase()`; @var2: `"ooooooh".toUpperCase() + '!'`; @var3: ~`"@{var1: }" + "@{var2: }" + '!'`;
  • 32. LESS Elements • .gradient • .rotation • .bw-gradient • .scale • .bordered • .transition • .drop-shadow • .inner-shadow • .rounded • .box-shadow • .border-radius • .columns • .opacity • .translate • .transition-duration
  • 33. LESS: Precompilers LESS needs to be pre-compiled into CSS using… • simpless • less.app • lessphp • …others OR to compile on the fly while developing use… <link rel="stylesheet/less" type="text/css" href="styles.less"> <script src="http://lesscss.googlecode.com/files/less-1.0.30.min.js"></script>
  • 34. LESS: SIMPLESS • SimpLESS compiles less into minified css • works with Twitter bootstrap • self-updates • compiles on the fly (monitored polling) • multi-platform • free • open source
  • 35. LESS: SIMPLESS This is what I do… 1. I code my LESSS in a separate project 2. I let SimpLESS monitor the local file to compile CSS on the fly 3. I commit minified CSS to my main project 4. I reference the minified CSS using with the SVN version tagged on in my html <link media="screen" href=http://www.example.com/css/style.min.css?1994 type="text/css" rel="stylesheet“>
  • 36. LESS: Eclipse plugin I personally use the Xtext plugin – here are some install instructions… http://www.normalesup.org/~simonet/soft/ow/eclipse-less.en.html You can use the LESS compiler in Eclipse, however I manage all my compilation externally as I also use LESS with .NET and Classic ASP code (yes!)
  • 37. Useful links LESS http://www.lesscss.org SimpLESS http://wearekiss.com/simpless LessElements http://lesselements.com Winnipeg PHP http://winnipegphp.com Tipping Canoe http://www.tippingcanoe.com David Engel davidengel.dev@gmail.com (developed using LESS) http://www.maximinc.com