-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving ProgressBar component css (#1583)
Co-authored-by: Cameron Dutro <[email protected]>
- Loading branch information
Showing
16 changed files
with
143 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/view-components': patch | ||
--- | ||
|
||
Migrating progress bar component to beta folder, and adding progress bar css. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* Progress */ | ||
|
||
.Progress { | ||
display: flex; | ||
height: 8px; | ||
overflow: hidden; | ||
background-color: var(--color-neutral-muted); | ||
border-radius: 6px; | ||
outline: 1px solid transparent; /* Support Firefox custom colors */ | ||
} | ||
|
||
.Progress--large { | ||
height: 10px; | ||
} | ||
|
||
.Progress--small { | ||
height: 5px; | ||
} | ||
|
||
.Progress-item { | ||
outline: 2px solid transparent; /* Support Firefox custom colors */ | ||
} | ||
|
||
.Progress-item + .Progress-item { | ||
margin-left: 2px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# frozen_string_literal: true | ||
|
||
module Primer | ||
module Beta | ||
# Use `ProgressBar` to visualize task completion. | ||
class ProgressBar < Primer::Component | ||
status :beta | ||
|
||
# Use the Item slot to add an item to the progress bar | ||
# | ||
# @param percentage [Integer] The percent complete | ||
# @param bg [Symbol] The background color | ||
# @param kwargs [Hash] The same arguments as <%= link_to_system_arguments_docs %>. | ||
renders_many :items, lambda { |percentage: 0, bg: :success_emphasis, **system_arguments| | ||
deny_tag_argument(**system_arguments) | ||
system_arguments[:tag] = :span | ||
system_arguments[:bg] = bg | ||
system_arguments[:style] = join_style_arguments(system_arguments[:style], "width: #{percentage}%;") | ||
system_arguments[:classes] = class_names("Progress-item", system_arguments[:classes]) | ||
|
||
Primer::BaseComponent.new(**system_arguments) | ||
} | ||
|
||
SIZE_DEFAULT = :default | ||
|
||
SIZE_MAPPINGS = { | ||
SIZE_DEFAULT => "", | ||
:small => "Progress--small", | ||
:large => "Progress--large" | ||
}.freeze | ||
|
||
SIZE_OPTIONS = SIZE_MAPPINGS.keys | ||
# @example Default | ||
# <%= render(Primer::Beta::ProgressBar.new) do |component| %> | ||
# <% component.item(percentage: 25) %> | ||
# <% end %> | ||
# | ||
# @example Small | ||
# <%= render(Primer::Beta::ProgressBar.new(size: :small)) do |component| %> | ||
# <% component.item(bg: :accent_emphasis, percentage: 50) %> | ||
# <% end %> | ||
# | ||
# @example Large | ||
# <%= render(Primer::Beta::ProgressBar.new(size: :large)) do |component| %> | ||
# <% component.item(bg: :danger_emphasis, percentage: 75) %> | ||
# <% end %> | ||
# | ||
# @example Multiple items | ||
# <%= render(Primer::Beta::ProgressBar.new) do |component| %> | ||
# <% component.item(percentage: 10) %> | ||
# <% component.item(bg: :accent_emphasis, percentage: 20) %> | ||
# <% component.item(bg: :danger_emphasis, percentage: 30) %> | ||
# <% end %> | ||
# | ||
# @param size [Symbol] <%= one_of(Primer::Beta::ProgressBar::SIZE_OPTIONS) %> Increases height. | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
def initialize(size: SIZE_DEFAULT, **system_arguments) | ||
@system_arguments = deny_tag_argument(**system_arguments) | ||
@system_arguments[:classes] = class_names( | ||
@system_arguments[:classes], | ||
"Progress", | ||
SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)] | ||
) | ||
@system_arguments[:tag] = :span | ||
end | ||
|
||
def render? | ||
items.any? | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module Primer | ||
# Use `ProgressBar` to visualize task completion. | ||
class ProgressBarComponent < Primer::Component | ||
status :beta | ||
|
||
# Use the Item slot to add an item to the progress bas | ||
# | ||
# @param percentage [Integer] The percent complete | ||
# @param bg [Symbol] The background color | ||
# @param kwargs [Hash] The same arguments as <%= link_to_system_arguments_docs %>. | ||
renders_many :items, lambda { |percentage: 0, bg: :success_emphasis, **system_arguments| | ||
deny_tag_argument(**system_arguments) | ||
system_arguments[:tag] = :span | ||
system_arguments[:bg] = bg | ||
system_arguments[:style] = join_style_arguments(system_arguments[:style], "width: #{percentage}%;") | ||
system_arguments[:classes] = class_names("Progress-item", system_arguments[:classes]) | ||
|
||
Primer::BaseComponent.new(**system_arguments) | ||
} | ||
|
||
SIZE_DEFAULT = :default | ||
|
||
SIZE_MAPPINGS = { | ||
SIZE_DEFAULT => "", | ||
:small => "Progress--small", | ||
:large => "Progress--large" | ||
}.freeze | ||
|
||
SIZE_OPTIONS = SIZE_MAPPINGS.keys | ||
# @example Default | ||
# <%= render(Primer::ProgressBarComponent.new) do |component| %> | ||
# <% component.item(percentage: 25) %> | ||
# <% end %> | ||
# | ||
# @example Small | ||
# <%= render(Primer::ProgressBarComponent.new(size: :small)) do |component| %> | ||
# <% component.item(bg: :accent_emphasis, percentage: 50) %> | ||
# <% end %> | ||
# | ||
# @example Large | ||
# <%= render(Primer::ProgressBarComponent.new(size: :large)) do |component| %> | ||
# <% component.item(bg: :danger_emphasis, percentage: 75) %> | ||
# <% end %> | ||
# | ||
# @example Multiple items | ||
# <%= render(Primer::ProgressBarComponent.new) do |component| %> | ||
# <% component.item(percentage: 10) %> | ||
# <% component.item(bg: :accent_emphasis, percentage: 20) %> | ||
# <% component.item(bg: :danger_emphasis, percentage: 30) %> | ||
# <% end %> | ||
# | ||
# @param size [Symbol] <%= one_of(Primer::ProgressBarComponent::SIZE_OPTIONS) %> Increases height. | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
def initialize(size: SIZE_DEFAULT, **system_arguments) | ||
@system_arguments = deny_tag_argument(**system_arguments) | ||
@system_arguments[:classes] = class_names( | ||
@system_arguments[:classes], | ||
"Progress", | ||
SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)] | ||
) | ||
@system_arguments[:tag] = :span | ||
end | ||
|
||
def render? | ||
items.any? | ||
end | ||
class ProgressBarComponent < Primer::Beta::ProgressBar | ||
status :deprecated | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.