-
Notifications
You must be signed in to change notification settings - Fork 116
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
move Primer::BorderBoxComponent and Header, to Beta::BorderBox #1255
Merged
Merged
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
af4c086
inital move and rename into Beta::BorderBox
mxriverlynn 4b806c6
update all references
mxriverlynn b032cfa
add deprecated border box component
mxriverlynn 7924933
deprecate references to beta:borderboxcomponent
mxriverlynn 0f454ea
docs: build docs
actions-user 0aeeb74
moving border box header into beta folder
mxriverlynn 3c87d03
moving header to beta folder. it's failing docs build currently
mxriverlynn f1367e0
Merge remote-tracking branch 'origin/main' into move-border-box-to-beta
mxriverlynn 6ada834
Merge remote-tracking branch 'origin/move-border-box-to-beta' into mo…
mxriverlynn 9b8691f
docs: build docs
actions-user f9bbe33
updated site nav link for border box
mxriverlynn 8d10b45
updating arguments file
mxriverlynn 5f499e5
Merge remote-tracking branch 'origin/move-border-box-to-beta' into mo…
mxriverlynn 385425d
deleted old border box component test file
mxriverlynn b0e8c10
correcting name migration for border box component
mxriverlynn 3bfc279
don't need a status for a sub-component
mxriverlynn 3b7cd5e
added changeset
mxriverlynn c5fbc9b
docs: build docs
actions-user 67f07b1
Merge remote-tracking branch 'origin/main' into move-border-box-to-beta
mxriverlynn b0623ca
Merge remote-tracking branch 'origin/move-border-box-to-beta' into mo…
mxriverlynn 1b425f9
fixing missing comma from bad merge
mxriverlynn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,147 @@ | ||
# frozen_string_literal: true | ||
|
||
module Primer | ||
module Beta | ||
# `BorderBox` is a Box component with a border. | ||
class BorderBox < Primer::Component | ||
status :beta | ||
|
||
DEFAULT_PADDING = :default | ||
PADDING_MAPPINGS = { | ||
DEFAULT_PADDING => "", | ||
:condensed => "Box--condensed", | ||
:spacious => "Box--spacious" | ||
}.freeze | ||
PADDING_SUGGESTION = "Perhaps you could consider using :padding options of #{PADDING_MAPPINGS.keys.to_sentence}?" | ||
|
||
DEFAULT_ROW_SCHEME = :default | ||
ROW_SCHEME_MAPPINGS = { | ||
DEFAULT_ROW_SCHEME => "", | ||
:neutral => "Box-row--gray", | ||
:info => "Box-row--blue", | ||
:warning => "Box-row--yellow" | ||
}.freeze | ||
|
||
# Optional Header. | ||
# | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
# @accessibility | ||
# When using header.title, the recommended tag is a heading tag, such as h1, h2, h3, etc. | ||
renders_one :header, "Primer::Beta::BorderBox::Header" | ||
|
||
# Optional Body. | ||
# | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
renders_one :body, lambda { |**system_arguments| | ||
system_arguments[:tag] = :div | ||
system_arguments[:classes] = class_names( | ||
"Box-body", | ||
system_arguments[:classes] | ||
) | ||
|
||
Primer::BaseComponent.new(**system_arguments) | ||
} | ||
|
||
# Optional Footer. | ||
# | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
renders_one :footer, lambda { |**system_arguments| | ||
system_arguments[:tag] = :div | ||
system_arguments[:classes] = class_names( | ||
"Box-footer", | ||
system_arguments[:classes] | ||
) | ||
|
||
Primer::BaseComponent.new(**system_arguments) | ||
} | ||
|
||
# Use Rows to add rows with borders and maintain the same padding. | ||
# | ||
# @param scheme [Symbol] Color scheme. <%= one_of(Primer::Beta::BorderBox::ROW_SCHEME_MAPPINGS.keys) %> | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
renders_many :rows, lambda { |scheme: DEFAULT_ROW_SCHEME, **system_arguments| | ||
system_arguments[:tag] = :li | ||
system_arguments[:classes] = class_names( | ||
"Box-row", | ||
ROW_SCHEME_MAPPINGS[fetch_or_fallback(ROW_SCHEME_MAPPINGS.keys, scheme, DEFAULT_ROW_SCHEME)], | ||
system_arguments[:classes] | ||
) | ||
|
||
Primer::BaseComponent.new(**system_arguments) | ||
} | ||
|
||
# @example Header with title, body, rows, and footer | ||
# <%= render(Primer::Beta::BorderBox.new) do |component| %> | ||
# <% component.header do |h| %> | ||
# <% h.title(tag: :h2) do %> | ||
# Header | ||
# <% end %> | ||
# <% end %> | ||
# <% component.body do %> | ||
# Body | ||
# <% end %> | ||
# <% component.row do %> | ||
# <% if true %> | ||
# Row one | ||
# <% end %> | ||
# <% end %> | ||
# <% component.row do %> | ||
# Row two | ||
# <% end %> | ||
# <% component.footer do %> | ||
# Footer | ||
# <% end %> | ||
# <% end %> | ||
# | ||
# @example Padding density | ||
# <%= render(Primer::Beta::BorderBox.new(padding: :condensed)) do |component| %> | ||
# <% component.header do %> | ||
# Header | ||
# <% end %> | ||
# <% component.body do %> | ||
# Body | ||
# <% end %> | ||
# <% component.row do %> | ||
# Row two | ||
# <% end %> | ||
# <% component.footer do %> | ||
# Footer | ||
# <% end %> | ||
# <% end %> | ||
# | ||
# @example Row colors | ||
# <%= render(Primer::Beta::BorderBox.new) do |component| %> | ||
# <% component.row do %> | ||
# Default | ||
# <% end %> | ||
# <% component.row(scheme: :neutral) do %> | ||
# Neutral | ||
# <% end %> | ||
# <% component.row(scheme: :info) do %> | ||
# Info | ||
# <% end %> | ||
# <% component.row(scheme: :warning) do %> | ||
# Warning | ||
# <% end %> | ||
# <% end %> | ||
# | ||
# @param padding [Symbol] <%= one_of(Primer::Beta::BorderBox::PADDING_MAPPINGS.keys) %> | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
def initialize(padding: DEFAULT_PADDING, **system_arguments) | ||
@system_arguments = deny_tag_argument(**system_arguments) | ||
@system_arguments[:tag] = :div | ||
@system_arguments[:classes] = class_names( | ||
"Box", | ||
PADDING_MAPPINGS[fetch_or_fallback(PADDING_MAPPINGS.keys, padding, DEFAULT_PADDING)], | ||
system_arguments[:classes] | ||
) | ||
|
||
@system_arguments[:system_arguments_denylist] = { [:p, :pt, :pb, :pr, :pl] => PADDING_SUGGESTION } | ||
end | ||
|
||
def render? | ||
rows.any? || header.present? || body.present? || footer.present? | ||
end | ||
end | ||
end | ||
end |
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
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,145 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
module Primer | ||
# `BorderBox` is a Box component with a border. | ||
class BorderBoxComponent < Primer::Component | ||
status :beta | ||
|
||
DEFAULT_PADDING = :default | ||
PADDING_MAPPINGS = { | ||
DEFAULT_PADDING => "", | ||
:condensed => "Box--condensed", | ||
:spacious => "Box--spacious" | ||
}.freeze | ||
PADDING_SUGGESTION = "Perhaps you could consider using :padding options of #{PADDING_MAPPINGS.keys.to_sentence}?" | ||
|
||
DEFAULT_ROW_SCHEME = :default | ||
ROW_SCHEME_MAPPINGS = { | ||
DEFAULT_ROW_SCHEME => "", | ||
:neutral => "Box-row--gray", | ||
:info => "Box-row--blue", | ||
:warning => "Box-row--yellow" | ||
}.freeze | ||
|
||
# Optional Header. | ||
# | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
# @accessibility | ||
# When using header.title, the recommended tag is a heading tag, such as h1, h2, h3, etc. | ||
renders_one :header, "Primer::Alpha::BorderBox::Header" | ||
|
||
# Optional Body. | ||
# | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
renders_one :body, lambda { |**system_arguments| | ||
system_arguments[:tag] = :div | ||
system_arguments[:classes] = class_names( | ||
"Box-body", | ||
system_arguments[:classes] | ||
) | ||
|
||
Primer::BaseComponent.new(**system_arguments) | ||
} | ||
|
||
# Optional Footer. | ||
# | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
renders_one :footer, lambda { |**system_arguments| | ||
system_arguments[:tag] = :div | ||
system_arguments[:classes] = class_names( | ||
"Box-footer", | ||
system_arguments[:classes] | ||
) | ||
|
||
Primer::BaseComponent.new(**system_arguments) | ||
} | ||
|
||
# Use Rows to add rows with borders and maintain the same padding. | ||
# | ||
# @param scheme [Symbol] Color scheme. <%= one_of(Primer::BorderBoxComponent::ROW_SCHEME_MAPPINGS.keys) %> | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
renders_many :rows, lambda { |scheme: DEFAULT_ROW_SCHEME, **system_arguments| | ||
system_arguments[:tag] = :li | ||
system_arguments[:classes] = class_names( | ||
"Box-row", | ||
ROW_SCHEME_MAPPINGS[fetch_or_fallback(ROW_SCHEME_MAPPINGS.keys, scheme, DEFAULT_ROW_SCHEME)], | ||
system_arguments[:classes] | ||
) | ||
|
||
Primer::BaseComponent.new(**system_arguments) | ||
} | ||
|
||
# @example Header with title, body, rows, and footer | ||
# <%= render(Primer::BorderBoxComponent.new) do |component| %> | ||
# <% component.header do |h| %> | ||
# <% h.title(tag: :h2) do %> | ||
# Header | ||
# <% end %> | ||
# <% end %> | ||
# <% component.body do %> | ||
# Body | ||
# <% end %> | ||
# <% component.row do %> | ||
# <% if true %> | ||
# Row one | ||
# <% end %> | ||
# <% end %> | ||
# <% component.row do %> | ||
# Row two | ||
# <% end %> | ||
# <% component.footer do %> | ||
# Footer | ||
# <% end %> | ||
# <% end %> | ||
# | ||
# @example Padding density | ||
# <%= render(Primer::BorderBoxComponent.new(padding: :condensed)) do |component| %> | ||
# <% component.header do %> | ||
# Header | ||
# <% end %> | ||
# <% component.body do %> | ||
# Body | ||
# <% end %> | ||
# <% component.row do %> | ||
# Row two | ||
# <% end %> | ||
# <% component.footer do %> | ||
# Footer | ||
# <% end %> | ||
# <% end %> | ||
# | ||
# @example Row colors | ||
# <%= render(Primer::BorderBoxComponent.new) do |component| %> | ||
# <% component.row do %> | ||
# Default | ||
# <% end %> | ||
# <% component.row(scheme: :neutral) do %> | ||
# Neutral | ||
# <% end %> | ||
# <% component.row(scheme: :info) do %> | ||
# Info | ||
# <% end %> | ||
# <% component.row(scheme: :warning) do %> | ||
# Warning | ||
# <% end %> | ||
# <% end %> | ||
# | ||
# @param padding [Symbol] <%= one_of(Primer::BorderBoxComponent::PADDING_MAPPINGS.keys) %> | ||
# @param system_arguments [Hash] <%= link_to_system_arguments_docs %> | ||
def initialize(padding: DEFAULT_PADDING, **system_arguments) | ||
@system_arguments = deny_tag_argument(**system_arguments) | ||
@system_arguments[:tag] = :div | ||
@system_arguments[:classes] = class_names( | ||
"Box", | ||
PADDING_MAPPINGS[fetch_or_fallback(PADDING_MAPPINGS.keys, padding, DEFAULT_PADDING)], | ||
system_arguments[:classes] | ||
) | ||
|
||
@system_arguments[:system_arguments_denylist] = { [:p, :pt, :pb, :pr, :pl] => PADDING_SUGGESTION } | ||
end | ||
|
||
def render? | ||
rows.any? || header.present? || body.present? || footer.present? | ||
end | ||
class BorderBoxComponent < Primer::Beta::BorderBox | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I believe only top-level components have statuses?