From 24b317c9090b6dc7be8573b54c8d5bde46c8c1be Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Tue, 23 Jul 2024 16:57:23 +0200 Subject: [PATCH] Add dummy example of chained class renames --- lib/bitstyles_phoenix/bitstyles.ex | 4 ++++ test/bitstyles_phoenix/bitstyles_test.exs | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/bitstyles_phoenix/bitstyles.ex b/lib/bitstyles_phoenix/bitstyles.ex index 8d51aac..78d9177 100644 --- a/lib/bitstyles_phoenix/bitstyles.ex +++ b/lib/bitstyles_phoenix/bitstyles.ex @@ -56,6 +56,7 @@ defmodule BitstylesPhoenix.Bitstyles do String.replace(acc, new_border_color, old_border_color) end) + # class from version 5 getting renamed to work for < 5 class = case class do "u-list-none" -> "a-list-reset" @@ -63,6 +64,7 @@ defmodule BitstylesPhoenix.Bitstyles do "u-fg-text" -> "u-fg-gray-30" "u-fg-text-darker" -> "u-fg-gray-50" "u-bg-gray-darker" -> "u-bg-gray-80" + "u-version-5-0-0" -> "u-version-4" class -> class end @@ -101,6 +103,7 @@ defmodule BitstylesPhoenix.Bitstyles do "u-border-radius-" <> variant -> "u-round--#{variant}" "u-overflow-x-auto" -> "u-overflow--x" "u-overflow-y-auto" -> "u-overflow--y" + "u-version-3" -> "u-version-1-5" _ -> class end @@ -114,6 +117,7 @@ defmodule BitstylesPhoenix.Bitstyles do "u-flex-grow-" <> number -> "u-flex__grow-#{number}" "u-flex-wrap" -> "u-flex--wrap" "u-flex-col" -> "u-flex--col" + "u-version-1-5" -> "u-version-1-3" _ -> class end diff --git a/test/bitstyles_phoenix/bitstyles_test.exs b/test/bitstyles_phoenix/bitstyles_test.exs index 5debe21..2d86e01 100644 --- a/test/bitstyles_phoenix/bitstyles_test.exs +++ b/test/bitstyles_phoenix/bitstyles_test.exs @@ -11,6 +11,23 @@ defmodule BitstylesPhoenix.BitstylesTest do ) end + test "chained version" do + assert classname("u-version-5-0-0", {5, 0, 0}) == "u-version-5-0-0" + assert classname("u-version-5-0-0", {4, 9, 0}) == "u-version-4" + assert classname("u-version-5-0-0", {4, 4, 0}) == "u-version-4" + assert classname("u-version-5-0-0", {4, 3, 0}) == "u-version-4" + assert classname("u-version-5-0-0", {4, 2, 0}) == "u-version-4" + assert classname("u-version-5-0-0", {4, 1, 0}) == "u-version-4" + assert classname("u-version-5-0-0", {4, 0, 0}) == "u-version-4" + assert classname("u-version-5-0-0", {3, 9, 9}) == "u-version-2" + assert classname("u-version-5-0-0", {3, 0, 0}) == "u-version-2" + assert classname("u-version-5-0-0", {2, 0, 0}) == "u-version-2" + assert classname("u-version-5-0-0", {1, 6, 0}) == "u-version-1-5" + assert classname("u-version-5-0-0", {1, 5, 0}) == "u-version-1-5" + assert classname("u-version-5-0-0", {1, 4, 0}) == "u-version-1-3" + assert classname("u-version-5-0-0", {1, 3, 0}) == "u-version-1-3" + 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"