Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app-rails/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ gem "faraday"
# Create fake data (outside of dev/test block to support seeding lower environments)
gem "faker", "~> 3.2"

gem "lookbook", ">= 2.3.9"

group :development, :test do
gem "guard-rspec", require: false

Expand All @@ -83,6 +85,10 @@ group :development, :test do
# Testing framework
gem "factory_bot_rails"
gem "rspec-rails", "~> 6.1.0"

# Required by Lookbook
gem "listen"
gem "actioncable"
end

group :development do
Expand Down
26 changes: 26 additions & 0 deletions app-rails/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ GEM
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
crass (1.0.6)
css_parser (1.21.1)
addressable
cssbundling-rails (1.4.1)
railties (>= 6.0.0)
date (3.4.1)
Expand Down Expand Up @@ -191,6 +193,8 @@ GEM
guard (~> 2.1)
guard-compat (~> 1.1)
rspec (>= 2.99.0, < 4.0)
htmlbeautifier (1.4.3)
htmlentities (4.3.4)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
importmap-rails (2.1.0)
Expand Down Expand Up @@ -224,6 +228,18 @@ GEM
loofah (2.24.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
lookbook (2.3.9)
activemodel
css_parser
htmlbeautifier (~> 1.3)
htmlentities (~> 4.3.4)
marcel (~> 1.0)
railties (>= 5.0)
redcarpet (~> 3.5)
rouge (>= 3.26, < 5.0)
view_component (>= 2.0)
yard (~> 0.9)
zeitwerk (~> 2.5)
lumberjack (1.2.10)
mail (2.8.1)
mini_mime (>= 0.1.1)
Expand Down Expand Up @@ -351,13 +367,15 @@ GEM
ffi (~> 1.0)
rdoc (6.12.0)
psych (>= 4.0.0)
redcarpet (3.6.1)
regexp_parser (2.10.0)
reline (0.6.0)
io-console (~> 0.5)
responders (3.1.1)
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.4.1)
rouge (4.5.2)
route_translator (14.2.0)
actionpack (>= 6.1)
activesupport (>= 6.1)
Expand Down Expand Up @@ -456,6 +474,10 @@ GEM
unicode-emoji (4.0.4)
uri (1.0.3)
useragent (0.16.11)
view_component (3.21.0)
activesupport (>= 5.2.0, < 8.1)
concurrent-ruby (~> 1.0)
method_source (~> 1.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.1)
Expand All @@ -470,6 +492,7 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
yard (0.9.37)
zeitwerk (2.7.2)

PLATFORMS
Expand All @@ -489,6 +512,7 @@ PLATFORMS
x86_64-linux-musl

DEPENDENCIES
actioncable
active_storage_validations
aws-sdk-cognitoidentityprovider (~> 1.88)
aws-sdk-rails
Expand All @@ -507,6 +531,8 @@ DEPENDENCIES
jbuilder
jwt
letter_opener
listen
lookbook (>= 2.3.9)
pg (~> 1.1)
pg-aws_rds_iam (~> 0.7.0)
puma (>= 5.0)
Expand Down
9 changes: 9 additions & 0 deletions app-rails/app/previews/breadcrumbs_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class BreadcrumbsPreview < Lookbook::Preview
layout "component_preview"

def default
render template: "application/_breadcrumbs", locals: { crumbs: [
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

render partial: "application/breadcrumbs" not supported by lookbook so use render template: and remember to prefix with _ and set layout to "component_preview" to get rid of application layout

{ name: "Passport applications", url: "https://google.com" },
], current_name: "New passport application" }
end
end
6 changes: 3 additions & 3 deletions app-rails/app/views/application/_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
<% end %>

<li class="usa-nav__primary-item">
<%= render partial: "language-toggle", locals: { container_class: "display-block desktop:display-none relative" } %>
<%= render partial: "application/language-toggle", locals: { container_class: "display-block desktop:display-none relative" } %>
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to explicitly set partial paths rather than rely on Rails fallback behavior. This is probably better practice anyways, easier to read/find things for the reader

</li>
</ul>
</div>
</nav>

<%= render partial: "language-toggle", locals: { container_class: "usa-language-container display-none desktop:display-block" } %>
<%= render partial: "application/language-toggle", locals: { container_class: "usa-language-container display-none desktop:display-block" } %>
</div>
</header>
</header>
4 changes: 2 additions & 2 deletions app-rails/app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

<body>
<div class="display-flex flex-column minh-viewport">
<%= render partial: 'header' %>
<%= render partial: 'application/header' %>

<main id="main-content" class="grid-col-fill display-flex flex-column">
<div class="grid-col-fill <%= yield :main_col_class %>">
<section class="usa-section">
<div class="grid-container">
<%= render partial: 'flash' %>
<%= render partial: 'application/flash' %>

<div class="grid-row grid-gap">
<%= yield :before_content_col %>
Expand Down
35 changes: 35 additions & 0 deletions app-rails/app/views/layouts/component_preview.html.erb
Copy link
Copy Markdown
Collaborator Author

@lorenyu lorenyu Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly a copy of application.html.erb except without the application header/footer

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<%# Top-level layout for all pages in the application %>
<!DOCTYPE html>
<html lang="<%= I18n.locale %>">
<head>
<title>
<%= content_for?(:title) ? "#{ yield(:title) } | #{ t('header.title') }" : t("header.title") %>
</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<%= favicon_link_tag asset_path('@uswds/uswds/dist/img/us_flag_small.png') %>

<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= yield :head %>

<%= javascript_importmap_tags %>
<%= javascript_include_tag '@uswds/uswds/dist/js/uswds-init.min.js' %>
</head>

<body>
<div class="display-flex flex-column minh-viewport">
<main id="main-content" class="grid-col-fill display-flex flex-column">
<div class="grid-col-fill <%= yield :main_col_class %>">
<div class="grid-container">
<%= content_for?(:content) ? yield(:content) : yield %>
</div>
</div>
</main>
</div>

<%= javascript_include_tag '@uswds/uswds/dist/js/uswds.min.js' %>
<%= yield :scripts %>
</body>
</html>
3 changes: 3 additions & 0 deletions app-rails/config/initializers/lookbook.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Rails.application.configure do
config.lookbook.preview_paths = [Rails.root.join("app", "previews"),]
end
2 changes: 2 additions & 0 deletions app-rails/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Keep the default /up rails endpoint.
get "up" => "rails/health#show"

mount Lookbook::Engine, at: "/lookbook" if ENV["ENABLE_LOOKBOOK"].present?

# Support locale prefixes for these routes:
localized do
# Defines the root path route ("/")
Expand Down
6 changes: 6 additions & 0 deletions app-rails/local.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,9 @@ DB_HOST=127.0.0.1
DB_NAME=app
DB_USER=app
DB_PASSWORD=secret123

############################
# Lookbook
############################

ENABLE_LOOKBOOK=true
4 changes: 4 additions & 0 deletions infra/app/app-config/dev.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ module "dev_config" {
# Defaults to `false`. Uncomment the next line to enable.
# enable_command_execution = true

service_override_extra_environment_variables = {
ENABLE_LOOKBOOK = "true"
}

# Uncomment to override default feature flag values
feature_flag_overrides = {
BAR = true
Expand Down
Loading