SlideShare uma empresa Scribd logo
1 de 22
Styling your projects!
Leveraging css and r/sass in R projects
16/04/2019 | PEDRO SILVA | APPSILON DAY
Agenda
● What is css?
● Adding css to shiny
● sass vs css. Why use SASS?
● How can you use sass in r (r/sass)
● Resource list
● Bonus: Non well known selectors
What is css?
What is css (Cascading Style Sheets)?
● Describes how HTML elements are to be
displayed
● Instructions are called statements.
Statements do two things:
○ Identify the elements in an HTML document
that it affects
○ Gives the browser rules on how to draw these
elements
● It can control the layout of multiple web
pages all at once (CSS saves a lot of work!)
Adding css to shiny
Adding css to shiny
● There are 3 main ways you can add css
styling to your code:
○ Add styling directly to HTML tags
○ Add CSS to your HTML header
○ Add style sheets with the www
directory
Adding css to shiny
1. Add styling directly to HTML tags
✘ Easy to lose track of in large projects
✘ Impossible to reuse code in different tags
Adding css to shiny
2. Add CSS to your HTML header
✔ Allows code to be reused by using selectors
✘ Rules cannot be cached since we are still declaring styles in the code
Adding css to shiny
3. Add style sheets with the www directory
✔ Code can be reused
✔ Allows caching
✔ Allows multiple files to be included
✘ Still has all the limitations for CSS
SASS vs CSS
SASS vs CSS
● SASS (Systematically Awesome Style Sheets) is a pre-processor of CSS
(SASS code always compiles into CSS).
SASS CSS
Object oriented Statement oriented
Allows nesting .class { p {} } No nesting
Allows variables $var = 5 No variable declaration (yet)
Allows properties to be defined outside of
SASS objects
Code is not reusable (inside CSS)
SASS: Mixins
● A Mixin is a block of code that lets us group CSS declarations we may
reuse throughout our site.
Example, displaying an HTML element as a Flex element:
Creating a Mixin:
Using a Mixin:
SASS: Functions
● SASS allows you to use functions that can be evaluated inside elements.
Example, function that defines the width of an element:
Generated CSS:
SASS: Loops
● Code can also be generated in a loop:
Generated CSS:
How can you use sass in r?
(r/sass)
How can you use sass in r (r/sass)
● Use a library!
● r/sass implements a CSS preprocessor, letting R developers use SASS to
generate dynamic style sheets.
● sass() can take a SASS string or file and returns a string of compiled CSS
main.scss
config.scss
Resources
● SASS vignette
https://rstudio.github.io/sass/articles/sass.html
● R/SASS Repository
https://github.com/rstudio/sass
● Basics on CSS
https://www.w3schools.com/css/default.asp
● Dinamic CSS generation in R
https://gallery.shinyapps.io/sass-theme/
appsilon.com
Questions?
BONUS: Selectors
you might not know
about
Bonus: Selectors
* Targets EVERY element on the page
X[attribute="foo"] {} Targets elements with a specific attribute
X ~ Y and X + Y Targets Y elements that have a sibling X:
X ~ Y {} Y elements that have an X before them.
X + Y {} Y elements that have an X IMMEDIATELY before.
X:first-of-type {} and X:last-of-type {} First or last X in a container
X:not(selector) X that is not also selector
Bonus: Selectors
X:nth-of-type(condition) Elements in a specific positions inside their container.
Condition can be a few different values:
odd or even will target all odd or even elements
x:nth-of-type(2) will target elements on a specific position
an + b a is a cycle size, n is a counter (starts at 0), and b is an offset value:
x:nth-of-type(3n+0) elements whose index is a multiple of 3
x:nth-of-type(4n+1) every 4th element starting at the first one
Online calculator: https://css-tricks.com/examples/nth-child-tester/

Mais conteúdo relacionado

Semelhante a Styling your projects! leveraging css and r sass in r projects

The CSS Handbook
The CSS HandbookThe CSS Handbook
The CSS Handbookjackchenvlo
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS ImplementationAmey Parab
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSSanjoy Kr. Paul
 
SPS Oslo - Stop your SharePoint CSS becoming a di-sass-ter today!
SPS Oslo - Stop your SharePoint CSS becoming a di-sass-ter today!SPS Oslo - Stop your SharePoint CSS becoming a di-sass-ter today!
SPS Oslo - Stop your SharePoint CSS becoming a di-sass-ter today!Stefan Bauer
 
Sass:-Syntactically Awesome Stylesheet by Shafeeq
Sass:-Syntactically Awesome Stylesheet by ShafeeqSass:-Syntactically Awesome Stylesheet by Shafeeq
Sass:-Syntactically Awesome Stylesheet by ShafeeqDignitasDigital1
 
The sass way - Yatendra Bhardwaj
The sass way - Yatendra BhardwajThe sass way - Yatendra Bhardwaj
The sass way - Yatendra BhardwajYatendra Bhardwaj
 
Get Started With Tailwind React and Create Beautiful Apps.pdf
Get Started With Tailwind React and Create Beautiful Apps.pdfGet Started With Tailwind React and Create Beautiful Apps.pdf
Get Started With Tailwind React and Create Beautiful Apps.pdfRonDosh
 
Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksAndolasoft Inc
 
Css training tutorial css3 & css4 essentials
Css training tutorial css3 & css4 essentialsCss training tutorial css3 & css4 essentials
Css training tutorial css3 & css4 essentialsQA TrainingHub
 
CSS Interview Questions for Fresher and Experience
CSS Interview Questions for Fresher and Experience CSS Interview Questions for Fresher and Experience
CSS Interview Questions for Fresher and Experience Hitesh Kumar
 
Revamp Your Stylesheet
Revamp Your StylesheetRevamp Your Stylesheet
Revamp Your StylesheetGary Homidas
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Erin M. Kidwell
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sasschriseppstein
 

Semelhante a Styling your projects! leveraging css and r sass in r projects (20)

The CSS Handbook
The CSS HandbookThe CSS Handbook
The CSS Handbook
 
SCSS Implementation
SCSS ImplementationSCSS Implementation
SCSS Implementation
 
Structuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSSStructuring your CSS for maintainability: rules and guile lines to write CSS
Structuring your CSS for maintainability: rules and guile lines to write CSS
 
SPS Oslo - Stop your SharePoint CSS becoming a di-sass-ter today!
SPS Oslo - Stop your SharePoint CSS becoming a di-sass-ter today!SPS Oslo - Stop your SharePoint CSS becoming a di-sass-ter today!
SPS Oslo - Stop your SharePoint CSS becoming a di-sass-ter today!
 
Sass:-Syntactically Awesome Stylesheet by Shafeeq
Sass:-Syntactically Awesome Stylesheet by ShafeeqSass:-Syntactically Awesome Stylesheet by Shafeeq
Sass:-Syntactically Awesome Stylesheet by Shafeeq
 
UNIT 3.ppt
UNIT 3.pptUNIT 3.ppt
UNIT 3.ppt
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Rational HATS and CSS
Rational HATS and CSSRational HATS and CSS
Rational HATS and CSS
 
The sass way - Yatendra Bhardwaj
The sass way - Yatendra BhardwajThe sass way - Yatendra Bhardwaj
The sass way - Yatendra Bhardwaj
 
Get Started With Tailwind React and Create Beautiful Apps.pdf
Get Started With Tailwind React and Create Beautiful Apps.pdfGet Started With Tailwind React and Create Beautiful Apps.pdf
Get Started With Tailwind React and Create Beautiful Apps.pdf
 
INTRODUCTIONS OF CSS
INTRODUCTIONS OF CSSINTRODUCTIONS OF CSS
INTRODUCTIONS OF CSS
 
Organize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS TricksOrganize Your Website With Advanced CSS Tricks
Organize Your Website With Advanced CSS Tricks
 
Css training tutorial css3 & css4 essentials
Css training tutorial css3 & css4 essentialsCss training tutorial css3 & css4 essentials
Css training tutorial css3 & css4 essentials
 
