\documentclass[10pt,a4paper]{article}

% Packages
\usepackage{fancyhdr}           % For header and footer
\usepackage{multicol}           % Allows multicols in tables
\usepackage{tabularx}           % Intelligent column widths
\usepackage{tabulary}           % Used in header and footer
\usepackage{hhline}             % Border under tables
\usepackage{graphicx}           % For images
\usepackage{xcolor}             % For hex colours
%\usepackage[utf8x]{inputenc}    % For unicode character support
\usepackage[T1]{fontenc}        % Without this we get weird character replacements
\usepackage{colortbl}           % For coloured tables
\usepackage{setspace}           % For line height
\usepackage{lastpage}           % Needed for total page number
\usepackage{seqsplit}           % Splits long words.
%\usepackage{opensans}          % Can't make this work so far. Shame. Would be lovely.
\usepackage[normalem]{ulem}     % For underlining links
% Most of the following are not required for the majority
% of cheat sheets but are needed for some symbol support.
\usepackage{amsmath}            % Symbols
\usepackage{MnSymbol}           % Symbols
\usepackage{wasysym}            % Symbols
%\usepackage[english,german,french,spanish,italian]{babel}              % Languages

% Document Info
\author{brian (brianyang)}
\pdfinfo{
  /Title (polymer-2-0.pdf)
  /Creator (Cheatography)
  /Author (brian (brianyang))
  /Subject (Polymer 2.0 Cheat Sheet)
}

% Lengths and widths
\addtolength{\textwidth}{6cm}
\addtolength{\textheight}{-1cm}
\addtolength{\hoffset}{-3cm}
\addtolength{\voffset}{-2cm}
\setlength{\tabcolsep}{0.2cm} % Space between columns
\setlength{\headsep}{-12pt} % Reduce space between header and content
\setlength{\headheight}{85pt} % If less, LaTeX automatically increases it
\renewcommand{\footrulewidth}{0pt} % Remove footer line
\renewcommand{\headrulewidth}{0pt} % Remove header line
\renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit
% This two commands together give roughly
% the right line height in the tables
\renewcommand{\arraystretch}{1.3}
\onehalfspacing

% Commands
\newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour
\newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols
\newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns
\newcommand{\tn}{\tabularnewline} % Required as custom column type in use

% Font and Colours
\definecolor{HeadBackground}{HTML}{333333}
\definecolor{FootBackground}{HTML}{666666}
\definecolor{TextColor}{HTML}{333333}
\definecolor{DarkBackground}{HTML}{A3A3A3}
\definecolor{LightBackground}{HTML}{F3F3F3}
\renewcommand{\familydefault}{\sfdefault}
\color{TextColor}

% Header and Footer
\pagestyle{fancy}
\fancyhead{} % Set header to blank
\fancyfoot{} % Set footer to blank
\fancyhead[L]{
\noindent
\begin{multicols}{3}
\begin{tabulary}{5.8cm}{C}
    \SetRowColor{DarkBackground}
    \vspace{-7pt}
    {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent
        \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}}
    }
\end{tabulary}
\columnbreak
\begin{tabulary}{11cm}{L}
    \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Polymer 2.0 Cheat Sheet}}}} \\
    \normalsize{by \textcolor{DarkBackground}{brian (brianyang)} via \textcolor{DarkBackground}{\uline{cheatography.com/30738/cs/9213/}}}
\end{tabulary}
\end{multicols}}

\fancyfoot[L]{ \footnotesize
\noindent
\begin{multicols}{3}
\begin{tabulary}{5.8cm}{LL}
  \SetRowColor{FootBackground}
  \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}}  \\
  \vspace{-2pt}brian (brianyang) \\
  \uline{cheatography.com/brianyang} \\
        \uline{\seqsplit{brianyang}.com}
  \end{tabulary}
\vfill
\columnbreak
\begin{tabulary}{5.8cm}{L}
  \SetRowColor{FootBackground}
  \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}}  \\
   \vspace{-2pt}Not Yet Published.\\
   Updated 22nd September, 2016.\\
   Page {\thepage} of \pageref{LastPage}.
\end{tabulary}
\vfill
\columnbreak
\begin{tabulary}{5.8cm}{L}
  \SetRowColor{FootBackground}
  \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}}  \\
  \SetRowColor{white}
  \vspace{-5pt}
  %\includegraphics[width=48px,height=48px]{dave.jpeg}
  Measure your website readability!\\
  www.readability-score.com
\end{tabulary}
\end{multicols}}




