diff --git a/assets/css/components/avatar.css b/assets/css/components/avatar.css index 74e76cd17..8772c6a81 100644 --- a/assets/css/components/avatar.css +++ b/assets/css/components/avatar.css @@ -21,23 +21,23 @@ /* Avatar - sizes */ .atomic-avatar--xs { - @apply h-8 w-8 text-xs; + @apply size-8 text-xs; } .atomic-avatar--sm { - @apply h-12 w-12 text-lg; + @apply size-12 text-lg; } .atomic-avatar--md { - @apply h-16 w-16 text-lg; + @apply size-16 text-lg; } .atomic-avatar--lg { - @apply h-20 w-20 text-4xl; + @apply size-20 text-4xl; } .atomic-avatar--xl { - @apply h-24 w-24 text-4xl; + @apply size-24 text-4xl; } /* Avatar - colors */ diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js index a89824018..36902c3c6 100644 --- a/assets/tailwind.config.js +++ b/assets/tailwind.config.js @@ -1,6 +1,9 @@ const colors = require("tailwindcss/colors"); const plugin = require('tailwindcss/plugin'); +const fs = require("fs"); +const path = require("path"); + module.exports = { darkMode: 'selector', content: [ @@ -25,23 +28,23 @@ module.exports = { }, keyframes: { wave: { - '0%': { transform: 'rotate(0.0deg)' }, - '15%': { transform: 'rotate(14.0deg)' }, - '30%': { transform: 'rotate(-8.0deg)' }, - '40%': { transform: 'rotate(14.0deg)' }, - '50%': { transform: 'rotate(-4.0deg)' }, - '60%': { transform: 'rotate(10.0deg)' }, - '70%': { transform: 'rotate(0.0deg)' }, - '100%': { transform: 'rotate(0.0deg)' }, + '0%': { transform: 'rotate(0.0deg)' }, + '15%': { transform: 'rotate(14.0deg)' }, + '30%': { transform: 'rotate(-8.0deg)' }, + '40%': { transform: 'rotate(14.0deg)' }, + '50%': { transform: 'rotate(-4.0deg)' }, + '60%': { transform: 'rotate(10.0deg)' }, + '70%': { transform: 'rotate(0.0deg)' }, + '100%': { transform: 'rotate(0.0deg)' }, }, progress: { - '0%': { width: '0%' }, - '100%': { width: '100%' }, + '0%': { width: '0%' }, + '100%': { width: '100%' }, } }, animation: { - wave: 'wave 1.5s infinite', - progress: 'progress 5s linear 1' + wave: 'wave 1.5s infinite', + progress: 'progress 5s linear 1' }, backgroundSize: { '75': '75%' @@ -50,9 +53,55 @@ module.exports = { }, plugins: [ require('@tailwindcss/forms'), + + // Allows prefixing tailwind classes with LiveView classes to add rules + // only when LiveView classes are applied, for example: + // + //
+ // plugin(({addVariant}) => addVariant('phx-no-feedback', ['&.phx-no-feedback', '.phx-no-feedback &'])), plugin(({addVariant}) => addVariant('phx-click-loading', ['&.phx-click-loading', '.phx-click-loading &'])), plugin(({addVariant}) => addVariant('phx-submit-loading', ['&.phx-submit-loading', '.phx-submit-loading &'])), - plugin(({addVariant}) => addVariant('phx-change-loading', ['&.phx-change-loading', '.phx-change-loading &'])) + plugin(({addVariant}) => addVariant('phx-change-loading', ['&.phx-change-loading', '.phx-change-loading &'])), + + // Embeds Heroicons (https://heroicons.com) into app.css bundle + plugin(function({matchComponents, theme}) { + let iconsDir = path.join(__dirname, "../deps/heroicons/optimized") + let values = {} + let icons = [ + ["", "/24/outline"], + ["-solid", "/24/solid"], + ["-mini", "/20/solid"], + ["-micro", "/16/solid"] + ] + icons.forEach(([suffix, dir]) => { + fs.readdirSync(path.join(iconsDir, dir)).forEach(file => { + let name = path.basename(file, ".svg") + suffix + values[name] = {name, fullPath: path.join(iconsDir, dir, file)} + }) + }) + matchComponents({ + "hero": ({name, fullPath}) => { + let content = fs.readFileSync(fullPath).toString().replace(/\r?\n|\r/g, "") + let size = theme("spacing.6") + if (name.endsWith("-mini")) { + size = theme("spacing.5") + } else if (name.endsWith("-micro")) { + size = theme("spacing.4") + } + return { + [`--hero-${name}`]: `url('data:image/svg+xml;utf8,${content}')`, + "-webkit-mask": `var(--hero-${name})`, + "mask": `var(--hero-${name})`, + "mask-repeat": "no-repeat", + "background-color": "currentColor", + "vertical-align": "middle", + "display": "inline-block", + "width": size, + "height": size + } + } + }, {values}) + }) ] } diff --git a/lib/atomic/schema.ex b/lib/atomic/schema.ex index 068dc3aa6..9f890413a 100644 --- a/lib/atomic/schema.ex +++ b/lib/atomic/schema.ex @@ -2,16 +2,16 @@ defmodule Atomic.Schema do @moduledoc """ The application Schema for all the modules, providing Ecto.UUIDs as default id. """ - alias Atomic.Time + use Gettext, backend: AtomicWeb.Gettext - import AtomicWeb.Gettext + alias Atomic.Time defmacro __using__(_) do quote do use Ecto.Schema use Waffle.Ecto.Schema + use Gettext, backend: AtomicWeb.Gettext - import AtomicWeb.Gettext import Ecto.Changeset import Ecto.Query diff --git a/lib/atomic_web.ex b/lib/atomic_web.ex index 53f6c7367..58d46de71 100644 --- a/lib/atomic_web.ex +++ b/lib/atomic_web.ex @@ -20,9 +20,10 @@ defmodule AtomicWeb do def controller do quote do use Phoenix.Controller, namespace: AtomicWeb + use Gettext, backend: AtomicWeb.Gettext import Plug.Conn - import AtomicWeb.Gettext + alias AtomicWeb.Router.Helpers, as: Routes end end @@ -80,7 +81,7 @@ defmodule AtomicWeb do def channel do quote do use Phoenix.Channel - import AtomicWeb.Gettext + use Gettext, backend: AtomicWeb.Gettext end end @@ -99,8 +100,10 @@ defmodule AtomicWeb do # Import basic rendering functionality (render, render_layout, etc) import Phoenix.View + # Custom imports + use Gettext, backend: AtomicWeb.Gettext + import AtomicWeb.ErrorHelpers - import AtomicWeb.Gettext import AtomicWeb.Helpers alias Atomic.Uploaders diff --git a/lib/atomic_web/components/activity.ex b/lib/atomic_web/components/activity.ex index 84ee53e61..cc0e88fc1 100644 --- a/lib/atomic_web/components/activity.ex +++ b/lib/atomic_web/components/activity.ex @@ -46,21 +46,21 @@ defmodule AtomicWeb.Components.Activity do
- <.icon name={:clock} solid class="h-5 w-5" /> + <.icon name="hero-clock-solid" class="size-5" /> <%= relative_datetime(@activity.start) %> starting in - <.icon name={:user_group} solid class="h-5 w-5" /> + <.icon name="hero-user-group-solid" class="size-5" /> <%= @activity.enrolled %>/<%= @activity.maximum_entries %> enrollments - <.icon name={:map_pin} solid class="h-5 w-5" /> + <.icon name="hero-map-pin-solid" class="size-5" /> <%= @activity.location.name %> location diff --git a/lib/atomic_web/components/badge.ex b/lib/atomic_web/components/badge.ex index 309d571fd..f188c3215 100644 --- a/lib/atomic_web/components/badge.ex +++ b/lib/atomic_web/components/badge.ex @@ -24,19 +24,18 @@ defmodule AtomicWeb.Components.Badge do default: :left, doc: "The position of the icon if applicable." - attr :icon, :atom, default: nil, doc: "The icon to display." - - attr :icon_variant, :atom, - default: :outline, - values: [:solid, :outline, :mini], - doc: "The icon variation to display." - + attr :icon, :string, default: nil, doc: "The icon to display." attr :icon_class, :string, default: "", doc: "Additional classes to apply to the icon." attr :class, :string, default: "", doc: "Additional classes to apply to the badge." attr :label, :string, default: nil, doc: "Badge label." - attr :rest, :global - slot :inner_block, required: false + + attr :rest, :global, + include: + ~w(csrf_token disabled download form href hreflang method name navigate patch referrerpolicy rel replace target type value autofocus tabindex), + doc: "Arbitrary HTML or phx attributes." + + slot :inner_block, required: false, doc: "Slot for the content of the badge." def badge(assigns) do ~H""" @@ -50,11 +49,11 @@ defmodule AtomicWeb.Components.Badge do ]} > <%= if @icon && @icon_position == :left do %> - <.icon name={@icon} class={"#{generate_icon_classes(assigns)}"} solid={@icon_variant == :solid} mini={@icon_variant == :mini} /> + <.icon name={@icon} class={"#{generate_icon_classes(assigns)}"} /> <% end %> <%= render_slot(@inner_block) || @label %> <%= if @icon && @icon_position == :right do %> - <.icon name={@icon} class={"#{generate_icon_classes(assigns)}"} solid={@icon_variant == :solid} mini={@icon_variant == :mini} /> + <.icon name={@icon} class={"#{generate_icon_classes(assigns)}"} /> <% end %>
""" diff --git a/lib/atomic_web/components/button.ex b/lib/atomic_web/components/button.ex index 12d441854..b87705367 100644 --- a/lib/atomic_web/components/button.ex +++ b/lib/atomic_web/components/button.ex @@ -45,13 +45,7 @@ defmodule AtomicWeb.Components.Button do default: :left, doc: "The position of the icon if applicable." - attr :icon, :atom, default: nil, doc: "The icon to display." - - attr :icon_variant, :atom, - default: :outline, - values: [:solid, :outline, :mini], - doc: "The icon variation to display." - + attr :icon, :string, default: nil, doc: "The icon to display." attr :icon_class, :string, default: "", doc: "Additional classes to apply to the icon." attr :class, :string, default: "", doc: "Additional classes to apply to the component." @@ -127,7 +121,7 @@ defmodule AtomicWeb.Components.Button do defp icon_content(assigns) do ~H""" - <.icon name={@icon} class={"#{generate_icon_classes(assigns)}"} solid={@icon_variant == :solid} mini={@icon_variant == :mini} /> + <.icon name={@icon} class={"#{generate_icon_classes(assigns)}"} /> """ end diff --git a/lib/atomic_web/components/calendar/calendar.ex b/lib/atomic_web/components/calendar/calendar.ex index 689b0a056..3f1c3cd49 100644 --- a/lib/atomic_web/components/calendar/calendar.ex +++ b/lib/atomic_web/components/calendar/calendar.ex @@ -69,7 +69,7 @@ defmodule AtomicWeb.Components.Calendar do <.link patch={"#{if @mode == "month" do @previous_month_path else @previous_week_path end}"}> <.link patch={"#{if @mode == "month" do @present_month_path else @present_week_path end}"}> @@ -80,7 +80,7 @@ defmodule AtomicWeb.Components.Calendar do <.link patch={"#{if @mode == "month" do @next_month_path else @next_week_path end}"}>
@@ -95,7 +95,7 @@ defmodule AtomicWeb.Components.Calendar do ]} > <:wrapper> - <.button color={:white} icon={:chevron_down} icon_position={:right} icon_variant={:solid}> + <.button color={:white} icon="hero-chevron-down-solid" icon_position={:right}> <%= if @mode == "month" do %> <%= gettext("Month view") %> <% else %> @@ -150,7 +150,7 @@ defmodule AtomicWeb.Components.Calendar do
diff --git a/lib/atomic_web/components/calendar/month.ex b/lib/atomic_web/components/calendar/month.ex index 6717e6ba5..f19675812 100644 --- a/lib/atomic_web/components/calendar/month.ex +++ b/lib/atomic_web/components/calendar/month.ex @@ -61,7 +61,7 @@ defmodule AtomicWeb.Components.CalendarMonth do <.badge variant={:outline} color={:primary} label="Activity" />
@@ -99,7 +99,7 @@ defmodule AtomicWeb.Components.CalendarMonth do