CSS Interview Questions for Fresher and Experience
CSS Interview Questions for Fresher and Experience CSS Interview Questions for Fresher and Experience
CSS Interview Questions for Fresher and Experience
 
Srijan presentation on CSS
Srijan presentation on CSSSrijan presentation on CSS
Srijan presentation on CSS
 
Make your CSS beautiful again
Make your CSS beautiful againMake your CSS beautiful again
Make your CSS beautiful again
 
Css and its future
Css and its futureCss and its future
Css and its future
 
Revamp Your Stylesheet
Revamp Your StylesheetRevamp Your Stylesheet
Revamp Your Stylesheet
 
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
Girl Develop It Cincinnati: Intro to HTML/CSS Class 4
 
Authoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & SassAuthoring Stylesheets with Compass & Sass
Authoring Stylesheets with Compass & Sass
 

Mais de Appsilon Data Science

User! 2019 best practices for building shiny enterprise applications
User! 2019  best practices for building shiny enterprise applicationsUser! 2019  best practices for building shiny enterprise applications
User! 2019 best practices for building shiny enterprise applicationsAppsilon Data Science
 
Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)Appsilon Data Science
 
Successful Machine Learning projects in Fintech
Successful Machine Learning projects in FintechSuccessful Machine Learning projects in Fintech
Successful Machine Learning projects in FintechAppsilon Data Science
 
Tech Talk - Overview of Dash framework for building dashboards
Tech Talk - Overview of Dash framework for building dashboardsTech Talk - Overview of Dash framework for building dashboards
Tech Talk - Overview of Dash framework for building dashboardsAppsilon Data Science
 
Tech talk - Data Validation with assertr
Tech talk - Data Validation with assertrTech talk - Data Validation with assertr
Tech talk - Data Validation with assertrAppsilon Data Science
 
Marek Rogala's Talk at User2017 on shiny.collections
Marek Rogala's Talk at User2017 on shiny.collectionsMarek Rogala's Talk at User2017 on shiny.collections
Marek Rogala's Talk at User2017 on shiny.collectionsAppsilon Data Science
 
Scaling Shiny Apps - EARL 2017 San Francisco
Scaling Shiny Apps - EARL 2017 San Francisco Scaling Shiny Apps - EARL 2017 San Francisco
Scaling Shiny Apps - EARL 2017 San Francisco Appsilon Data Science
 

Mais de Appsilon Data Science (10)

User! 2019 best practices for building shiny enterprise applications
User! 2019  best practices for building shiny enterprise applicationsUser! 2019  best practices for building shiny enterprise applications
User! 2019 best practices for building shiny enterprise applications
 
SCRUM in Data Science
SCRUM in Data ScienceSCRUM in Data Science
SCRUM in Data Science
 
Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)Introduction to Generative Adversarial Networks (GANs)
Introduction to Generative Adversarial Networks (GANs)
 
Successful Machine Learning projects in Fintech
Successful Machine Learning projects in FintechSuccessful Machine Learning projects in Fintech
Successful Machine Learning projects in Fintech
 
Making shiny shine brighter
Making shiny shine brighterMaking shiny shine brighter
Making shiny shine brighter
 
Tech Talk - Overview of Dash framework for building dashboards
Tech Talk - Overview of Dash framework for building dashboardsTech Talk - Overview of Dash framework for building dashboards
Tech Talk - Overview of Dash framework for building dashboards
 
Tech talk - Data Validation with assertr
Tech talk - Data Validation with assertrTech talk - Data Validation with assertr
Tech talk - Data Validation with assertr
 
Marek Rogala's Talk at User2017 on shiny.collections
Marek Rogala's Talk at User2017 on shiny.collectionsMarek Rogala's Talk at User2017 on shiny.collections
Marek Rogala's Talk at User2017 on shiny.collections
 
Scaling Shiny Apps - EARL 2017 San Francisco
Scaling Shiny Apps - EARL 2017 San Francisco Scaling Shiny Apps - EARL 2017 San Francisco
Scaling Shiny Apps - EARL 2017 San Francisco
 
Open Data - Rada Innowacyjności
Open Data - Rada InnowacyjnościOpen Data - Rada Innowacyjności
Open Data - Rada Innowacyjności
 

Último

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 

Último (20)

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 

Styling your projects! leveraging css and r sass in r projects

  • 1. Styling your projects! Leveraging css and r/sass in R projects 16/04/2019 | PEDRO SILVA | APPSILON DAY
  • 2. Agenda ● What is css? ● Adding css to shiny ● sass vs css. Why use SASS? ● How can you use sass in r (r/sass) ● Resource list ● Bonus: Non well known selectors
  • 4. What is css (Cascading Style Sheets)? ● Describes how HTML elements are to be displayed ● Instructions are called statements. Statements do two things: ○ Identify the elements in an HTML document that it affects ○ Gives the browser rules on how to draw these elements ● It can control the layout of multiple web pages all at once (CSS saves a lot of work!)
  • 6. Adding css to shiny ● There are 3 main ways you can add css styling to your code: ○ Add styling directly to HTML tags ○ Add CSS to your HTML header ○ Add style sheets with the www directory
  • 7. Adding css to shiny 1. Add styling directly to HTML tags ✘ Easy to lose track of in large projects ✘ Impossible to reuse code in different tags
  • 8. Adding css to shiny 2. Add CSS to your HTML header ✔ Allows code to be reused by using selectors ✘ Rules cannot be cached since we are still declaring styles in the code
  • 9. Adding css to shiny 3. Add style sheets with the www directory ✔ Code can be reused ✔ Allows caching ✔ Allows multiple files to be included ✘ Still has all the limitations for CSS
  • 11. SASS vs CSS ● SASS (Systematically Awesome Style Sheets) is a pre-processor of CSS (SASS code always compiles into CSS). SASS CSS Object oriented Statement oriented Allows nesting .class { p {} } No nesting Allows variables $var = 5 No variable declaration (yet) Allows properties to be defined outside of SASS objects Code is not reusable (inside CSS)
  • 12. SASS: Mixins ● A Mixin is a block of code that lets us group CSS declarations we may reuse throughout our site. Example, displaying an HTML element as a Flex element: Creating a Mixin: Using a Mixin:
  • 13. SASS: Functions ● SASS allows you to use functions that can be evaluated inside elements. Example, function that defines the width of an element: Generated CSS:
  • 14. SASS: Loops ● Code can also be generated in a loop: Generated CSS:
  • 15. How can you use sass in r? (r/sass)
  • 16. How can you use sass in r (r/sass) ● Use a library! ● r/sass implements a CSS preprocessor, letting R developers use SASS to generate dynamic style sheets. ● sass() can take a SASS string or file and returns a string of compiled CSS
  • 18. Resources ● SASS vignette https://rstudio.github.io/sass/articles/sass.html ● R/SASS Repository https://github.com/rstudio/sass ● Basics on CSS https://www.w3schools.com/css/default.asp ● Dinamic CSS generation in R https://gallery.shinyapps.io/sass-theme/
  • 20. BONUS: Selectors you might not know about
  • 21. Bonus: Selectors * Targets EVERY element on the page X[attribute="foo"] {} Targets elements with a specific attribute X ~ Y and X + Y Targets Y elements that have a sibling X: X ~ Y {} Y elements that have an X before them. X + Y {} Y elements that have an X IMMEDIATELY before. X:first-of-type {} and X:last-of-type {} First or last X in a container X:not(selector) X that is not also selector
  • 22. Bonus: Selectors X:nth-of-type(condition) Elements in a specific positions inside their container. Condition can be a few different values: odd or even will target all odd or even elements x:nth-of-type(2) will target elements on a specific position an + b a is a cycle size, n is a counter (starts at 0), and b is an offset value: x:nth-of-type(3n+0) elements whose index is a multiple of 3 x:nth-of-type(4n+1) every 4th element starting at the first one Online calculator: https://css-tricks.com/examples/nth-child-tester/