-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add link to internal handbook in homepage intro (#640)
* Add link to internal handbook in homepage intro * Remove duplicate lock Co-authored-by: Zach Margolis <[email protected]> --------- Co-authored-by: Zach Margolis <[email protected]>
- Loading branch information
1 parent
e823906
commit ec8eeb0
Showing
8 changed files
with
82 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= tag.div(**tag_options, class: css_class, role:) do %> | ||
<div class="usa-alert__body"> | ||
<%= content_tag(text_tag, content, class: 'usa-alert__text') %> | ||
</div> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
class AlertComponent < BaseComponent | ||
attr_reader :type, :message, :tag_options, :text_tag | ||
|
||
validates_inclusion_of :type, in: [nil, :info, :success, :warning, :error, :emergency] | ||
|
||
def initialize(type: nil, text_tag: 'p', message: nil, **tag_options) | ||
@type = type | ||
@message = message | ||
@tag_options = tag_options | ||
@text_tag = text_tag | ||
end | ||
|
||
def role | ||
if type == :error | ||
'alert' | ||
else | ||
'status' | ||
end | ||
end | ||
|
||
def css_class | ||
['usa-alert', modifier_css_class, *tag_options[:class]] | ||
end | ||
|
||
def modifier_css_class | ||
case type | ||
when :info | ||
'usa-alert--info' | ||
when :success | ||
'usa-alert--success' | ||
when :error | ||
'usa-alert--error' | ||
when :warning | ||
'usa-alert--warning' | ||
when :emergency | ||
'usa-alert--emergency' | ||
end | ||
end | ||
|
||
def content | ||
@message || super | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'active_model' | ||
|
||
class BaseComponent < ViewComponent::Base | ||
include ActiveModel::Model | ||
|
||
def before_render | ||
validate! | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
class BreadcrumbComponent < ViewComponent::Base; end | ||
class BreadcrumbComponent < BaseComponent; 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