\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{awesomebox}[2016/11/22 v0.1]

% Awesome Box has been written by Étienne Deparis and is released under
% the WTFPL (http://www.wtfpl.net/txt/copying/).
% A copy of this license is distributed in this package.


\RequirePackage{ifxetex,ifluatex}
\newif\ifawesomebox@notxetex\awesomebox@notxetextrue
\ifxetex
  \awesomebox@notxetexfalse
\else
  \ifluatex
    \awesomebox@notxetexfalse
  \fi
\fi

\ifawesomebox@notxetex
\PackageError{awesomebox}{%
  You are trying to use awesomebox\MessageBreak
  with something else than xelatex or luatex
}{%
  Please abort now with <ctrl+d>
}
\fi

% This package heavily uses the work of Honza Ustohal, known under the
% name FontAwesome bindings for (Xe)LaTeX:
% https://gist.github.com/sway/3101743
%
% Translation of FontAwesome's private range characters into XeTeX
% symbols. All icons are camel-cased and prefixed with 'abIcon', i.e. what
% was .icon-align-center the CSS version of FontAwesome becomes
% \abIconAlignCenter
%
% New icons code could be retrieve from this page
% http://fontawesome.io/cheatsheet/

\def\abIconCheck{\symbol{"F00C}}
\def\abIconInfoCircle{\symbol{"F05A}}
\def\abIconFire{\symbol{"F06D}}
\def\abIconExclamationCircle{\symbol{"F06A}}
\def\abIconExclamationTriangle{\symbol{"F071}}
\def\abIconCogs{\symbol{"F085}}
\def\abIconThumbsUp{\symbol{"F087}}
\def\abIconThumbsDown{\symbol{"F088}}
\def\abIconCertificate{\symbol{"F0A3}}
\def\abIconLightBulb{\symbol{"F0EB}}
\def\abIconTwitter{\symbol{"F099}}
\def\abIconGithub{\symbol{"F09B}}

\RequirePackage{xltxtra}
\newfontfamily{\ABFamily}{FontAwesome}

% Some basic colors
\RequirePackage{xcolor}
\definecolor{abnote}{RGB}{25,64,122}
\definecolor{abcaution}{RGB}{188,50,0}
\definecolor{abwarning}{RGB}{188,103,0}
\definecolor{abimportant}{RGB}{188,0,0}

\newlength{\aweboxleftmargin}
\setlength{\aweboxleftmargin}{9mm}
\newlength{\aweboxvskip}
\setlength{\aweboxvskip}{5mm}
\newlength{\aweboxsignraise}
\setlength{\aweboxsignraise}{-5mm}
\newlength{\aweboxrulewidth}
\setlength{\aweboxrulewidth}{2pt}

\RequirePackage{tabularx}

% \awesomebox{icon}{rulewidth}{color}{content}
\newcommand{\awesomebox}[4]{%
  \vspace{\aweboxvskip}
  \noindent
  \begin{tabularx}{\textwidth}{%
      m{\aweboxleftmargin}!{\color{#3}\vrule width #2}X}
    \raisebox{\aweboxsignraise}{\textcolor{#3}{\Huge\ABFamily#1}} & #4 \\
  \end{tabularx}
  \vspace{\aweboxvskip}}

\newcommand{\notebox}[1]{%
  \awesomebox{\abIconInfoCircle}{\aweboxrulewidth}{abnote}{#1}}

\newcommand{\tipbox}[1]{%
  \awesomebox{\abIconLightBulb}{\aweboxrulewidth}{black}{#1}}

\newcommand{\warningbox}[1]{%
  \awesomebox{\abIconExclamationTriangle}{\aweboxrulewidth}{abwarning}{#1}}

\newcommand{\cautionbox}[1]{%
  \awesomebox{\abIconFire}{\aweboxrulewidth}{abcaution}{#1}}

\newcommand{\importantbox}[1]{%
  \awesomebox{\abIconExclamationCircle}{\aweboxrulewidth}{abimportant}{#1}}
\endinput
