Skip to content

Commit

Permalink
New sizing values; fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
angelikatyborska committed Jul 2, 2024
1 parent 0dd5256 commit d13fe87
Show file tree
Hide file tree
Showing 17 changed files with 181 additions and 102 deletions.
2 changes: 1 addition & 1 deletion lib/bitstyles_phoenix.ex
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ defmodule BitstylesPhoenix do
You can control how required labels are rendered. By default you will get this appended to your labels if the input is required:
```html
<span aria-hidden="true" class="u-fg-warning u-margin-xss-left">*</span>
<span aria-hidden="true" class="u-fg-warning u-margin-s4s-left">*</span>
```
You can override it by specifying your own component to render the required labels. The component will get the form and the field as assigns, as well as any optional parameters you pass in the MFA as `@opts`.
Expand Down
4 changes: 2 additions & 2 deletions lib/bitstyles_phoenix/alpine3/dropdown.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ defmodule BitstylesPhoenix.Alpine3.Dropdown do
</use>
</svg>
</button>
<ul class="a-dropdown u-overflow-y-auto a-list-reset u-margin-s-top" @click.away="dropdownOpen = false" x-cloak="x-cloak" x-show="dropdownOpen" x-transition:enter="is-transitioning" x-transition:enter-end="is-on-screen" x-transition:enter-start="is-off-screen" x-transition:leave="is-transitioning" x-transition:leave-end="is-off-screen" x-transition:leave-start="is-on-screen">
<ul class="a-dropdown u-overflow-y-auto a-list-reset u-margin-s2-top" @click.away="dropdownOpen = false" x-cloak="x-cloak" x-show="dropdownOpen" x-transition:enter="is-transitioning" x-transition:enter-end="is-on-screen" x-transition:enter-start="is-off-screen" x-transition:leave="is-transitioning" x-transition:leave-end="is-off-screen" x-transition:leave-start="is-on-screen">
<li>
<a href="#" class="a-button a-button--transparent a-button--menu u-h6">
Option 1
Expand Down Expand Up @@ -112,7 +112,7 @@ defmodule BitstylesPhoenix.Alpine3.Dropdown do
</use>
</svg>
</button>
<ul class="a-dropdown u-overflow-y-auto a-list-reset u-margin-s-top" @click.away="myOwnDropDown = false" x-cloak="x-cloak" x-show="myOwnDropDown" x-transition:enter="is-transitioning" x-transition:enter-end="is-on-screen" x-transition:enter-start="is-off-screen" x-transition:leave="is-transitioning" x-transition:leave-end="is-off-screen" x-transition:leave-start="is-on-screen">
<ul class="a-dropdown u-overflow-y-auto a-list-reset u-margin-s2-top" @click.away="myOwnDropDown = false" x-cloak="x-cloak" x-show="myOwnDropDown" x-transition:enter="is-transitioning" x-transition:enter-end="is-on-screen" x-transition:enter-start="is-off-screen" x-transition:leave="is-transitioning" x-transition:leave-end="is-off-screen" x-transition:leave-start="is-on-screen">
<li>
<a href="#" class="a-button a-button--transparent a-button--menu u-h6">
Option 1
Expand Down
20 changes: 10 additions & 10 deletions lib/bitstyles_phoenix/alpine3/sidebar.ex
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ defmodule BitstylesPhoenix.Alpine3.Sidebar do
...> <.ui_sidebar_nav_item><.ui_button href="#" class="u-flex-grow-1" color="transparent">Menu item #2</.ui_button></.ui_sidebar_nav_item>
...> </.ui_sidebar_nav>
...> </:sidebar_content>
...> <:main :let={s} class="u-margin-s-top">
...> <:main :let={s} class="u-margin-s2-top">
...> <.ui_content class="flex">
...> <.ui_js_sidebar_open sidebar={s} class="u-margin-s-right"/>
...> <.ui_js_sidebar_open sidebar={s} class="u-margin-s2-right"/>
...> Main Content
...> </.ui_content>
...> </:main>
Expand All @@ -61,13 +61,13 @@ defmodule BitstylesPhoenix.Alpine3.Sidebar do
bitcrowd
</span>
</a>
<ul class="u-flex-grow-1 u-flex-shrink-1 u-overflow-y-auto a-list-reset u-flex u-flex-col u-items-stretch u-padding-xs-right u-padding-xs-left">
<li class="u-margin-xs-bottom u-flex">
<ul class="u-flex-grow-1 u-flex-shrink-1 u-overflow-y-auto a-list-reset u-flex u-flex-col u-items-stretch u-padding-s4-right u-padding-s4-left">
<li class="u-margin-s4-bottom u-flex">
<a href="#" class="a-button a-button--transparent u-flex-grow-1">
Menu item #1
</a>
</li>
<li class="u-margin-xs-bottom u-flex">
<li class="u-margin-s4-bottom u-flex">
<a href="#" class="a-button a-button--transparent u-flex-grow-1">
Menu item #2
</a>
Expand All @@ -94,13 +94,13 @@ defmodule BitstylesPhoenix.Alpine3.Sidebar do
</button>
</div>
</div>
<ul class="u-flex-grow-1 u-flex-shrink-1 u-overflow-y-auto a-list-reset u-flex u-flex-col u-items-stretch u-padding-xs-right u-padding-xs-left">
<li class="u-margin-xs-bottom u-flex">
<ul class="u-flex-grow-1 u-flex-shrink-1 u-overflow-y-auto a-list-reset u-flex u-flex-col u-items-stretch u-padding-s4-right u-padding-s4-left">
<li class="u-margin-s4-bottom u-flex">
<a href="#" class="a-button a-button--transparent u-flex-grow-1">
Menu item #1
</a>
</li>
<li class="u-margin-xs-bottom u-flex">
<li class="u-margin-s4-bottom u-flex">
<a href="#" class="a-button a-button--transparent u-flex-grow-1">
Menu item #2
</a>
Expand All @@ -109,9 +109,9 @@ defmodule BitstylesPhoenix.Alpine3.Sidebar do
</div>
</nav>
</header>
<main class="u-flex-grow-1 u-overflow-y-auto u-margin-s-top">
<main class="u-flex-grow-1 u-overflow-y-auto u-margin-s2-top">
<div class="a-content flex">
<button type="button" :aria-expanded="sidebarOpen" @click="sidebarOpen = true" aria-controls="sidebar-small" class="a-button a-button--square u-hidden@l u-margin-s-right" title="Open sidebar">
<button type="button" :aria-expanded="sidebarOpen" @click="sidebarOpen = true" aria-controls="sidebar-small" class="a-button a-button--square u-hidden@l u-margin-s2-right" title="Open sidebar">
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon" focusable="false" height="16" width="16">
<use xlink:href="#icon-hamburger">
</use>
Expand Down
50 changes: 49 additions & 1 deletion lib/bitstyles_phoenix/bitstyles.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,58 @@ defmodule BitstylesPhoenix.Bitstyles do
class
end

