From 711a85c0dafd17aae2c22e1777c8be526bc224de Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Mon, 15 Apr 2024 14:29:46 +0200 Subject: [PATCH 01/20] Set default version to 5.0.0 --- lib/bitstyles_phoenix/bitstyles.ex | 16 ++++++++++++---- scripts/generate_version_showcase.ex | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/bitstyles_phoenix/bitstyles.ex b/lib/bitstyles_phoenix/bitstyles.ex index 3c25aba..ad88db0 100644 --- a/lib/bitstyles_phoenix/bitstyles.ex +++ b/lib/bitstyles_phoenix/bitstyles.ex @@ -1,7 +1,7 @@ defmodule BitstylesPhoenix.Bitstyles do @moduledoc false - @default_version "4.3.0" + @default_version "5.0.0" @cdn_url "https://cdn.jsdelivr.net/npm/bitstyles" def cdn_url do @@ -14,12 +14,20 @@ defmodule BitstylesPhoenix.Bitstyles do """ def classname(name), do: classname(name, version()) - def classname(class, version) when version > "4.3.0" do + def classname(class, version) when version > "5.0.0" do IO.warn("Version #{version} of bitstyles is not yet supported") class end - def classname(class, version) when version >= "4.2.0", do: class + def classname(class, version) when version >= "5.0.0" do + class + end + + def classname(class, version) when version >= "4.3.0" do + # TODO + mapping = %{} + classname(mapping, "5.0.0") + end def classname(class, version) when version >= "4.0.0" do mapping = @@ -28,7 +36,7 @@ defmodule BitstylesPhoenix.Bitstyles do _ -> class end - classname(mapping, "4.2.0") + classname(mapping, "4.3.0") end def classname(class, version) when version >= "2.0.0" do diff --git a/scripts/generate_version_showcase.ex b/scripts/generate_version_showcase.ex index d1c9c20..aee396e 100644 --- a/scripts/generate_version_showcase.ex +++ b/scripts/generate_version_showcase.ex @@ -7,6 +7,7 @@ defmodule Scripts.GenerateVersionShowcase do @moduledoc "Generates static HTML pages in #{@dir_name} for manually testing bitstyles_phoenix with different bitstyles versions." @all_supported_bitstyles_versions [ + "5.0.0", "4.3.0", "4.2.0", "4.1.0", From da54bc92751bc6aa06319584501ecb17bd7d5846 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Mon, 15 Apr 2024 14:40:41 +0200 Subject: [PATCH 02/20] Fix existing tests --- lib/bitstyles_phoenix/bitstyles.ex | 11 +++--- lib/bitstyles_phoenix/component/dropdown.ex | 27 +++++++++++++ lib/bitstyles_phoenix/component/error.ex | 14 +++++++ test/bitstyles_phoenix/bitstyles_test.exs | 44 +++++++++++++++++++-- 4 files changed, 88 insertions(+), 8 deletions(-) diff --git a/lib/bitstyles_phoenix/bitstyles.ex b/lib/bitstyles_phoenix/bitstyles.ex index ad88db0..746ed90 100644 --- a/lib/bitstyles_phoenix/bitstyles.ex +++ b/lib/bitstyles_phoenix/bitstyles.ex @@ -20,13 +20,14 @@ defmodule BitstylesPhoenix.Bitstyles do end def classname(class, version) when version >= "5.0.0" do - class + # TODO + case class do + _ -> class + end end - def classname(class, version) when version >= "4.3.0" do - # TODO - mapping = %{} - classname(mapping, "5.0.0") + def classname(class, version) when version >= "4.2.0" do + classname(class, "5.0.0") end def classname(class, version) when version >= "4.0.0" do diff --git a/lib/bitstyles_phoenix/component/dropdown.ex b/lib/bitstyles_phoenix/component/dropdown.ex index dda83c6..34a7f21 100644 --- a/lib/bitstyles_phoenix/component/dropdown.ex +++ b/lib/bitstyles_phoenix/component/dropdown.ex @@ -66,6 +66,33 @@ defmodule BitstylesPhoenix.Component.Dropdown do ...> """ ''', [ + "5.0.0": ''' + """ +
+ + +
+ """ + ''', "4.3.0": ''' """
diff --git a/lib/bitstyles_phoenix/component/error.ex b/lib/bitstyles_phoenix/component/error.ex index 066f824..8835498 100644 --- a/lib/bitstyles_phoenix/component/error.ex +++ b/lib/bitstyles_phoenix/component/error.ex @@ -31,6 +31,13 @@ defmodule BitstylesPhoenix.Component.Error do ...> <.ui_errors form={@form} field={:name} /> ...> """ ''', + "5.0.0": ''' + """ + + is too short + + """ + ''', "4.3.0": ''' """ @@ -131,6 +138,13 @@ defmodule BitstylesPhoenix.Component.Error do ...> <.ui_error error={{"Foo error", []}} /> ...> """ ''', + "5.0.0": ''' + """ + + Foo error + + """ + ''', "4.3.0": ''' """ diff --git a/test/bitstyles_phoenix/bitstyles_test.exs b/test/bitstyles_phoenix/bitstyles_test.exs index ce3df7c..a6d84a8 100644 --- a/test/bitstyles_phoenix/bitstyles_test.exs +++ b/test/bitstyles_phoenix/bitstyles_test.exs @@ -4,13 +4,51 @@ defmodule BitstylesPhoenix.BitstylesTest do import ExUnit.CaptureIO describe "classname/2" do - test "version 5.0.0" do + test "version 6.0.0" do assert Regex.match?( - ~r/5.0.0 of bitstyles is not yet supported/, - capture_io(:stderr, fn -> classname("u-flex", "5.0.0") end) + ~r/6.0.0 of bitstyles is not yet supported/, + capture_io(:stderr, fn -> classname("u-flex", "6.0.0") end) ) end + test "version 5.0.0" do + assert classname("u-flex", "5.0.0") == "u-flex" + assert classname("u-border-radius-0", "5.0.0") == "u-border-radius-0" + assert classname("u-overflow-x-auto", "5.0.0") == "u-overflow-x-auto" + assert classname("u-overflow-y-auto", "5.0.0") == "u-overflow-y-auto" + assert classname("u-bg-gray-80", "5.0.0") == "u-bg-gray-80" + assert classname("u-fg-warning", "5.0.0") == "u-fg-warning" + assert classname("u-font-medium", "5.0.0") == "u-font-medium" + assert classname("u-line-height-min", "5.0.0") == "u-line-height-min" + assert classname("u-text-right", "5.0.0") == "u-text-right" + assert classname("u-flex-shrink-0", "5.0.0") == "u-flex-shrink-0" + assert classname("u-flex-grow-1", "5.0.0") == "u-flex-grow-1" + assert classname("u-flex-wrap", "5.0.0") == "u-flex-wrap" + assert classname("u-flex-col", "5.0.0") == "u-flex-col" + assert classname("u-grid-cols-3", "5.0.0") == "u-grid-cols-3" + assert classname("u-col-span-3", "5.0.0") == "u-col-span-3" + assert classname("u-col-start-1", "5.0.0") == "u-col-start-1" + end + + test "version 4.3.0" do + assert classname("u-flex", "4.3.0") == "u-flex" + assert classname("u-border-radius-0", "4.3.0") == "u-border-radius-0" + assert classname("u-overflow-x-auto", "4.3.0") == "u-overflow-x-auto" + assert classname("u-overflow-y-auto", "4.3.0") == "u-overflow-y-auto" + assert classname("u-bg-gray-80", "4.3.0") == "u-bg-gray-80" + assert classname("u-fg-warning", "4.3.0") == "u-fg-warning" + assert classname("u-font-medium", "4.3.0") == "u-font-medium" + assert classname("u-line-height-min", "4.3.0") == "u-line-height-min" + assert classname("u-text-right", "4.3.0") == "u-text-right" + assert classname("u-flex-shrink-0", "4.3.0") == "u-flex-shrink-0" + assert classname("u-flex-grow-1", "4.3.0") == "u-flex-grow-1" + assert classname("u-flex-wrap", "4.3.0") == "u-flex-wrap" + assert classname("u-flex-col", "4.3.0") == "u-flex-col" + assert classname("u-grid-cols-3", "4.3.0") == "u-grid-cols-3" + assert classname("u-col-span-3", "4.3.0") == "u-col-span-3" + assert classname("u-col-start-1", "4.3.0") == "u-col-start-1" + end + test "version 4.2.0" do assert classname("u-border-radius-0", "4.2.0") == "u-border-radius-0" end From f6652320cb66fd74699067d96b7ac56f0bb4bfe6 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Tue, 16 Apr 2024 08:11:29 +0200 Subject: [PATCH 03/20] Transform sizing classes --- lib/bitstyles_phoenix/bitstyles.ex | 19 ++++++++++++++----- test/bitstyles_phoenix/bitstyles_test.exs | 14 ++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/lib/bitstyles_phoenix/bitstyles.ex b/lib/bitstyles_phoenix/bitstyles.ex index 746ed90..137970a 100644 --- a/lib/bitstyles_phoenix/bitstyles.ex +++ b/lib/bitstyles_phoenix/bitstyles.ex @@ -20,14 +20,23 @@ defmodule BitstylesPhoenix.Bitstyles do end def classname(class, version) when version >= "5.0.0" do - # TODO - case class do - _ -> class - end + class end def classname(class, version) when version >= "4.2.0" do - classname(class, "5.0.0") + sizes_renaming = %{ + "3xs" => "xxxs", + "2xs" => "xxs", + "2xl" => "xxl", + "3xl" => "xxxl" + } + + mapping = + Enum.reduce(sizes_renaming, class, fn {new_size, old_size}, acc -> + String.replace(acc, "-#{new_size}", "-#{old_size}") + end) + + classname(mapping, "5.0.0") end def classname(class, version) when version >= "4.0.0" do diff --git a/test/bitstyles_phoenix/bitstyles_test.exs b/test/bitstyles_phoenix/bitstyles_test.exs index a6d84a8..24ebd0e 100644 --- a/test/bitstyles_phoenix/bitstyles_test.exs +++ b/test/bitstyles_phoenix/bitstyles_test.exs @@ -28,6 +28,13 @@ defmodule BitstylesPhoenix.BitstylesTest do assert classname("u-grid-cols-3", "5.0.0") == "u-grid-cols-3" assert classname("u-col-span-3", "5.0.0") == "u-col-span-3" assert classname("u-col-start-1", "5.0.0") == "u-col-start-1" + assert classname("u-margin-2xs", "5.0.0") == "u-margin-2xs" + assert classname("u-margin-3xs\@m", "5.0.0") == "u-margin-3xs\@m" + assert classname("u-margin-3xs-bottom", "5.0.0") == "u-margin-3xs-bottom" + assert classname("u-padding-2xl", "5.0.0") == "u-padding-2xl" + assert classname("u-padding-3xl\@l", "5.0.0") == "u-padding-3xl\@l" + assert classname("u-margin-3xl-bottom", "5.0.0") == "u-margin-3xl-bottom" + assert classname("u-margin-neg-3xl-bottom", "5.0.0") == "u-margin-neg-3xl-bottom" end test "version 4.3.0" do @@ -47,6 +54,13 @@ defmodule BitstylesPhoenix.BitstylesTest do assert classname("u-grid-cols-3", "4.3.0") == "u-grid-cols-3" assert classname("u-col-span-3", "4.3.0") == "u-col-span-3" assert classname("u-col-start-1", "4.3.0") == "u-col-start-1" + assert classname("u-margin-2xs", "4.3.0") == "u-margin-xxs" + assert classname("u-margin-3xs\@m", "4.3.0") == "u-margin-xxxs\@m" + assert classname("u-margin-3xs-bottom", "4.3.0") == "u-margin-xxxs-bottom" + assert classname("u-padding-2xl", "4.3.0") == "u-padding-xxl" + assert classname("u-padding-3xl\@l", "4.3.0") == "u-padding-xxxl\@l" + assert classname("u-margin-3xl-bottom", "4.3.0") == "u-margin-xxxl-bottom" + assert classname("u-margin-neg-3xl-bottom", "4.3.0") == "u-margin-neg-xxxl-bottom" end test "version 4.2.0" do From a1cf049bcea75e329c1d7c77323e023b751b51c7 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Tue, 16 Apr 2024 08:34:48 +0200 Subject: [PATCH 04/20] placekitten.com does not work anymore --- lib/bitstyles_phoenix/component/avatar.ex | 16 ++++++++-------- lib/bitstyles_phoenix/component/sidebar.ex | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/bitstyles_phoenix/component/avatar.ex b/lib/bitstyles_phoenix/component/avatar.ex index 80e50bc..8615943 100644 --- a/lib/bitstyles_phoenix/component/avatar.ex +++ b/lib/bitstyles_phoenix/component/avatar.ex @@ -19,14 +19,14 @@ defmodule BitstylesPhoenix.Component.Avatar do ''' iex> assigns = %{} ...> render ~H""" - ...> <.ui_avatar src="https://placekitten.com/100/100" alt="Username’s avatar"/> + ...> <.ui_avatar src="https://placehold.co/100x100" alt="Username’s avatar"/> ...> """ ''', ''' """
- Username’s avatar + Username’s avatar
""" @@ -38,14 +38,14 @@ defmodule BitstylesPhoenix.Component.Avatar do ''' iex> assigns = %{} ...> render ~H""" - ...> <.ui_avatar src="https://placekitten.com/100/100" class="foo bar" alt="Username’s avatar"/> + ...> <.ui_avatar src="https://placehold.co/100x100" class="foo bar" alt="Username’s avatar"/> ...> """ ''', ''' """
- Username’s avatar + Username’s avatar
""" @@ -57,14 +57,14 @@ defmodule BitstylesPhoenix.Component.Avatar do ''' iex> assigns = %{} ...> render ~H""" - ...> <.ui_avatar size="l" src="https://placekitten.com/100/100" alt="Username’s avatar" height="46" width="46"/> + ...> <.ui_avatar size="l" src="https://placehold.co/100x100" alt="Username’s avatar" height="46" width="46"/> ...> """ ''', ''' """
- Username’s avatar + Username’s avatar
""" @@ -76,14 +76,14 @@ defmodule BitstylesPhoenix.Component.Avatar do ''' iex> assigns = %{} ...> render ~H""" - ...> <.ui_avatar src="https://placekitten.com/100/100" alt="Username’s avatar"> Username + ...> <.ui_avatar src="https://placehold.co/100x100" alt="Username’s avatar"> Username ...> """ ''', ''' """
- Username’s avatar + Username’s avatar
Username diff --git a/lib/bitstyles_phoenix/component/sidebar.ex b/lib/bitstyles_phoenix/component/sidebar.ex index 1316679..0aeeec4 100644 --- a/lib/bitstyles_phoenix/component/sidebar.ex +++ b/lib/bitstyles_phoenix/component/sidebar.ex @@ -24,7 +24,7 @@ defmodule BitstylesPhoenix.Component.Sidebar do ...> <.ui_dropdown variant={["top", "full-width"]}> ...> <:button variant="nav-large"> ...>
- ...> Jane Dobermann’s avatar + ...> Jane Dobermann’s avatar ...>
...> Jane Dobermann ...> @@ -64,7 +64,7 @@ defmodule BitstylesPhoenix.Component.Sidebar do
From 0941c089c753b45b4f815c9c424532eb155bfae4 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Mon, 1 Jul 2024 12:57:10 +0200 Subject: [PATCH 08/20] Fix u-gap-m is missing --- lib/bitstyles_phoenix/bitstyles.ex | 1 + lib/bitstyles_phoenix/component/description_list.ex | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/bitstyles_phoenix/bitstyles.ex b/lib/bitstyles_phoenix/bitstyles.ex index 26a6b07..6e92ab5 100644 --- a/lib/bitstyles_phoenix/bitstyles.ex +++ b/lib/bitstyles_phoenix/bitstyles.ex @@ -40,6 +40,7 @@ defmodule BitstylesPhoenix.Bitstyles do case class do "u-list-none" -> "a-list-reset" "a-badge--text" -> "a-badge--gray" + "u-gap-l" -> "u-gap-m" class -> class end diff --git a/lib/bitstyles_phoenix/component/description_list.ex b/lib/bitstyles_phoenix/component/description_list.ex index 62be529..44920f8 100644 --- a/lib/bitstyles_phoenix/component/description_list.ex +++ b/lib/bitstyles_phoenix/component/description_list.ex @@ -19,7 +19,7 @@ defmodule BitstylesPhoenix.Component.DescriptionList do ''' """
-
+
Length
@@ -27,7 +27,7 @@ defmodule BitstylesPhoenix.Component.DescriptionList do 8
-
+
Inserted at
@@ -63,7 +63,7 @@ defmodule BitstylesPhoenix.Component.DescriptionList do ''' """
-
+
Length
@@ -71,7 +71,7 @@ defmodule BitstylesPhoenix.Component.DescriptionList do 8
-
+
Some
@@ -79,7 +79,7 @@ defmodule BitstylesPhoenix.Component.DescriptionList do Tag
-
+
                 Tag
@@ -136,7 +136,7 @@ defmodule BitstylesPhoenix.Component.DescriptionList do
     assigns = assign(assigns, extra: extra)
 
     ~H"""
-      
+
<%= if assigns[:label] do %> <.ui_dt><%= @label %> <.ui_dd><%= assigns[:value] || render_slot(@inner_block) %> From d6cdae33b463fce16ca65145458d91e041529597 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Mon, 1 Jul 2024 13:32:53 +0200 Subject: [PATCH 09/20] Fix fg and bg colors --- lib/bitstyles_phoenix/alpine3/sidebar.ex | 4 ++-- lib/bitstyles_phoenix/bitstyles.ex | 4 ++++ .../component/breadcrumbs.ex | 20 +++++++++---------- .../component/description_list.ex | 12 +++++------ lib/bitstyles_phoenix/component/sidebar.ex | 16 +++++++-------- 5 files changed, 30 insertions(+), 26 deletions(-) diff --git a/lib/bitstyles_phoenix/alpine3/sidebar.ex b/lib/bitstyles_phoenix/alpine3/sidebar.ex index 328554f..f65749e 100644 --- a/lib/bitstyles_phoenix/alpine3/sidebar.ex +++ b/lib/bitstyles_phoenix/alpine3/sidebar.ex @@ -54,7 +54,7 @@ defmodule BitstylesPhoenix.Alpine3.Sidebar do