SlideShare a Scribd company logo
1 of 47
Download to read offline
CSS3 meets GWT with GSS
Closure-stylesheets in GWT
Daniel Kurka
Software Engineer

Julien Dramaix
Software Engineer

Developers
!2
!3
What is this about?
• Introduction to Closure-stylesheets (GSS)
- Variables
- Functions
- Mixins
- Conditionals
- Linting
- RTL flipping

• Integration with GWT
• Timeline
• Demo

!4
DRY
http://farm3.staticflickr.com/2663/4241456606_be6fcc8b4e_o.jpg

!5
http://upload.wikimedia.org/wikipedia/commons/1/19/Lego_mess.jpg

!6
CSS is missing things
• variables
- repeating tokens in CSS files

• functions
- no way to express derived parameters

• macros
- duplicating code common code blocks

!7
Closure-stylesheets
• are an extension to CSS
• write GSS, compile to CSS
• adding variables, conditionals, mixing
• support minification, linting, RTL flipping, renaming

!8
Examples

!9
Variables
@def BG_COLOR

rgb(235, 239, 249);	

!
@def DIALOG_BORDER_COLOR
@def DIALOG_BG_COLOR

rgb(107, 144, 218);	
BG_COLOR;	

!
body {	
background-color: BG_COLOR;	
}	

!
.dialog {	
background-color: DIALOG_BG_COLOR;	
border: 1px solid DIALOG_BORDER_COLOR;	
}

!10
compiles to
body {	
background-color: #ebeff9;	
}	
.dialog {	
background-color: #ebeff9;	
border: 1px solid #6b90da;	
}

!11
Functions
• Several arithmetic functions
- add()
- sub()
- mult()
- divide()
- min()
- max()

• Variable number of arguments
• Arguments may be purely numeric or need to have the same CSS unit
• multiply and divide only allow a CSS unit for the first parameter
• not as flexible as CSS calc, but yields more maintainable stylesheets

!12
Functions
@def LEFT_HAND_NAV_WIDTH
@def LEFT_HAND_NAV_PADDING

180px;	
3px;	

!
.left_hand_nav {	
position: absolute;	
width: LEFT_HAND_NAV_WIDTH;	
padding: LEFT_HAND_NAV_PADDING;	
}	

!
.content {	
position: absolute;	
margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */	
LEFT_HAND_NAV_WIDTH,	
LEFT_HAND_NAV_PADDING); /* padding right */	
}

!13
compiles to
.left_hand_nav {	
position: absolute;	
width: 180px;	
padding: 3px;	
}	

!
.content {	
position: absolute;	
margin-left: 186px;	
}

!14
Functions
• blendColorsHsb(startColor, endColor) blends using HSB values
• blendColorsRgb(startColor, endColor) blends using RGB values
• makeMutedColor(backgroundColor, foregroundColor [, saturationLoss])
• addHsbToCssColor(baseColor, hueToAdd, saturationToAdd,
brightnessToAdd)
• makeContrastingColor(color, similarityIndex)
• adjustBrightness(color, brightness)
• ….

!15
Functions - selectFrom
/* Implies MYDEF = FOO ? BAR : BAZ; */	
@def MYDEF selectFrom(FOO, BAR, BAZ);	

!
/* @def FOO true; to have the effect of @def MYDEF = BAR. */

!16
Providing your own functions
• Implement GssFunctionMapProvider
• pass “--gss-function-map-provider” to the compiler

!17
Mixins
• reuse a list of parameterized declarations
• declaration
• a mixing can be used anywhere instead of a declaration

!18
Mixins
@defmixin size(WIDTH, HEIGHT) {	
width: WIDTH;	
height: HEIGHT;	
}	

!
.logo {	
@mixin size(150px, 55px);	
background-image: url('http://www.google.com/images/logo_sm.gif');	
}

!19
compiles to
.logo {	
width: 150px;	
height: 55px;	
background-image: url('http://www.google.com/images/logo_sm.gif');	
}

!20
Mixins - for browser specific code
@defmixin gradient(POS, HSL1, HSL2, HSL3, COLOR, FALLBACK_COLOR) {	
background-color: FALLBACK_COLOR; /* fallback color if gradients are not supported */	
background-image: -webkit-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR);
/* Chrome 10+,Safari 5.1+ */	
/* @alternate */ 	
background-image: -moz-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR); 	
/* FF3.6+ */	
/* @alternate */ 	
background-image: -ms-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR); /* IE10 */	
/* @alternate */ 	
background-image: -o-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR);
	
