Skip to content

Instantly share code, notes, and snippets.

@sigmasoldi3r
Created February 8, 2018 15:13
Show Gist options
  • Save sigmasoldi3r/28d411918357e04cd2052e5080d519ff to your computer and use it in GitHub Desktop.
Save sigmasoldi3r/28d411918357e04cd2052e5080d519ff to your computer and use it in GitHub Desktop.
Creates a badge similar to shields.io, but bigger. It's intended to be used as HTTP api method reference (Left HTTP Verb, right relative path). Still WIP
% You should include tcolorbox libraries adn raster, with:
% \usepackage[raster]{tcolorbox}
% Also define your own colors or use from xcolor
% Usage is dead simple: \badge{color_and_verb}{relative_path}
% The name of the color is used as left part text! You should define aliases, like:
% \definecolor{POST}{HTML}{97CA00}
% \definecolor{GET}{HTML}{007EC6}
% \definecolor{PUT}{HTML}{DFB317}
% \definecolor{PATCH}{HTML}{9F9F9F}
% \definecolor{DELETE}{HTML}{E05D44}
% Example (Using those aliases): \badge{POST}{/api/developers}
\newcommand{\badge}[2] {
\begin{tcbraster}[raster columns=12,fonttitle=\bfseries]
\begin{tcolorbox}[
raster multicolumn=2,
colupper=white,
halign=flush center,
sharp corners=east,
colback=#1,
size=small,
colframe=black!0
]\strut #1\end{tcolorbox}\begin{tcolorbox}[
raster multicolumn=10,
enlarge left by=-3mm,
colupper=white,
sharp corners=west,
colback=darkgray,
size=small,
colframe=black!0
]\strut #2\end{tcolorbox}
\end{tcbraster}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment