-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade bitstyles to 5.0.1 #125
Changes from 17 commits
711a85c
da54bc9
f665232
a1cf049
05e60fd
f721cd2
691714a
0941c08
d6cdae3
86ce283
4e8bf53
d3c26dc
b9dc051
c1a6fdb
71f0ecd
26f8313
6b71961
15d7c55
c9e1f48
1f8194e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
defmodule BitstylesPhoenix.Bitstyles do | ||
@moduledoc false | ||
|
||
@default_version "4.3.0" | ||
@default_version "5.0.1" | ||
@cdn_url "https://cdn.jsdelivr.net/npm/bitstyles" | ||
|
||
def cdn_url do | ||
|
@@ -14,12 +14,51 @@ 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.1" 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.2.0" do | ||
sizes_renaming = %{ | ||
"3xs" => "xxxs", | ||
"2xs" => "xxs", | ||
"2xl" => "xxl", | ||
"3xl" => "xxxl" | ||
} | ||
|
||
class = | ||
Enum.reduce(sizes_renaming, class, fn {new_size, old_size}, acc -> | ||
String.replace(acc, "-#{new_size}", "-#{old_size}") | ||
end) | ||
|
||
border_color_renaming = %{ | ||
"u-border-gray-light" => "u-border-gray-10", | ||
"u-border-gray-dark" => "u-border-gray-70" | ||
} | ||
|
||
class = | ||
Enum.reduce(border_color_renaming, class, fn {new_border_color, old_border_color}, acc -> | ||
String.replace(acc, new_border_color, old_border_color) | ||
end) | ||
|
||
class = | ||
case class do | ||
"u-list-none" -> "a-list-reset" | ||
"a-badge--text" -> "a-badge--gray" | ||
"u-gap-l" -> "u-gap-m" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 this will change the behaviour quite a lot, right? We have numerous places in the code in dima e.g. that use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I understand...
Isn't this exactly what we want? The class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But then are the values for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also keep in mind the values are always just values set by the sass variables, so one can always go back to the old values if they want to not migrate things. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The class https://github.com/bitcrowd/bitstyles/blob/v5.0.1/scss/bitstyles/utilities/gap/_settings.scss#L4-L7
I think I understand. It's fine to define class mappings in this module if the new class only exists in the new version, and the old class only exists in the old version. But here we have a new class that exists in both new and old version, but with a different meaning in the old version ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
"u-fg-text" -> "u-fg-gray-30" | ||
"u-fg-text-darker" -> "u-fg-gray-50" | ||
"u-bg-gray-darker" -> "u-bg-gray-80" | ||
class -> class | ||
end | ||
|
||
classname(class, "5.0.0") | ||
end | ||
|
||
def classname(class, version) when version >= "4.0.0" do | ||
mapping = | ||
|
@@ -28,7 +67,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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we at least make sure here, that the class starts with
u-
and is a bitstyles class?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
15d7c55
(#125)