Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
70 changes: 68 additions & 2 deletions app/assets/stylesheets/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,60 @@ code, pre { font-family: var(--font-mono); font-size: 0.9375em; }
.site-footer__inner { padding-block: var(--space-4); }
.site-footer p { margin: 0; }

/* ----------------------------------------------------------------- home --- */
/*
* The one hand-written page. A visitor who lands on / is not here to use the
* app - they are deciding whether to trust it - so the page leads with the
* vision in display size and drops to reading size for everything after.
*/

.hero {
padding-block: var(--space-2) var(--space-5);
border-bottom: 1px solid hsl(var(--border));
margin-bottom: var(--space-5);
}

/* The label above the vision statement. Small and quiet: it says what the
sentence below it is, and the sentence is the thing worth reading. */
.hero__eyebrow {
margin-bottom: var(--space-2);
color: hsl(var(--muted-foreground));
font-size: 0.8125rem;
font-weight: 600;
letter-spacing: 0.06em;
text-transform: uppercase;
}

/* Bigger than an h1 anywhere else in the app, and clamped so it stays a
headline on a phone instead of becoming five short lines. */
.hero h1 {
margin: 0;
font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.75rem);
letter-spacing: -0.02em;
}

.hero__cta { margin: var(--space-4) 0 0; }

/* Sentences, so they get the narrower measure the body copy elsewhere gets by
accident - .site-main is 800px wide, which is wide for a paragraph. */
.prose { max-width: 62ch; }

.prose h2 { margin-top: var(--space-5); }
.prose h2:first-child { margin-top: 0; }

/* The easter egg, and the reason this class exists at all: a horse that turns
up only with ?stampede should look framed, not like a broken hero image. */
.stampede {
margin: var(--space-6) 0 0;
}

.stampede img {
display: block;
width: 100%;
border: 1px solid hsl(var(--border));
border-radius: var(--radius);
}

/* ------------------------------------------------------------- controls --- */

label {
Expand Down Expand Up @@ -282,8 +336,13 @@ input[type="radio"] + label {
breathing room without touching _form.html.erb. */
form > div { margin-bottom: var(--space-3); }

/* .button is for links that act - "Create an account" on the home page. It
rides the same rule as the real controls so a link-button and a submit
button cannot drift apart; the three declarations after are the ones a link
needs and a <button> already has. */
input[type="submit"],
button {
button,
.button {
padding: 10px var(--space-4);
border: 1px solid transparent;
border-radius: calc(var(--radius) - 4px);
Expand All @@ -295,8 +354,15 @@ button {
cursor: pointer;
}

.button {
display: inline-block;
color: hsl(var(--primary-foreground));
text-decoration: none;
}

input[type="submit"]:hover,
button:hover { background: hsl(var(--primary) / 0.9); }
button:hover,
.button:hover { background: hsl(var(--primary) / 0.9); }

/* button_to ... method: :delete posts a form carrying a hidden _method=delete,
which is the only thing distinguishing "Destroy this person" from any other
Expand Down
54 changes: 44 additions & 10 deletions app/views/home/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
<h1>heading</h1>
<p>Hi</p>
<%= image_tag "horse.jpg", alt: "Horse", class: "horse-image" %>

<% if user_signed_in? %>
<p> <%= link_to 'Sign out', destroy_user_session_path, data: { turbo_method: :delete } %> </p>
<% else %>
<p> <%= link_to 'Sign in', new_user_session_path %> </p>
<p> <%= link_to 'Sign up', new_user_registration_path %> </p>
<% end %>
<% content_for :title, "Along With You" %>

<section class="hero">
<p class="hero__eyebrow">Our vision</p>
<h1>No one faces a medical journey overwhelmed by information, uncertainty, or alone.</h1>

<%# The one action on the page, and the only place in the app that offers to
make an account - the header carries Sign in and nothing else. Hidden
once you have one: a signed-in visitor already has the whole nav. %>
<% unless user_signed_in? %>
<p class="hero__cta">
<%= link_to "Create an account", new_user_registration_path, class: "button" %>
</p>
<% end %>
</section>

<section class="prose">
<h2>Our mission</h2>
<p>
Provide healthcare professionals with free tools to help individuals
organize important medical information, so individuals receiving a critical
health diagnosis can focus on their care and make better informed decisions.
</p>

<h2>Support the work</h2>
<p>
Along With You is given free of charge to those facing a health challenge.
It is our hope that having the information you need right on hand will give
you one less thing to worry about, and let you know that many are along with
you.
</p>
<p>
If you would like to make a donation to Along With You, visit
<%= link_to "alongwithyou.org", "https://www.alongwithyou.org" %>.
</p>
</section>

<%# The horse used to be the whole home page. It is an easter egg now: the URL
has to ask for it. params.key? rather than reading the value, so a bare
?stampede - nothing after the name - is enough. %>
<% if params.key?(:stampede) %>
<figure class="stampede">
<%= image_tag "horse.jpg", alt: "Five horses at full gallop, kicking up dust" %>
</figure>
<% end %>
55 changes: 52 additions & 3 deletions test/controllers/home_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,56 @@
require "test_helper"

class HomeControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
# For the signed-in case below. There is no users fixture and no global
# Devise test setup yet, so this class brings its own.
include Devise::Test::IntegrationHelpers

test "should get index" do
get root_url
assert_response :success
end

test "index speaks to visitors" do
get root_url

assert_select "h1", /No one faces a medical journey/
assert_select "a[href='https://www.alongwithyou.org']"
end

test "index does not repeat the header's account links" do
get root_url

assert_select ".site-main a[href=?]", new_user_session_path, count: 0
assert_select ".site-main a[href=?]", destroy_user_session_path, count: 0
end

test "index offers a visitor an account" do
get root_url
assert_select ".hero a[href=?]", new_user_registration_path, text: "Create an account"
end

test "index does not offer an account to someone who has one" do
sign_in User.create!(email: "signed-in@example.com", password: "password",
confirmed_at: Time.current)

get root_url
assert_select ".hero a[href=?]", new_user_registration_path, count: 0
end

test "index hides the horse" do
get root_url
assert_select "img[src*=?]", "horse", count: 0
end

test "index shows the horse to anyone who asks for a stampede" do
get root_url(stampede: "")
assert_select "img[src*=?]", "horse"
end

# A bare ?stampede - no equals sign, no value - parses to a nil value, so the
# view has to ask whether the key is there rather than what it says.
test "index shows the horse for a valueless stampede" do
get "/?stampede"
assert_select "img[src*=?]", "horse"
end
end
Loading