How i learned to stop using icon fonts and love svg (again)

Post on 15-Apr-2017

115 views 1 download

Transcript of How i learned to stop using icon fonts and love svg (again)

really

and SVGHow I learnt to stop using icon fonts

Hello!

1000 WORDSA picture is worth

Tree Woods Forest

🍆🙈🩄

Mexico City

Metro System

TL

TL

3

3

7

76 6

4

4

5

519 A

19

A

8

8B

B

2

2

12

12

Coyuya

El Rosario

Autobusesdel Norte

Indios Verdes

La Villa - BasĂ­lica

EduardoMolina

San AntonioAbad PantitlĂĄn

Ciudad Azteca

Plaza AragĂłn

OlĂ­mpica

Ecatepec

MĂșzquiz

RĂ­o de los Remedios

Impulsora

NezahualcĂłyotl

Villa de AragĂłn

Bosque de AragĂłn

Deportivo OceanĂ­a

OceanĂ­a

Terminal AĂ©rea

Hangares

AgrĂ­cola Oriental

Canal de San Juan

Tepalcates

Guelatao

PeñonViejo

Acatitla SantaMarta

Los Reyes La Paz

PueblaCiudadDeportiva

VelĂłdromoMixiuhca

Zaragoza

GĂłmezFarĂ­as

Boulevard Puerto AĂ©reo

Balbuena

Moctezuma

RomeroRubioRicardo Flores

MagĂłn

SanLĂĄzaro

Canal delNorte

Candelaria

Merced FrayServando

Jamaica

Tepito

Morelos

LagunillaGaribaldi

Allende

ZĂłcalo

Isabel laCatĂłlica

PinoSuĂĄrez

Chabacano

San Juande LetrĂĄn

Salto delAgua

Bellas Artes

Hidalgo

Guerrero

AragĂłn

TalismĂĄn

Consulado

→

La Viga

La Raza

Bondojito

MartĂ­nCarrera

Deportivo18 de Marzo

Potrero

Lindavista

Politécnico

Insituto delPetrĂłleo

VallejoNorte 45FerrerĂ­aAzcapotzalcoTezozĂłmoc

Aquiles SerdĂĄn

Camarones

RefinerĂ­a

San JoaquĂ­n

Polanco

Auditorio

Constituyentes

San Pedrode los Pinos

San Antonio

Barrancadel Muerto

Buenavista

Tlatelolco

Misterios

Valle GĂłmez

JuĂĄrez

RevoluciĂłnSanCosme

NormalColegioMilitar

PopotlaCuitlĂĄhuacPanteones

CuatroCaminos Tacuba

Observatorio

Tacubaya

Mixcoac

JuanacatlĂĄn

Chapultepec

Sevilla

Insurgentes

Cuauhtémoc

Balderas

Doctores

Obrera

NiñosHéroes

HospitalGeneral

CentroMĂ©dico

EtiopĂ­a

Eugenia

DivisiĂłndel Norte

Zapata

CoyoacĂĄn

Viveros

Miguel Ángelde Quevedo

Copilco

Universidad

Patriotismo Chilpancingo LĂĄzaro CĂĄrdenas

Viaducto

Xola

Villa de Cortés

Nativitas

Portales

Ermita

GeneralAnaya

Tasqueña

Tasqueña

Insurgentes Sur Hospital20 de Noviembre

Parque delos Venados

Eje Central Mexicaltzingo

Atlalilco

CulhuacĂĄn

San AndrésTomatlån

LomasEstrella

Calle 11 PeriféricoOriente

Tezonco Olivos Nopalera ZapotitlĂĄn Tlaltenco TlĂĄhuac

Santa Anita

Iztacalco

Apatlaco

Aculco

EscuadrĂłn 201

Iztapalapa Cerro de la Estrella

UAM-I ConstituciĂłnde 1917

Las Torres

Ciudad JardĂ­n

La Virgen

Xotepingo

Nezahualpilli

Registro Federal

TextitlĂĄn

El Vergel EstadioAzteca

Huipulco Xomali Periférico Tepepan La Noria Huichapan FranciscoGoitia

Xochimilco

The scale in this map is not 100% geographically accurate, especially for the Tren Ligero.

The logos reproduced herein are copyright of the STC.

