Skip to content

Commit

Permalink
Add dummy example of chained class renames
Browse files Browse the repository at this point in the history
  • Loading branch information
angelikatyborska committed Jul 23, 2024
1 parent f5ecbdd commit 24b317c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/bitstyles_phoenix/bitstyles.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ 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"
"a-badge--text" -> "a-badge--gray"
"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

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
17 changes: 17 additions & 0 deletions test/bitstyles_phoenix/bitstyles_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 24b317c

Please sign in to comment.