\begin{document}
\raggedright
\raggedcolumns

% Set font size to small. Switch to any value
% from this page to resize cheat sheet text:
% www.emerson.emory.edu/services/latex/latex_169.html
\footnotesize % Small font.

\begin{multicols*}{2}

\begin{tabularx}{8.4cm}{x{1.76 cm} x{6.24 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{build custom element}}  \tn
% Row 0
\SetRowColor{LightBackground}
Polymer 1.x & Polymer(\{\}) \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
Polymer 2.0 & class MyElement extends Polymer.Element \{\} \tn 
% Row Count 4 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{x{3.04 cm} x{4.96 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{API}}  \tn
% Row 0
\SetRowColor{LightBackground}
\seqsplit{this.shadowRoot} & get shadow DOM \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
\seqsplit{this.\$.container} & access identifier \#container \tn 
% Row Count 3 (+ 2)
% Row 2
\SetRowColor{LightBackground}
\textless{}template is="dom-bind"\textgreater{} & use Polymer bindings without defining a new custom element \tn 
% Row Count 6 (+ 3)
% Row 3
\SetRowColor{white}
\$\$(selector) & Returns the first node in this element's local DOM that matches selector \tn 
% Row Count 10 (+ 4)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{8.4cm}}{instance methods \seqsplit{https://www.polymer-project.org/1.0/docs/devguide/instance-methods}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Instance Methods}}  \tn
% Row 0
\SetRowColor{LightBackground}
fire(type, {[}detail{]}, {[}options{]}) & Fires a custom event \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
async(method, {[}wait{]}) & Calls method asynchronously \tn 
% Row Count 4 (+ 2)
% Row 2
\SetRowColor{LightBackground}
debounce(jobName, callback, {[}wait{]}) & Call debounce to collapse multiple requests for a named task into one invocation \tn 
% Row Count 8 (+ 4)
% Row 3
\SetRowColor{white}
\seqsplit{toggleAttribute(name}, bool, {[}node{]}) & toggles the named boolean attribute \tn 
% Row Count 10 (+ 2)
% Row 4
\SetRowColor{LightBackground}
\seqsplit{this.transform('rotateX(90deg)'}, this.\$.myDiv) & Applies a CSS transform to the specified node, or host element if no node is specified \tn 
% Row Count 15 (+ 5)
% Row 5
\SetRowColor{white}
resolveUrl(url) & returns a path relative to the current document \tn 
% Row Count 18 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\SetRowColor{LightBackground}
\mymulticolumn{2}{x{8.4cm}}{instance methods \seqsplit{https://www.polymer-project.org/1.0/docs/devguide/instance-methods}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{property list for polymer base}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{} \tn 
% Row Count 0 (+ 0)
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{\seqsplit{https://www.polymer-project.org/1.0/docs/api/Polymer.Base}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Polymer.Templatizer behavior}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{// Get a template from somewhere, e.g. light DOM \newline var template = \seqsplit{Polymer.dom(this).querySelector('template');} \newline // Prepare the template \newline this.templatize(template); \newline // Instance the template with an initial data model \newline var instance = this.stamp(\{myProp: 'initial'\}); \newline // Insert the instance's DOM somewhere, e.g. light DOM \newline Polymer.dom(this).appendChild(instance.root); \newline // Changing a property on the instance will propagate to bindings \newline // in the template \newline instance.myProp = 'new value';} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{The Polymer.Templatizer behavior adds methods to generate instances of templates that are each managed by an anonymous Polymer.Base instance. \newline  \newline https://www.polymer-project.org/1.0/docs/api/Polymer.Templatizer}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Lifecycle}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{created} \tn 
% Row Count 1 (+ 1)
% Row 1
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{ready} \tn 
% Row Count 2 (+ 1)
% Row 2
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{attached} \tn 
% Row Count 3 (+ 1)
% Row 3
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{detached} \tn 
% Row Count 4 (+ 1)
% Row 4
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{attributeChanged} \tn 
% Row Count 5 (+ 1)
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Property name to attribute name mapping}}  \tn
% Row 0
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{Attribute names are converted to lowercase property names} \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
\mymulticolumn{1}{x{8.4cm}}{Attribute names with dashes are converted to camelCase property names} \tn 
% Row Count 4 (+ 2)
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{Properties \seqsplit{https://www.polymer-project.org/1.0/docs/devguide/properties}}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Custom CSS properties}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{.title \{ \newline     color: var(-{}-my-toolbar-title-color); \newline  \}} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{value of the property will inherit down to the toolbar where it is used if defined \newline  \newline https://www.polymer-project.org/1.0/docs/devguide/styling}  \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{x{1.36 cm} x{6.64 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Declared properties}}  \tn
% Row 0
\SetRowColor{LightBackground}
\seqsplit{computed} & The value is interpreted as a method name and argument list \tn 
% Row Count 2 (+ 2)
% Row 1
\SetRowColor{white}
\seqsplit{observer} & The value is interpreted as a method name to be invoked when the property value changes \tn 
% Row Count 5 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Configuring default property values}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{Polymer(\{ \newline  \newline   is: 'x-custom', \newline  \newline   properties: \{ \newline  \newline     mode: \{ \newline       type: String, \newline       value: 'auto' \newline     \}, \newline  \newline     data: \{ \newline       type: Object, \newline       notify: true, \newline       value: function() \{ return \{\}; \} \newline     \} \newline  \newline   \} \newline  \newline \});} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} }
\SetRowColor{DarkBackground}
\mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Style}}  \tn
% Row 0
\SetRowColor{LightBackground}
:host ::content div & must have a selector to the left of the ::content pseudo-element \tn 
% Row Count 4 (+ 4)
% Row 1
\SetRowColor{white}
-{}-my-toolbar-title-color & These custom properties can be defined and will propogate  down the composed DOM tree \tn 
% Row Count 9 (+ 5)
% Row 2
\SetRowColor{LightBackground}
color: var(-{}-my-toolbar-title-color, blue) & include a default value in the var() function \tn 
% Row Count 12 (+ 3)
\hhline{>{\arrayrulecolor{DarkBackground}}--}
\end{tabularx}
\par\addvspace{1.3em}

\begin{tabularx}{8.4cm}{X}
\SetRowColor{DarkBackground}
\mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Custom CSS mixins}}  \tn
\SetRowColor{LightBackground}
\mymulticolumn{1}{x{8.4cm}}{// example \newline \textless{}dom-module id="my-toolbar"\textgreater{} \newline  \newline   \textless{}template\textgreater{} \newline  \newline     \textless{}style\textgreater{} \newline       :host \{ \newline         padding: 4px; \newline         background-color: gray; \newline         /{\emph{ apply a mixin }}/ \newline         @apply(-{}-my-toolbar-theme); \newline       \} \newline       .title \{ \newline         @apply(-{}-my-toolbar-title-theme); \newline       \} \newline     \textless{}/style\textgreater{} \newline  \newline     \textless{}span class="title"\textgreater{}\{\{title\}\}\textless{}/span\textgreater{} \newline  \newline   \textless{}/template\textgreater{} \newline  \newline   ... \newline  \newline \textless{}/dom-module\textgreater{} \newline  \newline // example usage  \newline \textless{}dom-module id="my-element"\textgreater{} \newline  \newline   \textless{}template\textgreater{} \newline  \newline     \textless{}style\textgreater{} \newline       /{\emph{ Apply custom theme to toolbars }}/ \newline       :host \{ \newline         -{}-my-toolbar-theme: \{ \newline           background-color: green; \newline           border-radius: 4px; \newline           border: 1px solid gray; \newline         \}; \newline         -{}-my-toolbar-title-theme: \{ \newline           color: green; \newline         \}; \newline       \} \newline  \newline       /{\emph{ Make only toolbars with the .warning class red and bold }}/ \newline       .warning \{ \newline         -{}-my-toolbar-title-theme: \{ \newline           color: red; \newline           font-weight: bold; \newline         \}; \newline       \} \newline     \textless{}/style\textgreater{} \newline  \newline     \textless{}my-toolbar title="This one is green."\textgreater{}\textless{}/my-toolbar\textgreater{} \newline     \textless{}my-toolbar title="This one is green too."\textgreater{}\textless{}/my-toolbar\textgreater{} \newline  \newline     \textless{}my-toolbar class="warning" title="This one is red."\textgreater{}\textless{}/my-toolbar\textgreater{} \newline  \newline   \textless{}/template\textgreater{} \newline  \newline   \textless{}script\textgreater{} \newline     Polymer(\{ is: 'my-element'\}); \newline   \textless{}/script\textgreater{} \newline  \newline \textless{}/dom-module\textgreater{}} \tn 
\hhline{>{\arrayrulecolor{DarkBackground}}-}
\end{tabularx}
\par\addvspace{1.3em}


% That's all folks
\end{multicols*}

\end{document}