Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/mave_core_web/components/dashboard_components/states.ex
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,12 @@ defmodule MaveCoreWeb.DashboardComponents.States do
</div>
</div>
<div class="flex text-stone-300 text-sm">
<div class="flex-grow">{@current}</div>
<div
data-usage-current
class={["flex-grow", @segments.overage > 0 && "text-red-500"]}
>
{@current}
</div>
<div>{@max}</div>
</div>
</div>
Expand Down
10 changes: 10 additions & 0 deletions storybook/dashboard/states/usage_bar.story.exs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ defmodule Storybook.Dashboard.States.UsageBar do
max: "10,000 calls",
percent: 100.0
}
},
%Variation{
id: :over_limit,
description: "Over limit (129%)",
attributes: %{
label: "Bandwidth",
current: "1.29 TB",
max: "1 TB",
percent: 129.0
}
}
]
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defmodule MaveCoreWeb.DashboardComponents.StatesTest do
assert html =~ ~s(data-usage-segment="within-limit")
assert html =~ ~s(style="width: 25.0%;")
refute html =~ ~s(data-usage-segment="overage")
refute html =~ "text-red-500"
end

test "usage_bar shows the portion above the limit in red" do
Expand All @@ -31,5 +32,6 @@ defmodule MaveCoreWeb.DashboardComponents.StatesTest do
assert html =~ ~s(data-usage-segment="overage")
assert html =~ "bg-red-500"
assert html =~ ~s(style="width: 25.0%;")
assert html =~ ~r/data-usage-current[^>]*class="flex-grow text-red-500"/
end
end
Loading