This map put together by Richard (richard@mexicometro.org / @richardmtl )

ICONSmake for better communication

Menu

ICONSmake for better websites

38!

SPRITELYCSS solutions

.twitter-icon { background-position: 102px -48px; }

RESCUE!Icon fonts to the

HACKIcon fonts are a

SVG.What’s next?

<svg> <path class="heart" d="M25.79,10.7a4.77,4.77,..." /> </svg>

BOTHER?Why should I

REASONSyou should switch to SVG

5

SEMANTICS.Perhaps you care about1

2 ACCESSIBILITYis better out-of-the-box.

<svg> <title>Heart</title> <desc>A fluorescent teal heart.</desc> <path class="heart" d="M25.79,10.7a4.77,4.77,..." /> </svg>

LOOK BETTERYour icons are going to3

.heart { fill: #B9FDFE; }

.heart { fill: none; stroke: #B9FDFE; stroke-width: 2px; }

.heart { fill: #B9FDFE; }

.arrow { fill: #FD80E5; }

.arrow { transition: all 0.5s ease-in; transform: translate (20, -20); }

FAILUREis an awful lot less likely.

4

BROWSERSHappier

5

4.5per cent of global browser usage

OKAYI’m convinced.

HOW DO I DO IT?

POISONChoose your

DATA URI

.skull-icon { background-image: url(‘data:image/svg+xmldata:application/octet-stream;base64,CjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgMzIgMzIiPgoJPHN0eWxlIHR5cGU9InRleHQvY3NzIj4KCS5oZWFydCB7CgkJZmlsbDogI2I2ZmRmTQsNS42NSw3LjQ3LDguNDEsMi41NC0yLjc2LDUuMTItNS40OSw3LjUtOC40MSwxLjczLTIuMTEsMi45MS0zLjg1LDIuMzgtNi42M2gwWiIgLz4KPC9zdmc+Cg
’); background-repeat: no-repeat; background-position: 50% 50%; height: 1em; width: 1em; }

<span class=“skull-icon”> </span>

SYMBOL

<svg style="display: none"> <symbol id="heart-icon"> <...> </symbol> <symbol id="skull-icon"> <...> </symbol>

</svg>

<svg class="skull-icon"> <use xlink:href="#skull-icon"></use> <svg>

<svg class="skull-icon"> <use xlink:href="icons.svg#skull-icon"></use> <svg>

BEST FRIENDReusable, modular code is your

<?php themeslug_icon( 'skull' ); ?>

[themeslug-icon name="skull"]

TASK RUNNERSYour other best friend forever.

SOCIAL MENUS?But what about my

add_filter( 'wp_nav_menu_objects', 'themeslug_social_menu' );

<a href=“http://twitter.com/sarahsemark”>Twitter</a>

<a href=“http://twitter.com/sarahsemark”> <svg class=“twitter-icon”> 
 </svg> <span class=“screen-reader-text”>Twitter</span> </a>

JETPACKsocial menus

add_theme_support( ‘jetpack-social-menu‘ );

function themeslug_social_menu() { if ( has_nav_menu( ‘jetpack-social-menu‘ ) ) : ?> <nav class=“jetpack-social-navigation” role=“navigation”> <?php wp_nav_menu( array ( ‘theme_location’ => ‘jetpack-social-menu’, ‘link_before’ => ‘’, ‘link_after’ => ‘’, ) ); ?> </nav> <?php endif; }

REACT?what if I’m using

const SkullIcon = React.createClass( { render() { return( <svg className=“skull-icon”> 
 </svg> ) } } );

ACCESSIBLE?How do I make sure all this is

<svg aria-hidden="true"> <use xlink:href="#skull-icon"></use> </svg>

<svg role="img" aria-labelledby=“skull-title"> <title id="#skull-title">skull</title> <use xlink:href="#skull-icon"></use> </svg>

<a href="#" aria-label="Delete all items"> <svg> <use xlink:href="#skull-icon"></use> </svg> </a>

FALLBACKSa quick word about

<svg> 
 <image src="skull.png" xlink:href=""/> </svg>

THANKS FOR FLYING!

QUESTIONS?@sarahsemark

github.com/sarahmonster/easy-as-svg

triggersandsparks.com/talks/svg-icons