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

Similar documents
IBM Forms V8.0 Custom Themes IBM Corporation

Building Page Layouts

IN4MATX 133: User Interface Software

INTRODUCTION TO CSS. Topics MODULE 5

CSS. MPRI : Web Data Management. Antoine Amarilli Friday, December 7th 1/43

CSS Futures. Web Development

More CSS goodness with CSS3. Webpage Design

OddsMatrix. Everything is possible. SASS Code Standards

Frontend UI Training. Whats App :

Client-Side Web Technologies. CSS Part I

CSC309 Winter Lecture 2. Larry Zhang

Cascading Style Sheets CSCI 311

"Charting the Course... MOC A: Developing with the SharePoint Framework. Course Summary

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

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.

Tutorial 5 Working with Tables and Columns. HTML and CSS 6 TH EDITION

Build Powerful FrontEnd Workflows with PostCSS. Guide to writing/generating cutting edge CSS

Guidelines for doing the short exercises

NAVIGATION INSTRUCTIONS

CSS: Responsive Design, CSS3 and Fallbacks

APEX Developers - Do More With Less!!


CSS. Shan-Hung Wu CS, NTHU

CSS Box Model. Cascading Style Sheets

Javascript Performance in the Browser. Charlie Fiskeaux II User Interface Engineer

55249: Developing with the SharePoint Framework Duration: 05 days

Friday, January 18, 13. : Now & in the Future

Styling Web Applications Presented by Roel Fermont

Introduction to WEB PROGRAMMING

Parashar Technologies HTML Lecture Notes-4

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

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

Introduction to Sencha Ext JS

Proper_Name Final Exam December 21, 2005 CS-081/Vickery Page 1 of 4

CSS cont. October 5, Unit 4

How Behance went responsive with Sass and RequireJS. Jackie

Zen Garden. CSS Zen Garden

The Scope of This Book... xxii A Quick Note About Browsers and Platforms... xxii The Appendices and Further Resources...xxiii

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

eskills for Volunteers STRATEGIC PARTNERSHIP IN THE FIELD OF YOUTH

Sass. The Future of Stylesheets.

Introduction to HTML & CSS. Instructor: Beck Johnson Week 2

Web Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh

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

BORDER IMAGES THE BACKGROUND IMAGE PROPERTIES. Learning Web Design, 5e

Index. Ray Nicholus 2016 R. Nicholus, Beyond jquery, DOI /

Scripting. Web Architecture and Information Management [./] Spring 2009 INFO (CCN 42509) Contents

CSS.

Lesson 5 Introduction to Cascading Style Sheets

Web Programming and Design. MPT Senior Cycle Tutor: Tamara Week 2

CSS Cascading Style Sheets

CS7026 CSS3. CSS3 Graphics Effects

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

