Current section

Files

Jump to
sigma_kit lib components progress_bar.ex
Raw

lib/components/progress_bar.ex

defmodule SigmaKit.Components.ProgressBar do
use Phoenix.LiveComponent
attr :min, :float, default: 0.0, doc: "Minimum progress"
attr :max, :float, default: 100.0, doc: "Maximum progress"
attr :value, :float, default: 0.0, doc: "Current progress"
attr :power_line, :boolean, default: false, doc: "Use a thin line style"
def progress_bar(assigns = %{power_line: true}) do
~H"""
<div class="sk-pb">
<div
class="sk-pb-progress"
style={"width: #{(@value - @min) / (@max - @min) * 100}%"}
>
<div class="sk-pb-glow"></div>
</div>
</div>
"""
end
def progress_bar(assigns = %{power_line: false}) do
~H"""
<div class="sk-pb">
<div
class="sk-pb-progress"
style={"width: #{(@value - @min) / (@max - @min) * 100}%"}
>
</div>
</div>
"""
end
end