/* Opera 11.10+ */	
}	

!

.header {	
@mixin gradient(top, 0%, 50%, 70%, #cc0000, #f07575);	
}

!21
Mixins - for browser specific code
.header {	
background-color:
background-image:
background-image:
background-image:
background-image:
}

#f07575;	
-webkit-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000);	
-moz-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000);	
-ms-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000);	
-o-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000);	

!22
Conditionals
• defining variables in conditionals

!23
Conditionals
@if (BROWSER_IE) {	
@if (BROWSER_IE6) {	
@def GOOG_INLINE_BLOCK_DISPLAY
} @elseif (BROWSER_IE7) {	
@def GOOG_INLINE_BLOCK_DISPLAY
} @else {	
@def GOOG_INLINE_BLOCK_DISPLAY
}	
} @elseif (BROWSER_FF2) {	
@def GOOG_INLINE_BLOCK_DISPLAY
} @else {	
@def GOOG_INLINE_BLOCK_DISPLAY
}	

inline;	
inline;	
inline-block;	

-moz-inline-box;	
inline-block;	

!
.goog-inline-block {	
position: relative;	
display: GOOG_INLINE_BLOCK_DISPLAY;	
}

!24
Conditionals
• “java -jar closure-stylesheets.jar --define BROWSER_FF2 --pretty-print
conditionals-example.gss”
	
.goog-inline-block {	
position: relative;	
display: -moz-inline-box;	
}	

• “java -jar closure-stylesheets.jar --pretty-print conditionals-example.gss”
	
.goog-inline-block {	
position: relative;	
display: inline-box;	
}	

!25
Linting
• check your CSS for errors
• will fail the compile with an error message

!26
Linting
.logo {	
width: 150px;	
height: 55px;	
background-image: urel('http://www.google.com/images/logo_sm.gif');	
border-color: #DCDCDC;	
border-color: rgba(0, 0, 0, 0.1);	
}

!27
Linting
.logo {	
width: 150px;	
height: 55px;	
background-image: urel('http://www.google.com/images/logo_sm.gif');	
border-color: #DCDCDC;	
border-color: rgba(0, 0, 0, 0.1);	
}	

!
Unknown function "urel" in linting-example.gss at line 4 column 21:	
background-image: urel('http://www.google.com/images/logo_sm.gif');	
^	
Detected multiple identical, non-alternate declarations in the same
ruleset.	
If this is intentional please use the /* @alternate */ annotation.	
border-color:[rgba(0,0,0,0.1)] in linting-example.gss at line 7 column 1:	
}	
^	
2 error(s)

!28
RTL flipping
.logo {	
margin-left: 10px;	
}	

!
.shortcut_accelerator {	
/* Keyboard shortcuts are untranslated; always left-to-right. */	
/* @noflip */ direction: ltr;	
border-right: 2px solid #ccc;	
padding: 0 2px 0 4px;	
}	

!29
RTL flipping
.logo {	
margin-right: 10px;	
}	

!
.shortcut_accelerator {	
direction: ltr;	
border-left: 2px solid #ccc;	
padding: 0 4px 0 2px;	
}	

!30
GSS

!31
Integration with GWT
• Why ?
- Closure-stylesheets are powerful
- easier to maintain CSS
- GWT needs better CSS3 support

• What does it look like?
- A new GSSResource
- similar to CSSResource

!32
CSS: application.gss
@def PADDING_RIGHT 50px;	
@def PADDING_LEFT 50px;	

!
@defmixin size(WIDTH, HEIGHT) {	
width: WIDTH;	
height: HEIGHT;	
}	

!
.header, span[data-role^="header"] {	
display: block;	
@mixin size(150px, 50px);	
}	

!
.header-with-padding {	
@mixin size(add(PADDING_RIGHT, 150px, PADDING_LEFT), 50px);	
padding-right: PADDING_RIGHT;	
}

!33
Java: define GssResource
public interface ApplicationResources extends ClientBundle {	

!
public interface ApplicationGss extends GssResource {	
int paddingRight();	
	
String header();	

!
@ClassName("header-with-padding")	
String headerWithPadding();	
}	

!
@Source("application.gss")	
public ApplicationGss style();	
}

