Skip to content

Instantly share code, notes, and snippets.

@lnr0626
lnr0626 / tailwind-phx-live.plugin.js
Last active June 7, 2021 22:27
Tailwind plugin adding variants for phx loading events
const _ = require('lodash');
const plugin = require('tailwindcss/plugin');
module.exports = plugin(({ addVariant, theme, e }) => {
const events = theme('phxLive.events', []);
_.forEach(events, (event) => {
addVariant(`phx-${event}-loading`, ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `.${e(`phx-${event}-loading`)}.${e(`${event}-loading${separator}${className}`)}`;
@lnr0626
lnr0626 / heroicons_with_surface.ex
Last active October 17, 2020 13:37
A module for handling svg icons both with and without surface
defmodule HeroiconWithSurface do
@moduledoc """
This assumes https://github.com/tailwindlabs/heroicons has been cloned as a submodule to svgs/heroicons
Examples:
<#HeroiconWithSurface variant="outline" icon="phone" class="w-5 h-5" />
<%= HeroiconWithSurface.svg({"outline", "phone"}, class: "w-5 h-5") %>
"""
use SvgIcons,