IN4MATX 133: User Interface Software

Similar documents
Zen Garden. CSS Zen Garden

Introduction to WEB PROGRAMMING

CSS Cascading Style Sheets

IDM 222. Web Design II. IDM 222: Web Authoring II 1

CSS.

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

CSS Cascading Style Sheets

SASS Variables and Mixins Written by Margaret Rodgers. Variables. Contents. From Web Team. 1 Variables

Cascading Style Sheets (CSS)

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

CREATE SASSY WEB PARTS. Developer Guide to SASS usage in SPFx

{WebCodeChicks} </spartanburg> Beginning Sass. sass-lang.com/guide

CSS: Cascading Style Sheets

Adding CSS to your HTML

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

Cascading Style Sheets Level 2

3.1 Introduction. 3.2 Levels of Style Sheets. - The CSS1 specification was developed in There are three levels of style sheets

- The CSS1 specification was developed in CSS2 was released in CSS2.1 reflects browser implementations

IN4MATX 133: User Interface Software

IN4MATX 133: User Interface Software

Beginner s Guide to SASS

Unveiling the Basics of CSS and how it relates to the DataFlex Web Framework

CSC309 Winter Lecture 2. Larry Zhang

Unit 10 - Client Side Customisation of Web Pages. Week 5 Lesson 1 CSS - Selectors

CSS: The Basics CISC 282 September 20, 2014

Appendix D CSS Properties and Values

Web Designer s Reference

Managing CSS Projects with ITCSS. DaFED Novi Sad, November 2014

APEX Developers - Do More With Less!!

- The CSS1 specification was developed in CSSs provide the means to control and change presentation of HTML documents

2. Write style rules for how you d like certain elements to look.