def classname(class, version) when version >= "5.0.0" do
def classname(class, version) when version >= "6.0.0" do
class
end

def classname(class, version) when version >= "5.0.0" do
sizes_renaming = %{
"s7" => "4xs",
# 3xs has no size equivalent in new sizing
# exact match:
"s6" => "2xs",
"s5" => "2xs",
# exact match:
"s4" => "xs",
"s3" => "xs",
# exact match:
"s2" => "s",
"s1" => "s",
# exact match:
"m" => "m",
# exact match:
"l1" => "l",
"l2" => "l",
# exact match:
"l3" => "xl",
"l4" => "xl",
"l5" => "xl",
# exact match:
"l6" => "2xl",
# exact match:
"l7" => "3xl"
# 4xl has no size equivalent in new sizing
}

class =
Enum.reduce(sizes_renaming, class, fn {new_size, old_size}, acc ->
acc
|> String.replace("margin-#{new_size}", "margin-#{old_size}")
|> String.replace("margin-neg-#{new_size}", "margin-neg-#{old_size}")
|> String.replace("padding-#{new_size}", "padding-#{old_size}")
|> String.replace("padding-neg-#{new_size}", "padding-neg-#{old_size}")
|> String.replace("gap-#{new_size}", "gap-#{old_size}")
end)

class =
case class do
"u-fg-grayscale" -> "u-fg-text"
class -> class
end

classname(class, "6.0.0")
end