!34
Usage:
ApplicationResources resources = GWT.create(ApplicationResources.class);	
ApplicationGss style = resources.style();	
style.ensureInjected();	

!
// ...	
myWidget.addStyleName(style.header());

!35
CssResource features
• @sprite
• @eval
• value function

!36
Image sprite (@sprite)
.addIcon {	
gwt-sprite: 'addIcon';	
}

!37
Runtime substitution (@eval)
@def BLACK eval(‘mypackage.GssSampleApplication.black()’);	

!
.black {	
color: eval('mypackage.GssSampleApplication.black()');	
}

!38
Value function
@def ICON_WIDTH value('addIcon.getWidth', 'px');	

!39
How far is this done?
• supports all Closure-stylesheet features
• supported CssResource features
- image sprites
- runtime substitution
- value function
- RTL support

!40
What is missing?
• conditionals based on permutations
!
@if user.agent safari {	
/* ... */ 	
}	

!
@if locale en { 	
/* ... */ 	
}

!41
Roadmap
• Ready to use, but there might still be issues
• please test & report issues at: https://github.com/jDramaix/gss.gwt/
issues
• Expect missing user agent conditionals in Q1
• Unclear: How will CssResource transition look like
• If everything goes smoothly, expect GssResource in GWT 3.0, but you can
use it right now!

!42
Demo

!43
Summary
• simple and maintainable CSS with Closure-stylesheets
- many exciting features
- widely used inside of Google

• GssResource
- brings Closure-stylesheets to GWT, aka CssResource for CSS
- brings all CSS3 features to GWT
- thanks to Julien Dramaix for this big contribution

• Roadmap
- Test and report bugs!

!44
Questions?

!45
Julien Dramaix
gplus: https://plus.google.com/+JulienDramaix
twitter: @jDramaix
Daniel Kurka
www.m-gwt.com

!

gplus: daniel-kurka.de/+

!

twitter: @dankurka

More Related Content

What's hot

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
 
Css week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandourCss week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandourOsama Ghandour Geris
 
Css week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandourCss week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandourOsama Ghandour Geris
 
Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Tahmina Khatoon
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockMarco Pinheiro
 
HTML5 and CSS3 for Teachers
HTML5 and CSS3 for TeachersHTML5 and CSS3 for Teachers
HTML5 and CSS3 for TeachersJason Hando
 

What's hot (7)

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
 
Css week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandourCss week11 2019 2020 for g10 by eng.osama ghandour
Css week11 2019 2020 for g10 by eng.osama ghandour
 
Css week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandourCss week11 2020 2021 for g10 by eng.osama ghandour
Css week11 2020 2021 for g10 by eng.osama ghandour
 
Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)Syntactically awesome stylesheets (Sass)
Syntactically awesome stylesheets (Sass)
 
SASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, GreensockSASS, Compass, Gulp, Greensock
SASS, Compass, Gulp, Greensock
 
SASS - CSS with Superpower
SASS - CSS with SuperpowerSASS - CSS with Superpower
SASS - CSS with Superpower
 
HTML5 and CSS3 for Teachers
HTML5 and CSS3 for TeachersHTML5 and CSS3 for Teachers
HTML5 and CSS3 for Teachers
 

Similar to CSS3 meets GWT with GSS

CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassLucien Lee
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid PrototypingEven Wu
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageKatsunori Tanaka
 
It's a Mod World - A Practical Guide to Rocking Modernizr
It's a Mod World - A Practical Guide to Rocking ModernizrIt's a Mod World - A Practical Guide to Rocking Modernizr
It's a Mod World - A Practical Guide to Rocking ModernizrMichael Enslow
 
New Elements & Features in CSS3
New Elements & Features in CSS3New Elements & Features in CSS3
New Elements & Features in CSS3Jamshid Hashimi
 
[WebVisions 2010] CSS3 Workshop (Afternoon)
[WebVisions 2010] CSS3 Workshop (Afternoon)[WebVisions 2010] CSS3 Workshop (Afternoon)
[WebVisions 2010] CSS3 Workshop (Afternoon)Christopher Schmitt
 
Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan Stefan Bauer
 
CSS vs. JavaScript - Trust vs. Control
CSS vs. JavaScript - Trust vs. ControlCSS vs. JavaScript - Trust vs. Control
CSS vs. JavaScript - Trust vs. ControlChristian Heilmann
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPressJames Steinbach
 
