From 54ad10dc686090e583710be343efd4eec7265258 Mon Sep 17 00:00:00 2001 From: Matthew Landauer Date: Wed, 7 Feb 2024 23:17:28 +0000 Subject: [PATCH] Allow size override on heading --- app/components/tailwind/heading.html.erb | 2 +- app/components/tailwind/heading.rb | 15 +++++++++++++-- .../applications/_address_with_results.html.erb | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/components/tailwind/heading.html.erb b/app/components/tailwind/heading.html.erb index bae4ff9a6..f4e955d6d 100644 --- a/app/components/tailwind/heading.html.erb +++ b/app/components/tailwind/heading.html.erb @@ -1,3 +1,3 @@ -

+

<%= content %>

diff --git a/app/components/tailwind/heading.rb b/app/components/tailwind/heading.rb index 228ec04c1..56cbab683 100644 --- a/app/components/tailwind/heading.rb +++ b/app/components/tailwind/heading.rb @@ -5,13 +5,24 @@ module Tailwind class Heading < ViewComponent::Base extend T::Sig - sig { params(tag: Symbol, extra_classes: String).void } - def initialize(tag:, extra_classes: "") + # TODO: Perhaps we should allow the size override to work by saying we want an h1 heading but with the styling of an h2? + sig { params(tag: Symbol, size: T.nilable(String), extra_classes: String).void } + def initialize(tag:, size: nil, extra_classes: "") super raise "Invalid tag" unless tag == :h1 @extra_classes = extra_classes + + case size + when "3xl" + @size_class = T.let("text-3xl", String) + # 4xl is the default size for h1 + when "4xl", nil + @size_class = T.let("text-4xl", String) + else + raise "Unexpected size #{size}" + end end end end diff --git a/app/views/_tailwind/applications/_address_with_results.html.erb b/app/views/_tailwind/applications/_address_with_results.html.erb index 371d35d3d..4efe7ecea 100644 --- a/app/views/_tailwind/applications/_address_with_results.html.erb +++ b/app/views/_tailwind/applications/_address_with_results.html.erb @@ -5,7 +5,7 @@ <% if applications %>
<%# TODO: This is smaller than the "standard" h1 heading defined in the component %> -

Search results

+ <%= render Tailwind::Heading.new(tag: :h1, size: "3xl").with_content("Search results") %>