Arjen de Blok. Senior Technical Consultant bij ICT Groep ( sinds 1995 Programmeren sinds 1990 Technologiën. Links

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

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

Block & Inline Elements

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

COMP519 Web Programming Lecture 7: Cascading Style Sheets: Part 3 Handouts

CMPT 165 INTRODUCTION TO THE INTERNET AND THE WORLD WIDE WEB

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

IDM 221. Web Design I. IDM 221: Web Authoring I 1

Webpack. What is Webpack? APPENDIX A. n n n

Media Types & Media Features

Your essential APEX companion. Marko apexbyg.blogspot.com

BIM222 Internet Programming

Introduction to using HTML to design webpages

Better tools for content editors. Petr ILLEK Morpht

ThingLink User Guide. Andy Chen Eric Ouyang Giovanni Tenorio Ashton Yon

CSC309 Programming on the Web week 3: css, rwd

Page Layout. 4.1 Styling Page Sections 4.2 Introduction to Layout 4.3 Floating Elements 4.4 Sizing and Positioning

Cascading Style Sheets (CSS)

Styles, Style Sheets, the Box Model and Liquid Layout

Website Design (Weekend) By Alabian Solutions Ltd , 2016

Basics of Web Technologies

Stamp Builder. Documentation. v1.0.0

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Designing the Home Page and Creating Additional Pages

Theme System. Wisej Themes 1 OVERVIEW

Reasoning with Style

CSS: Beyond the Code. Karen Perone Rodman Public Library.

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

CS193X: Web Programming Fundamentals

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image

BA. (Hons) Graphics Design

Web Design & Dev. Combo. By Alabian Solutions Ltd , 2016

Teach Yourself HTML5 & CSS 3: Week 5 Task 13 - Anchors Part 3

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from

Cascading Style Sheet. Styles as Tag Attributes. Syntax. <h1>: what font type/size is used? STYLE = SELECTOR {RULES} Attributes such as bgcolor

Index. alt, 38, 57 class, 86, 88, 101, 107 href, 24, 51, 57 id, 86 88, 98 overview, 37. src, 37, 57. backend, WordPress, 146, 148

Data Visualization on the Web with D3

Web UI. Survey of Front End Technologies. Web Challenges and Constraints. Desktop and mobile devices. Highly variable runtime environment

COMS 359: Interactive Media

UNIT -II. Language-History and Versions Introduction JavaScript in Perspective-

Style Sheet Reference Guide

Web Application Styling

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar

Creating HTML files using Notepad

Lab Introduction to Cascading Style Sheets

Website Design (Weekday) By Alabian Solutions Ltd , 2016

Transcription:

CREATE SASSY WEB PARTS Developer Guide to SASS usage in SPFx

!!! WARNING!!! YOU WILL SEE SOURCE CODE!!! WARNING!!!

OUR GOALS Sketch and develop web parts Create your own reusable CSS Handle external CSS properly in SPFx Apply themes to your web parts

TYPESCRIPT is a typed superset of JavaScript that compiles to JavaScript

SASS SYNTACTICAL AWESOME STYLE SHEETS is a superset and programming language of CSS that compiles to CSS

PROGRAMMING LANGUAGE? VARIABLES $brand-color-main: #DD304D $default-padding: 10px PROGAMMING @if @else @for @each @while @debug @warn @error TYPES numbers: 1.2, 13, 10px strings: "foo", 'bar', baz colors: blue, #04a3f9, rgba(255, 0, 0, 0.5) boolean, null, lists of values, maps

MORE FEATURES? -- FUNCTIONS @function addition($a, $b) { @return $a+$b; // Function a { padding: addition(10px, 30px); // Result a { padding: 40px;

MORE FEATURES? -- MIXIN @mixin headline ($color, $size) { color: $color; font-size: $size; h1 { @include headline(green, 12px); // Result h1 { color: green; font-size: 12px;

MORE FEATURES? PLACEHOLDER EXTEND // Template Definition %box{ display: block; width: 300px; height: 150px;

MORE FEATURES? PLACEHOLDER EXTEND // Red Box.red-box{ @extend %box; background-color: red; // Green Box.green-box{ @extend %box; background-color: green;

MORE FEATURES? PLACEHOLDER EXTEND.red-box,.green-box { display: block; width: 300px; height: 150px;.red-box { background-color: red;.green-box { background-color: green;

MORE FEATURES? PLACEHOLDER EXTEND.red-box,.green-box { display: block; width: 300px; height: 150px;.red-box { background-color: red;.green-box { background-color: green;

NESTING - PARENT SELECTOR - & a{ color: teal; &:hover{ color: pink; &:visited{ color: teal;

NESTING a{ color: teal; a:hover{ color: pink; a:visited{ color: teal;

NESTING PARENT SELECTOR - &.box{ display: inline-block; width: 300px; height: 200px; color: black; &-label{ height: 50px; background-color: black; color: white;

NESTING PARENT SELECTOR - &.box{ display: inline-block; width: 300px; height: 200px; color: black;.box-label{ height: 50px; background-color: black; color: white;

LEAST IMPORTANT FEATURE IN HTML @import url; @import url list-of-media-queries; @import url("fineprint.css") print; @import url("bluish.css") projection, tv; @import 'custom.css'; @import url("chrome://communicator/skin/"); @import "common.css" screen, projection; @import url('landscape.css') screen and (orientation:landscape);

HOW BROWSER HANDLE 1. Load CSS HTTP Request 2. finds @import 3. Load CSS HTTP Request 4. parse both CSS 5. Render page

MOST IMPORTANT FEATURE IN SASS @import <file url>; Works same as in HTML but different @import url( http://getbootstrap.com/someurl ) HTML import @import somefile.css Merges file directly into CSS

MOST IMPORTANT FEATURE IN SASS @import _custom.scss ; @import custom ; Partial file through the _ File won t be converted.css file Import Reusable components Helps you strucuture your CSS Better

IMPORT IN SPFX @import _custom.scss ; @import custom ; @import node_modules/office-ui-fabric/dist/fabric.css Import CSS from any npm package Import CSS from bower components

CONGRATULATION SASS Certified

HOW I WORK

MY WORKFLOW SKETCH AND DESIGN DOCUMENT STYLES MOVE IT TO SPFx

DOCUMENT STYLES Style Guide Pattern Library Simple Style for SP/O365 and SPFx React Components

DEMO

BENEFITS - Focus on code design - Reusable components - Cross browser testing - No documentation effort - Refactor components Common Tool in Web Design

BRING IT TO SPFX

SASS COMPILATION IN SPFX COMPILE SASS AUTOPREFIX POSTFIX / TS Class Compilation

AUTOPREFIXING WHAT IS IT?.round { /* Safari 3-4, ios 1-3.2, Android 1.6- */ -webkit-border-radius: 12px; /* Firefox 1-3.6 */ -moz-border-radius: 12px; /* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, ios 4, Android 2.1+ */ border-radius: 12px;

AUTOPREFIXING WHAT IS IT?.round { border-radius: 12px;

AUTOPREFIXING WHAT IS IT?.round { /* Safari 3-4, ios 1-3.2, Android 1.6- */ -webkit-border-radius: 12px; /* Firefox 1-3.6 */ -moz-border-radius: 12px; /* Opera 10.5, IE 9, Safari 5, Chrome, Firefox 4, ios 4, Android 2.1+ */ border-radius: 12px;

HOW DOES AUTOPREFIXING WORK? 1. Lookup attributes on caniuse.com 2. Checks prefixes needed 3. Adds it to CSS

BENEFIT AUTOPREFIXING Cleaner CSS / Less Headache Configured to support Office 365 / SharePoint optimal No legacy code removal

SASS COMPILATION IN SPFX COMPILE SASS AUTOPREFIX POSTFIX / TS Class Compilation

POSTFIXING.round {....round_f6d5fd65{... BEFORE AFTER

POSTFIXING.round {....round_f6d5fd65{... BEFORE AFTER Make class name unique

POSTFIXING Web Part cannot effect the overall experience Different web parts same classes not possible Makes it hard to share code across web parts even in same project

TYPESCRIPT CLASS COMPILATION Each CSS class à style.yourclassname CSS becomes somewhat type safe LIMITATION: invalid class name.card-hover JS doesn t allow dashes in variable names

TYPESCRIPT CLASS COMPILATION Typescript class = JSON Object var styles = { 'my-class': 'my-class_2023f0bf style.my-class style[ my-class ] //Fails // CORRECT but not type safe

A CLOSER LOOK IN SPFX

RESULT OF SASS IN SPFX 1. /src/**/mysass.module.scss source file 2. /lib/**/mysass.module.css compiled CSS /lib/**/mysass.module.scss.d.ts type definition /lib/**/mysass.module.scss.js style object /lib/**/mysass.module.scss.js.map debug map

AVOID CSS CLASS NAME RENAME :global pseudo selector.spsmilan { :global { // Everything in here won t be replace @include card-hoverup("green", green, white, 0.6);

WHEN TO USE GLOBAL? Good option for external CSS Use it wisely Use it inside the container only

THEMED WEB PARTS "[theme:themeprimary, default:#0078d7]" Office UI Fabric supports theming Use variable colors User color variables

Information Architect Vienna / Austria n8d.at/blog @StfBauer