Front-End Frameworks: a quick overview
Front-End Frameworks: a quick overviewFront-End Frameworks: a quick overview
Front-End Frameworks: a quick overviewDiacode
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)emrox
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFxStefan Bauer
 
LESS is More
LESS is MoreLESS is More
LESS is Morejsmith92
 
Implementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 WorkshopImplementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 WorkshopShoshi Roberts
 

Similar to CSS3 meets GWT with GSS (20)

CSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & CompassCSS 開發加速指南-Sass & Compass
CSS 開發加速指南-Sass & Compass
 
CSS and CSS3
CSS and CSS3CSS and CSS3
CSS and CSS3
 
Rapid Prototyping
Rapid PrototypingRapid Prototyping
Rapid Prototyping
 
CSS3 3D Workshop
CSS3 3D WorkshopCSS3 3D Workshop
CSS3 3D Workshop
 
CSS3
CSS3CSS3
CSS3
 
LESS : The dynamic stylesheet language
LESS : The dynamic stylesheet languageLESS : The dynamic stylesheet language
LESS : The dynamic stylesheet language
 
It's a Mod World - A Practical Guide to Rocking Modernizr
It's a Mod World - A Practical Guide to Rocking ModernizrIt's a Mod World - A Practical Guide to Rocking Modernizr
It's a Mod World - A Practical Guide to Rocking Modernizr
 
New Elements & Features in CSS3
New Elements & Features in CSS3New Elements & Features in CSS3
New Elements & Features in CSS3
 
[WebVisions 2010] CSS3 Workshop (Afternoon)
[WebVisions 2010] CSS3 Workshop (Afternoon)[WebVisions 2010] CSS3 Workshop (Afternoon)
[WebVisions 2010] CSS3 Workshop (Afternoon)
 
Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan Create SASSY Web Parts - SPSMilan
Create SASSY Web Parts - SPSMilan
 
CSS vs. JavaScript - Trust vs. Control
CSS vs. JavaScript - Trust vs. ControlCSS vs. JavaScript - Trust vs. Control
CSS vs. JavaScript - Trust vs. Control
 
From CSS to Sass in WordPress
From CSS to Sass in WordPressFrom CSS to Sass in WordPress
From CSS to Sass in WordPress
 
Front-End Frameworks: a quick overview
Front-End Frameworks: a quick overviewFront-End Frameworks: a quick overview
Front-End Frameworks: a quick overview
 
Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)Sass & Compass (Barcamp Stuttgart 2012)
Sass & Compass (Barcamp Stuttgart 2012)
 
Css animation
Css animationCss animation
Css animation
 
Create SASSy web parts in SPFx
Create SASSy web parts in SPFxCreate SASSy web parts in SPFx
Create SASSy web parts in SPFx
 
[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX[Bauer] SASSy web parts with SPFX
[Bauer] SASSy web parts with SPFX
 
[heweb11] CSS3 Makeover
[heweb11] CSS3 Makeover[heweb11] CSS3 Makeover
[heweb11] CSS3 Makeover
 
LESS is More
LESS is MoreLESS is More
LESS is More
 
Implementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 WorkshopImplementing Awesome: An HTML5/CSS3 Workshop
Implementing Awesome: An HTML5/CSS3 Workshop
 

Recently uploaded

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
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
 

Recently uploaded (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
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
 

CSS3 meets GWT with GSS

  • 1. CSS3 meets GWT with GSS Closure-stylesheets in GWT Daniel Kurka Software Engineer Julien Dramaix Software Engineer Developers
  • 2. !2
  • 3. !3
  • 4. What is this about? • Introduction to Closure-stylesheets (GSS) - Variables - Functions - Mixins - Conditionals - Linting - RTL flipping • Integration with GWT • Timeline • Demo !4
  • 7. CSS is missing things • variables - repeating tokens in CSS files • functions - no way to express derived parameters • macros - duplicating code common code blocks !7
  • 8. Closure-stylesheets • are an extension to CSS • write GSS, compile to CSS • adding variables, conditionals, mixing • support minification, linting, RTL flipping, renaming !8
  • 10. Variables @def BG_COLOR rgb(235, 239, 249); ! @def DIALOG_BORDER_COLOR @def DIALOG_BG_COLOR rgb(107, 144, 218); BG_COLOR; ! body { background-color: BG_COLOR; } ! .dialog { background-color: DIALOG_BG_COLOR; border: 1px solid DIALOG_BORDER_COLOR; } !10
  • 11. compiles to body { background-color: #ebeff9; } .dialog { background-color: #ebeff9; border: 1px solid #6b90da; } !11
  • 12. Functions • Several arithmetic functions - add() - sub() - mult() - divide() - min() - max() • Variable number of arguments • Arguments may be purely numeric or need to have the same CSS unit • multiply and divide only allow a CSS unit for the first parameter • not as flexible as CSS calc, but yields more maintainable stylesheets !12
  • 13. Functions @def LEFT_HAND_NAV_WIDTH @def LEFT_HAND_NAV_PADDING 180px; 3px; ! .left_hand_nav { position: absolute; width: LEFT_HAND_NAV_WIDTH; padding: LEFT_HAND_NAV_PADDING; } ! .content { position: absolute; margin-left: add(LEFT_HAND_NAV_PADDING, /* padding left */ LEFT_HAND_NAV_WIDTH, LEFT_HAND_NAV_PADDING); /* padding right */ } !13
  • 14. compiles to .left_hand_nav { position: absolute; width: 180px; padding: 3px; } ! .content { position: absolute; margin-left: 186px; } !14
  • 15. Functions • blendColorsHsb(startColor, endColor) blends using HSB values • blendColorsRgb(startColor, endColor) blends using RGB values • makeMutedColor(backgroundColor, foregroundColor [, saturationLoss]) • addHsbToCssColor(baseColor, hueToAdd, saturationToAdd, brightnessToAdd) • makeContrastingColor(color, similarityIndex) • adjustBrightness(color, brightness) • …. !15
  • 16. Functions - selectFrom /* Implies MYDEF = FOO ? BAR : BAZ; */ @def MYDEF selectFrom(FOO, BAR, BAZ); ! /* @def FOO true; to have the effect of @def MYDEF = BAR. */ !16
  • 17. Providing your own functions • Implement GssFunctionMapProvider • pass “--gss-function-map-provider” to the compiler !17
  • 18. Mixins • reuse a list of parameterized declarations • declaration • a mixing can be used anywhere instead of a declaration !18
  • 19. Mixins @defmixin size(WIDTH, HEIGHT) { width: WIDTH; height: HEIGHT; } ! .logo { @mixin size(150px, 55px); background-image: url('http://www.google.com/images/logo_sm.gif'); } !19
  • 20. compiles to .logo { width: 150px; height: 55px; background-image: url('http://www.google.com/images/logo_sm.gif'); } !20
  • 21. Mixins - for browser specific code @defmixin gradient(POS, HSL1, HSL2, HSL3, COLOR, FALLBACK_COLOR) { background-color: FALLBACK_COLOR; /* fallback color if gradients are not supported */ background-image: -webkit-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR); /* Chrome 10+,Safari 5.1+ */ /* @alternate */ background-image: -moz-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR); /* FF3.6+ */ /* @alternate */ background-image: -ms-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR); /* IE10 */ /* @alternate */ background-image: -o-linear-gradient(POS, hsl(HSL1, HSL2, HSL3), COLOR); /* Opera 11.10+ */ } ! .header { @mixin gradient(top, 0%, 50%, 70%, #cc0000, #f07575); } !21
  • 22. Mixins - for browser specific code .header { background-color: background-image: background-image: background-image: background-image: } #f07575; -webkit-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000); -moz-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000); -ms-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000); -o-linear-gradient(top,hsl(0%,50%,70%) ,#cc0000); !22
  • 24. Conditionals @if (BROWSER_IE) { @if (BROWSER_IE6) { @def GOOG_INLINE_BLOCK_DISPLAY } @elseif (BROWSER_IE7) { @def GOOG_INLINE_BLOCK_DISPLAY } @else { @def GOOG_INLINE_BLOCK_DISPLAY } } @elseif (BROWSER_FF2) { @def GOOG_INLINE_BLOCK_DISPLAY } @else { @def GOOG_INLINE_BLOCK_DISPLAY } inline; inline; inline-block; -moz-inline-box; inline-block; ! .goog-inline-block { position: relative; display: GOOG_INLINE_BLOCK_DISPLAY; } !24
  • 25. Conditionals • “java -jar closure-stylesheets.jar --define BROWSER_FF2 --pretty-print conditionals-example.gss” .goog-inline-block { position: relative; display: -moz-inline-box; } • “java -jar closure-stylesheets.jar --pretty-print conditionals-example.gss” .goog-inline-block { position: relative; display: inline-box; } !25
  • 26. Linting • check your CSS for errors • will fail the compile with an error message !26
  • 27. Linting .logo { width: 150px; height: 55px; background-image: urel('http://www.google.com/images/logo_sm.gif'); border-color: #DCDCDC; border-color: rgba(0, 0, 0, 0.1); } !27
  • 28. Linting .logo { width: 150px; height: 55px; background-image: urel('http://www.google.com/images/logo_sm.gif'); border-color: #DCDCDC; border-color: rgba(0, 0, 0, 0.1); } ! Unknown function "urel" in linting-example.gss at line 4 column 21: background-image: urel('http://www.google.com/images/logo_sm.gif'); ^ Detected multiple identical, non-alternate declarations in the same ruleset. If this is intentional please use the /* @alternate */ annotation. border-color:[rgba(0,0,0,0.1)] in linting-example.gss at line 7 column 1: } ^ 2 error(s) !28
  • 29. RTL flipping .logo { margin-left: 10px; } ! .shortcut_accelerator { /* Keyboard shortcuts are untranslated; always left-to-right. */ /* @noflip */ direction: ltr; border-right: 2px solid #ccc; padding: 0 2px 0 4px; } !29
  • 30. RTL flipping .logo { margin-right: 10px; } ! .shortcut_accelerator { direction: ltr; border-left: 2px solid #ccc; padding: 0 4px 0 2px; } !30
  • 32. Integration with GWT • Why ? - Closure-stylesheets are powerful - easier to maintain CSS - GWT needs better CSS3 support • What does it look like? - A new GSSResource - similar to CSSResource !32
  • 33. CSS: application.gss @def PADDING_RIGHT 50px; @def PADDING_LEFT 50px; ! @defmixin size(WIDTH, HEIGHT) { width: WIDTH; height: HEIGHT; } ! .header, span[data-role^="header"] { display: block; @mixin size(150px, 50px); } ! .header-with-padding { @mixin size(add(PADDING_RIGHT, 150px, PADDING_LEFT), 50px); padding-right: PADDING_RIGHT; } !33
  • 34. Java: define GssResource public interface ApplicationResources extends ClientBundle { ! public interface ApplicationGss extends GssResource { int paddingRight(); String header(); ! @ClassName("header-with-padding") String headerWithPadding(); } ! @Source("application.gss") public ApplicationGss style(); } !34
  • 35. Usage: ApplicationResources resources = GWT.create(ApplicationResources.class); ApplicationGss style = resources.style(); style.ensureInjected(); ! // ... myWidget.addStyleName(style.header()); !35
  • 36. CssResource features • @sprite • @eval • value function !36
  • 37. Image sprite (@sprite) .addIcon { gwt-sprite: 'addIcon'; } !37
  • 38. Runtime substitution (@eval) @def BLACK eval(‘mypackage.GssSampleApplication.black()’); ! .black { color: eval('mypackage.GssSampleApplication.black()'); } !38
  • 39. Value function @def ICON_WIDTH value('addIcon.getWidth', 'px'); !39
  • 40. How far is this done? • supports all Closure-stylesheet features • supported CssResource features - image sprites - runtime substitution - value function - RTL support !40
  • 41. What is missing? • conditionals based on permutations ! @if user.agent safari { /* ... */ } ! @if locale en { /* ... */ } !41
  • 42. Roadmap • Ready to use, but there might still be issues • please test & report issues at: https://github.com/jDramaix/gss.gwt/ issues • Expect missing user agent conditionals in Q1 • Unclear: How will CssResource transition look like • If everything goes smoothly, expect GssResource in GWT 3.0, but you can use it right now! !42
  • 44. Summary • simple and maintainable CSS with Closure-stylesheets - many exciting features - widely used inside of Google • GssResource - brings Closure-stylesheets to GWT, aka CssResource for CSS - brings all CSS3 features to GWT - thanks to Julien Dramaix for this big contribution • Roadmap - Test and report bugs! !44