.hedgehog { background-image: url(backyard.jpg); color: #ffff99; height: 6in; width: 12in; } .tube {

Study Guide 2 - HTML and CSS - Chap. 6,8,10,11,12 Name - Alexia Bernardo

CSS worksheet. JMC 105 Drake University

Wanted! Introduction. Step 1: Styling your poster. Activity Checklist. In this project, you ll learn how to make your own poster.

CSS 1: Introduction. Chapter 3

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

BIM222 Internet Programming

Reading 2.2 Cascading Style Sheets

Session 3.1 Objectives Review the history and concepts of CSS Explore inline styles, embedded styles, and external style sheets Understand style

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

3.1 Introduction. 3.2 Levels of Style Sheets. - HTML is primarily concerned with content, rather than style. - There are three levels of style sheets

In the early days of the Web, designers just had the original 91 HTML tags to work with.

CS 350 Internet Applications I Name: Exam II (CSS) October 29, 2013

Web Design and Development Tutorial 03

COMS 359: Interactive Media

<body bgcolor=" " fgcolor=" " link=" " vlink=" " alink=" "> These body attributes have now been deprecated, and should not be used in XHTML.

Review Question 1. Which tag is used to create a link to another page? 1. <p> 2. <li> 3. <a> 4. <em>

- HTML is primarily concerned with content, rather than style. - However, tags have presentation properties, for which browsers have default values

Assignments (4) Assessment as per Schedule (2)

The Benefits of CSS. Less work: Change look of the whole site with one edit

ITNP43: HTML Lecture 4

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web

Block & Inline Elements

INTRODUCTION TO CSS. Topics MODULE 5

Web Development & Design Foundations with HTML5

Guidelines for doing the short exercises

The building block of a CSS stylesheet. A rule consists of a selector and a declaration block (one or more declarations).

Web Development & Design Foundations with HTML5

APEX Developers Do More With Less!! How do YOU manage your APEX CSS? Storage Options 1. Web server 2. APEX repository 3. In line 4.

Parashar Technologies HTML Lecture Notes-4

Universal CSS Navigation Menu: Advanced Styling Patrick Julicher Universal CSS Navigation Menu: Advanced Styling

CSS Selectors. element selectors. .class selectors. #id selectors

COMP519 Web Programming Lecture 6: Cascading Style Sheets: Part 2 Handouts

Data Visualization (CIS/DSC 468)

IBM Forms V8.0 Custom Themes IBM Corporation

Using Dreamweaver. 6 Styles in Websites. 1. Linked or Imported Stylesheets. 2. Embedded Styles. 3. Inline Styles

GIMP WEB 2.0 MENUS WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR CREATING AN HTML LIST

Web Engineering CSS. By Assistant Prof Malik M Ali

HTML and CSS a further introduction

Networks and Web for Health Informatics (HINF 6220) Tutorial 8 : CSS. 8 Oct 2015

Using Dreamweaver CS6

Admin. Midterm 1 on. Oct. 13 th (2 weeks from today) Coursework:

Hands On: Dreamweaver CS3 NEW SPRY Widgets

Creating a CSS driven menu system Part 1

CSS. Shan-Hung Wu CS, NTHU

HTML5: Adding Style. Styling Differences. HTML5: Adding Style Nancy Gill

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

CSS: Layout Part 2. clear. CSS for layout and formatting: clear

8/19/2018. Web Development & Design Foundations with HTML5. Learning Objectives (1 of 2) Learning Objectives (2 of 2)

CSS Tutorial Part 1: Introduction: A. Adding Style to a Web Page (3 options):

WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5

CSS3 Basics. From & CSS Visual Dictionary Learning Curve Books, LLC

The default style for an unordered (bulleted) list is the bullet, or dot. You can change the style to either a square or a circle as follows:

CSC309 Programming on the Web week 3: css, rwd

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

CSS

CSS: Cascading Style Sheets

Getting Started with Eric Meyer's CSS Sculptor 1.0

CMPT 165 Advanced XHTML & CSS Part 3

Introduction to Web Programming and Design

Data Visualization (DSC 530/CIS )

HTML/XML. HTML Continued Introduction to CSS

OddsMatrix. Everything is possible. SASS Code Standards

Using CSS in Web Site Design

CSS. LBSC 690: Jordan Boyd-Graber. October 8, Adapted. from Dwight VanTuyl s slides. LBSC 690: Jordan Boyd-Graber () CSS October 8, / 57

Which is why we ll now be learning how to write in CSS (or cascading sheet style)

Let s start with the document tree

Using Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles

Transcription:

IN4MATX 133: User Interface Software Lecture 21: SASS and Styling in Ionic Professor Daniel A. Epstein TA Jamshir Goorabian TA Simion Padurean 1

Class notes Quiz 4 (Tuesday) will cover November 5th s lecture (Guest lecture by Josh Tanenbaum) through today A2 grades will be posted after class Sorry for the delay Quiz 3 grades will hopefully be posted early next week Next week s office hours schedule is rearranged to account for Thanksgiving Check the calendar 2

Today s goals By the end of today, you should be able to Explain why we might use a preprocessor like SASS for CSS Use SASS variables, mixins, nesting, and operators to simplify CSS Style Ionic components and override platform-specific styles 3

Same page, different stylesheets https://www.w3schools.com/css/demo_default.htm 4

CSS syntax Selectors specify which elements a rule applies to Rules specify what values to assign to different formatting properties /* CSS Pseudocode */ selector { One rule, many properties property: value; property: value;... 5

Writing plain CSS Violates the Don t Repeat Yourself principle of coding Many times we re writing the same snippets of code for frequently used declarations 6

Example: fonts What if I want to switch from Lato to some other font? What if I want to make everything larger? I could have structured my CSS more efficiently, but at the core, it s inflexible For example, I could have set Lato to be the default font for cite cite >.series { font-family: 'Lato', sans-serif; cite > a { font-family: 'Lato', sans-serif; font-size: 0.8em; cite >.authors { font-family: 'ChaparralPro', serif; font-size: 1.1em; cite >.title { font-family: 'Lato', sans-serif; font-weight: 700; 7

CSS preprocessors Let you abstract key design elements, use logic, and write less code Three widely used ones: SASS, Less, Stylus They all do pretty much the same thing Ionic uses SASS by default 8

CSS preprocessors Major features Variables Mixins Nesting Operators 9

Variables Using variables with CSS preprocessors makes it easy to update colors, fonts, or other values throughout your entire stylesheet //Sass Variables $primary: #CC5533; $font-base: 12px; //Less Variables @primary: #CC5533; @font-base: 12px; //Stylus Variables primary = #CC5533 font-base = 12px 10

Variables As of 2016, variables are supported in plain old CSS Many frameworks use these variables instead of preprocessor variables Including Ionic (new in 4!) /*Declaring a variable*/ element { --main-bg-color: brown; /*Using the variable*/ element { background-color: var(--main-bg-color); But preprocessors offer a lot more functionality https://www.caniuse.com/#search=css%20variables 11

Mixins Mixins can share a whole collection of CSS rules throughout a stylesheet @mixin border-radius($radius) { -webkit-border-radius: $radius; -moz-border-radius: $radius; -ms-border-radius: $radius; border-radius: $radius;.box { @include border-radius(10px); 12

Nesting You can nest selectors with preprocessors This means you can easily organize an entire hierarchy of selectors, including child elements nav { ul { margin: 0; padding: 0; list-style: none; li { display: inline-block; a { display: block; padding: 6px 12px; text-decoration: none; &:hover { text-decoration: underline; 13

Question Which SASS nesting is equivalent to these plain CSS rules? ul > li { color: red; ul { font-weight: 500; list-style-type: circle; ul { font-weight: 700; list-style-type: square; ul { font-weight: 500; list-style-type: circle; A B C li { ul { color: red; li { color: blue; li { color: red; font-weight: 500; list-style-type: circle; D ul { font-weight: 500; list-style-type: circle; li { color: red; E li { color: red; ul { font-weight: 500; list-style-type: circle; 14

Operators Like most programming languages, CSS preprocessors can do math! $container = 100%; article[role="main"] { This is especially great for setting a fixed value in a variable, like a fontsize or padding, and then modifying it as you go along float: left; width: 600px / 960px * $container; 15

Digging into SASS 16

SASS Syntatically Awesome Style Sheets SASS is the most mature, stable, and powerful professional grade CSS extension language in the world. SASS boasts more features and abilities than any other CSS extension language out there It s on their website, so it must be true! http://sass-lang.com/ 17

SASS File extension:.scss SASS is a superset of CSS You can write any CSS in a SCSS document SCSS is transpiled to CSS Just like TypeScript is transpiled to JavaScript 18

SCSS Syntax Looks very much like regular CSS Rules apply to a selector and are made in brackets Each rule ends with a semicolon SCSS adds variables, mixins, etc. $font-stack: Helvetica, sans-serif; $primary-color: #333; body { font: 100% $font-stack; color: $primary-color; 19

SCSS Syntax There s another style, called sass syntax, which looks more like python It s older, uses the.sass extension Why is.scss better? It s a superset of CSS, rather than another syntax $primary-color: #3bbfce; $margin: 16px;.content-navigation { border-color: $primary-color; color: darken($primary-color, 10%);.border { padding: $margin / 2; margin: $margin / 2; border-color: $primary-color; $primary-color: #3bbfce $margin: 16px.content-navigation border-color: $primary-color color: darken($primary-color, 10%).border padding: $margin/2 margin: $margin/2 border-color: $primary-color.scss.sass 20

How do I actually use a CSS preprocessor like SASS? 21

Installing SASS npm install -g sass This version is written in JavaScript, which is slower But it s fine for the size of projects we re working with choco install sass brew install sass/sass/sass 3 times to make super duper sure (just kidding, it s how HomeBrew designates projects) https://sass-lang.com/install 22

Manually transpiling You can use SASS with a plain-old HTML page! It just needs to be transpiled to CSS before getting loaded 23

Manually transpiling Transpile one file: sass input.scss output.css Watch one file for changes: sass watch input.scss:output.scss Watch a whole directory of SASS files: sass watch path/sass-directory 24

Automatic transpiling A lot of frameworks will automatically transpile.scss files when they build and run Angular and Ionic can include.scss files for every component and secretly transpile them to.css A preprocessor is specified when the app is first created 25

Thoughts on CSS preprocessors Preprocessor functionality is slowly getting added to the CSS standard CSS now supports variables, for example Does this mean that preprocessors will soon be obsolete? Maybe. Or maybe they ll evolve, adding other kinds of new and better features Transpiling languages are a great way to show the value of new features And if they catch on enough, they get added into the standard Who knows, maybe JavaScript will add typing from TypeScript 26

Styling in Ionic 27

Ionic variables Two types of variables: Global variables Component variables Three files: app/global.scss app/theme/variables.scss app/[component]/[component].scss 28

Ionic global variables Defined in app/theme/ variables.scss /** primary **/ :root { --ion-color-primary: #3880ff; --ion-color-secondary: #0cd1e8; Used for defining platform colors, fonts, margins, etc. --ion-font-family: 'Arial'; --ion-margin: 16px; There are ~100 different global variables, but the defaults are pretty good https://beta.ionicframework.com/docs/theming/advanced/ 29

Ionic global variables Global variables can be accessed manually, like other CSS variables Ionic provides utilities for accessing global color variables in HTML /*SCSS or CSS*/ ion-button { color: var(--ion-color-primary); <!--HTML--> <ion-button color= primary"></ion-button> This somewhat violates code separation principles but the syntax is cleaner 30

Color palette Ionic s color generator can help you see what your scheme will look like in a built-out app May be useful in conjunction with a color palette tool: https://color.adobe.com/ http://paletton.com/ It will generate a file which can be copy/pasted into app/theme/variables.scss https://beta.ionicframework.com/docs/theming/color-generator 31

Component variables Each component has specific variables for defining its style These variables can be edited where the component is created (e.g., the parent component) https://beta.ionicframework.com/docs/api/button 32

Component variables <!--component.html--> <ion-button id="testbutton">test Button </ion-button> /*component.scss*/ #testbutton { --border-width: 5px; --border-style: solid; --border-color: black; https://beta.ionicframework.com/docs/api/button 33

Platform styles Each platform has a mode, either ios (ios) or md (Android) Components and global styles can be adjusted for each mode /*in global.scss*/.ios { --ion-background-color: #222;.md { --ion-background-color: #220; 34

Today s goals By the end of today, you should be able to Explain why we might use a preprocessor like SASS for CSS Use SASS variables, mixins, nesting, and operators to simplify CSS Style Ionic components and override platform-specific styles 35

IN4MATX 133: User Interface Software Lecture 21: SASS and Styling in Ionic Professor Daniel A. Epstein TA Jamshir Goorabian TA Simion Padurean 36