def classname(class, version) when version >= "4.2.0" do
sizes_renaming = %{
"3xs" => "xxxs",
Expand Down
4 changes: 2 additions & 2 deletions lib/bitstyles_phoenix/component/avatar.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ defmodule BitstylesPhoenix.Component.Avatar do
<div class="a-avatar">
<img height="32" width="32" alt="Username’s avatar" src="https://placehold.co/100x100"/>
</div>
<span class="u-margin-s-left">
<span class="u-margin-s2-left">
Username
</span>
</div>
Expand Down Expand Up @@ -114,7 +114,7 @@ defmodule BitstylesPhoenix.Component.Avatar do
<img {@extra} />
</div>
<%= if assigns[:inner_block] do %>
<span class={classnames("u-margin-s-left")}>
<span class={classnames("u-margin-s2-left")}>
<%= render_slot(@inner_block) %>
</span>
<% end %>
Expand Down
40 changes: 20 additions & 20 deletions lib/bitstyles_phoenix/component/breadcrumbs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@ defmodule BitstylesPhoenix.Component.Breadcrumbs do
"""
<nav aria-label="breadcrumbs">
<ol class="u-h6 u-list-none u-flex u-flex-wrap u-items-center">
<li class="u-margin-xs-right u-flex u-items-center">
<li class="u-margin-s4-right u-flex u-items-center">
Foo
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-text u-margin-xs-left" focusable="false" height="16" width="16">
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-grayscale u-margin-s4-left" focusable="false" height="16" width="16">
<use xlink:href="#icon-caret-right">
</use>
</svg>
</li>
<li class="u-margin-xs-right u-flex u-items-center">
<li class="u-margin-s4-right u-flex u-items-center">
Bar
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-text u-margin-xs-left" focusable="false" height="16" width="16">
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-grayscale u-margin-s4-left" focusable="false" height="16" width="16">
<use xlink:href="#icon-caret-right">
</use>
</svg>
</li>
<li class="u-margin-xs-right u-flex u-items-center">
<li class="u-margin-s4-right u-flex u-items-center">
Baz
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-text u-margin-xs-left" focusable="false" height="16" width="16">
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-grayscale u-margin-s4-left" focusable="false" height="16" width="16">
<use xlink:href="#icon-caret-right">
</use>
</svg>
Expand Down Expand Up @@ -150,23 +150,23 @@ defmodule BitstylesPhoenix.Component.Breadcrumbs do
"""
<nav aria-label="breadcrumbs">
<ol class="u-h6 u-list-none u-flex u-flex-wrap u-items-center">
<li class="u-margin-xs-right u-flex u-items-center">
<li class="u-margin-s4-right u-flex u-items-center">
Foo
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-text u-margin-xs-left" focusable="false" height="16" width="16">
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-grayscale u-margin-s4-left" focusable="false" height="16" width="16">
<use xlink:href="#icon-caret-right">
</use>
</svg>
</li>
<li class="u-margin-xs-right u-flex u-items-center">
<li class="u-margin-s4-right u-flex u-items-center">
Bar
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-text u-margin-xs-left" focusable="false" height="16" width="16">
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-grayscale u-margin-s4-left" focusable="false" height="16" width="16">
<use xlink:href="#icon-caret-right">
</use>
</svg>
</li>
<li class="u-margin-xs-right u-flex u-items-center">
<li class="u-margin-s4-right u-flex u-items-center">
Baz
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-text u-margin-xs-left" focusable="false" height="16" width="16">
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-grayscale u-margin-s4-left" focusable="false" height="16" width="16">
<use xlink:href="#icon-caret-right">
</use>
</svg>
Expand Down Expand Up @@ -200,23 +200,23 @@ defmodule BitstylesPhoenix.Component.Breadcrumbs do
"""
<nav aria-label="breadcrumbs" data-foo="bar">
<ol class="u-h6 u-list-none u-flex u-flex-wrap u-items-center u-fg-warning">
<li class="u-margin-xs-right u-flex u-items-center u-fg-brand-2" data-baz="foo">
<li class="u-margin-s4-right u-flex u-items-center u-fg-brand-2" data-baz="foo">
Foo
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-text u-margin-xs-left" focusable="false" height="16" width="16">
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-grayscale u-margin-s4-left" focusable="false" height="16" width="16">
<use xlink:href="#icon-caret-right">
</use>
</svg>
</li>
<li class="u-margin-xs-right u-flex u-items-center">
<li class="u-margin-s4-right u-flex u-items-center">
Bar
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-text u-margin-xs-left" focusable="false" height="16" width="16">
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-grayscale u-margin-s4-left" focusable="false" height="16" width="16">
<use xlink:href="#icon-caret-right">
</use>
</svg>
</li>
<li class="u-margin-xs-right u-flex u-items-center">
<li class="u-margin-s4-right u-flex u-items-center">
Baz
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-text u-margin-xs-left" focusable="false" height="16" width="16">
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="a-icon a-icon--m u-fg-grayscale u-margin-s4-left" focusable="false" height="16" width="16">
<use xlink:href="#icon-caret-right">
</use>
</svg>
Expand Down Expand Up @@ -244,11 +244,11 @@ defmodule BitstylesPhoenix.Component.Breadcrumbs do
<ol class={classnames(["u-h6 u-list-none u-flex u-flex-wrap u-items-center", assigns[:class]])}>
<%= for item <- (assigns[:item] || assigns[:items]) do %>
<li
class={classnames(["u-margin-xs-right u-flex u-items-center", assigns[:item] && item[:class]])}
class={classnames(["u-margin-s4-right u-flex u-items-center", assigns[:item] && item[:class]])}
{assigns[:item] && assigns_to_attributes(item, [:class]) || []}
>
<%= if assigns[:item], do: render_slot(item), else: item %>
<.ui_icon name="caret-right" size="m" class={classnames("u-fg-text u-margin-xs-left")} {@icon_extra} />
<.ui_icon name="caret-right" size="m" class={classnames("u-fg-grayscale u-margin-s4-left")} {@icon_extra} />
</li>
<% end %>
</ol>
Expand Down
4 changes: 2 additions & 2 deletions lib/bitstyles_phoenix/component/card.ex
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ defmodule BitstylesPhoenix.Component.Card do
'''
"""
<article class="a-card a-card-l">
<div aria-live="polite" class="u-padding-l-y a-flash a-flash--danger a-card-l__header">
<div aria-live="polite" class="u-padding-l1-y a-flash a-flash--danger a-card-l__header">
<div class="a-content u-flex u-items-center u-font-medium">
Its me mario
</div>
Expand All @@ -90,7 +90,7 @@ defmodule BitstylesPhoenix.Component.Card do
'''
"""
<article class="a-card">
<div aria-live="polite" class="u-padding-l-y a-flash a-flash--danger a-card__header">
<div aria-live="polite" class="u-padding-l1-y a-flash a-flash--danger a-card__header">
<div class="a-content u-flex u-items-center u-font-medium">
Its me mario
</div>
Expand Down
12 changes: 6 additions & 6 deletions lib/bitstyles_phoenix/component/description_list.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ defmodule BitstylesPhoenix.Component.DescriptionList do
"""
<dl class="a-dl">
<div class="a-dl__item u-grid@m u-grid-cols-3 u-gap-l u-padding-m-y u-padding-m@m u-items-baseline">
<dt class="u-font-medium u-h6 u-fg-text-darker u-margin-xs-bottom@s">
<dt class="u-font-medium u-h6 u-fg-text-darker u-margin-s4-bottom@s">
Length
</dt>
<dd class="u-col-span-2">
8
</dd>
</div>
<div class="a-dl__item u-grid@m u-grid-cols-3 u-gap-l u-padding-m-y u-padding-m@m u-items-baseline">
<dt class="u-font-medium u-h6 u-fg-text-darker u-margin-xs-bottom@s">
<dt class="u-font-medium u-h6 u-fg-text-darker u-margin-s4-bottom@s">
Inserted at
</dt>
<dd class="u-col-span-2">
Expand Down Expand Up @@ -64,23 +64,23 @@ defmodule BitstylesPhoenix.Component.DescriptionList do
"""
<dl class="a-dl extra" data-foo="baz">
<div class="a-dl__item u-grid@m u-grid-cols-3 u-gap-l u-padding-m-y u-padding-m@m u-items-baseline u-fg-brand-2">
<dt class="u-font-medium u-h6 u-fg-text-darker u-margin-xs-bottom@s">
<dt class="u-font-medium u-h6 u-fg-text-darker u-margin-s4-bottom@s">
Length
</dt>
<dd class="u-col-span-2">
8
</dd>
</div>
<div class="a-dl__item u-grid@m u-grid-cols-3 u-gap-l u-padding-m-y u-padding-m@m u-items-baseline">
<dt class="u-font-medium u-h6 u-fg-text-darker u-margin-xs-bottom@s u-fg-brand-1" data-foo="bar">
<dt class="u-font-medium u-h6 u-fg-text-darker u-margin-s4-bottom@s u-fg-brand-1" data-foo="bar">
Some
</dt>
<dd class="u-col-span-2 u-fg-brand-1" data-foo="bar">
Tag
</dd>
</div>
<div class="a-dl__item u-grid@m u-grid-cols-3 u-gap-l u-padding-m-y u-padding-m@m u-items-baseline">
<dt class="u-font-medium u-h6 u-fg-text-darker u-margin-xs-bottom@s">
<dt class="u-font-medium u-h6 u-fg-text-darker u-margin-s4-bottom@s">
<pre>
Tag
</pre>
Expand Down Expand Up @@ -162,7 +162,7 @@ defmodule BitstylesPhoenix.Component.DescriptionList do
assigns = assign(assigns, extra: extra)

~H"""
<dt class={classnames(["u-font-medium u-h6 u-fg-text-darker u-margin-xs-bottom@s", assigns[:class]])} {@extra}>
<dt class={classnames(["u-font-medium u-h6 u-fg-text-darker u-margin-s4-bottom@s", assigns[:class]])} {@extra}>
<%= render_slot(@inner_block) %>
</dt>
"""
Expand Down
Loading

0 comments on commit d13fe87

Please sign in to comment.