-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3372 from projectblacklight/title_component
Extract a TitleComponent
- Loading branch information
Showing
4 changed files
with
30 additions
and
18 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,6 @@ | ||
<div class="container site-title-container"> | ||
<div class="site-title-wrapper"> | ||
<%= title %> | ||
<%= subtitle %> | ||
</div> | ||
</div> |
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,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module Spotlight | ||
# Draws the title in the masthead | ||
class TitleComponent < ViewComponent::Base | ||
def initialize(title:, subtitle:) | ||
@title = title | ||
@subtitle = subtitle | ||
super | ||
end | ||
|
||
def title | ||
tag.h1 @title, class: 'site-title h2' | ||
end | ||
|
||
def subtitle | ||
return unless @subtitle | ||
|
||
tag.small(@subtitle, class: 'd-none d-md-block py-2 fs-4') | ||
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