Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
robbyronk committed Oct 1, 2023
2 parents 85ca9b0 + 84a78e0 commit dd2b4aa
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 143 deletions.
3 changes: 2 additions & 1 deletion assets/css/app.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400&display=swap" rel="stylesheet');
@import url('https://fonts.googleapis.com/css2?family=Racing+Sans+One&display=swap" rel="stylesheet');
/* This file is for your main application CSS */
6 changes: 5 additions & 1 deletion assets/tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ module.exports = {
],
theme: {
extend: {
fontFamily: {
'racing-sans-one': ['Racing Sans One', 'sans-serif'],
'ibm-plex-sans': ['IBM Plex Sans', 'sans-serif'],
},
colors: {
brand: "#FD4F00",
brand: "#000000",
}
},
},
Expand Down
2 changes: 1 addition & 1 deletion lib/leadfoot_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ defmodule LeadfootWeb.CoreComponents do
def simple_form(assigns) do
~H"""
<.form :let={f} for={@for} as={@as} {@rest}>
<div class="mt-10 space-y-8 bg-white">
<div class="mt-0 space-y-8 bg-transparent">
<%= render_slot(@inner_block, f) %>
<div :for={action <- @actions} class="mt-2 flex items-center justify-between gap-6">
<%= render_slot(action, f) %>
Expand Down
29 changes: 2 additions & 27 deletions lib/leadfoot_web/components/layouts/app.html.heex
Original file line number Diff line number Diff line change
@@ -1,30 +1,5 @@
<header class="px-4 sm:px-6 lg:px-8">
<div class="flex items-center justify-between border-b border-zinc-100 py-3 text-sm">
<div class="flex items-center gap-4">
<a href="/">
<img src={~p"/images/logo.svg"} width="36" />
</a>
<p class="bg-brand/5 text-brand rounded-full px-2 font-medium leading-6">
v<%= Application.spec(:phoenix, :vsn) %>
</p>
</div>
<div class="flex items-center gap-4 font-semibold leading-6 text-zinc-900">
<a href="https://twitter.com/elixirphoenix" class="hover:text-zinc-700">
@elixirphoenix
</a>
<a href="https://github.com/phoenixframework/phoenix" class="hover:text-zinc-700">
GitHub
</a>
<a
href="https://hexdocs.pm/phoenix/overview.html"
class="rounded-lg bg-zinc-100 px-2 py-1 hover:bg-zinc-200/80"
>
Get Started <span aria-hidden="true">&rarr;</span>
</a>
</div>
</div>
</header>
<main class="px-4 py-20 sm:px-6 lg:px-8">
<header class="px-4 sm:px-6 lg:px-6"></header>
<main class="px-4 sm:px-3 md:px-3 lg:px-4">
<div class="mx-auto max-w-2xl">
<.flash_group flash={@flash} />
<%= @inner_content %>
Expand Down
86 changes: 44 additions & 42 deletions lib/leadfoot_web/components/layouts/root.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,50 @@
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
</script>
</head>
<body class="bg-white antialiased">
<ul class="relative z-10 flex items-center gap-4 px-4 sm:px-6 lg:px-8 justify-end">
<%= if @current_user do %>
<li class="text-[0.8125rem] leading-6 text-zinc-900">
<%= @current_user.email %>
</li>
<li>
<.link
href={~p"/users/settings"}
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Settings
</.link>
</li>
<li>
<.link
href={~p"/users/log_out"}
method="delete"
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Log out
</.link>
</li>
<% else %>
<li>
<.link
href={~p"/users/register"}
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Register
</.link>
</li>
<li>
<.link
href={~p"/users/log_in"}
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Log in
</.link>
</li>
<% end %>
</ul>
<body class="bg-white">
<div class="mx-auto max-w-2xl">
<ul class="relative z-10 flex items-center gap-4 mx-4 sm:mx-1 justify-end">
<%= if @current_user do %>
<li class="text-[0.8125rem] leading-6 text-zinc-900">
<%= @current_user.email %>
</li>
<li>
<.link
href={~p"/users/settings"}
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Settings
</.link>
</li>
<li>
<.link
href={~p"/users/log_out"}
method="delete"
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Log out
</.link>
</li>
<% else %>
<li>
<.link
href={~p"/users/register"}
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Register
</.link>
</li>
<li>
<.link
href={~p"/users/log_in"}
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700"
>
Log in
</.link>
</li>
<% end %>
</ul>
</div>
<%= @inner_content %>
</body>
</html>
175 changes: 104 additions & 71 deletions lib/leadfoot_web/live/suspension_calculator_live/view.html.heex
Original file line number Diff line number Diff line change
@@ -1,81 +1,114 @@
<div class="grid grid-cols-4 md:grid-cols-2 gap-2 text-black">
<div class="bg-slate-300 p-2">
<div class="grid grid-cols-2 md:grid-cols-2 gap-2 text-black">
<div class="rounded-lg bg-transparent p-2">
<h1 class="text-4xl md:text-6xl font-racing-sans-one font-weight: lighter">LEADFOOT</h1>
<h2 class="text-1xl md:text-2xl font-ibm-plex-sans whitespace-nowrap">
Suspension Calculator
</h2>
</div>
<div class="relative rounded-lg bg-transparent p-2">
<button
class="absolute right-0 bottom-3 bg-transparent hover:bg-zinc-600 text-sm text-slate-700 font-semibold hover:text-white py-1 px-3 border border-slate-700 hover:border-transparent rounded"
onclick="my_modal_1.showModal()"
>
Help
</button>
<dialog
id="my_modal_1"
class="modal absolute m-auto left-4 right-4 rounded-xl bg-white max-w-2xl"
>
<form method="dialog" class="modal-box">
<button class="btn btn-sm btn-square btn-ghost absolute right-4 top-3">✕</button>
<h3 class="font-bold text-lg">Help</h3>
<p class="mt-4">All units are metric.</p>
<p class="mt-2">
Suspension frequencies are a good starting point but the best spring rate will not come from a calculator.
</p>
<p class="mt-2">
A faster spring frequency means the car will be more responsive. Usually, the front frequency should be the same or lower than the rear frequency.
</p>
<p class="mt-2">To start, try 2.0 Hz in front and 2.2 Hz in rear.</p>
<div class="modal-action flex justify-center">
<button class="mt-6 rounded-lg bg-zinc-900 hover:bg-zinc-700 py-2 px-3 text-sm font-semibold leading-6 text-white active:text-white/80">
Close
</button>
</div>
</form>
</dialog>
</div>
</div>
<div class="mt-2 grid grid-cols-1 gap-2 text-black">
<div class="rounded-lg bg-slate-800/10 p-2">
<.simple_form for={@form} id="form" phx-change="validate" phx-submit="save">
<div class="grid-auto-fit">
<.input class="w-full" field={@form[:mass]} label="Mass" inputmode="numeric" />
<.input
class="w-full"
field={@form[:front_distribution]}
type="text"
label="Front Distribution"
inputmode="numeric"
/>

<div class="sm-grid-auto-fit">
<div class="inline-block">
<.input
class="w-full"
field={@form[:front_spring_rate]}
type="text"
label="Front Spring Rate"
inputmode="numeric"
/>
</div>

<div class="inline-block">
<.input
class="w-full"
field={@form[:rear_spring_rate]}
type="text"
label="Rear Spring Rate"
inputmode="numeric"
/>
</div>
<div class="sm-grid-auto-fit flex justify-center py-2">
<div class="inline-block ml-6">
<.input class="w-full" field={@form[:mass]} label="Mass" inputmode="numeric" />
</div>

<div class="sm-grid-auto-fit">
<div class="inline-block">
<.input
class="w-full"
field={@form[:front_downforce]}
type="text"
label="Front Downforce"
inputmode="numeric"
/>
</div>

<div class="inline-block">
<.input
class="w-full"
field={@form[:rear_downforce]}
type="text"
label="Rear Downforce"
inputmode="numeric"
/>
</div>
<div class="inline-block px-6">
<.input
class="w-full"
field={@form[:front_distribution]}
type="text"
label="Front Distribution"
inputmode="numeric"
/>
</div>
</div>
<div class="sm-grid-auto-fit flex justify-center">
<div class="inline-block ml-6">
<.input
class="w-full"
field={@form[:front_spring_rate]}
type="text"
label="Front Spring Rate"
inputmode="numeric"
/>
</div>
<div class="inline-block px-6">
<.input
class="w-full"
field={@form[:rear_spring_rate]}
type="text"
label="Rear Spring Rate"
inputmode="numeric"
/>
</div>
</div>

<div class="sm-grid-auto-fit flex justify-center">
<div class="inline-block ml-6">
<.input
class="w-full"
field={@form[:front_downforce]}
type="text"
label="Front Downforce"
inputmode="numeric"
/>
</div>
<div class="inline-block px-6">
<.input
class="w-full"
field={@form[:rear_downforce]}
type="text"
label="Rear Downforce"
inputmode="numeric"
/>
</div>
</div>
<div class="py-1 flex justify-center">
<.button type="submit">Calculate</.button>
</div>
</.simple_form>

<div>front: <%= Float.round(@front_frequency, 2) %> Hz</div>
<div>rear: <%= Float.round(@rear_frequency, 2) %> Hz</div>
<div>ratio: <%= Float.round(@ratio, 2) %></div>

<div class="mt-3">with downforce</div>

<div>front: <%= Float.round(@front_with_downforce, 2) %> Hz</div>
<div>rear: <%= Float.round(@rear_with_downforce, 2) %> Hz</div>
<div>ratio: <%= Float.round(@ratio_with_downforce, 2) %></div>
</div>
<div class="bg-slate-300 p-2">
<p>All units are metric.</p>
<p>
Suspension frequencies are a good starting point but the best spring rate will not come from a calculator.
</p>
<p>A faster spring frequency means the car will be more responsive.</p>
<p>Usually, the front frequency should be the same or lower than the rear frequency.</p>
<p>To start, try 2.0 Hz in front and 2.2 Hz in rear.</p>
</div>
<div class="my-4 grid md:grid-cols-1 gap-2 text-black">
<div class="px-8 sm:px-24 md:px-28 rounded-lg bg-slate-800/10 p-2">
<div><strong>Without Downforce</strong></div>
<div>Front: <%= Float.round(@front_frequency, 2) %> Hz</div>
<div>Rear: <%= Float.round(@rear_frequency, 2) %> Hz</div>
<div>Ratio: <%= Float.round(@ratio, 2) %></div>
<div class="mt-3"><strong>With Downforce</strong></div>
<div>Front: <%= Float.round(@front_with_downforce, 2) %> Hz</div>
<div>Rear: <%= Float.round(@rear_with_downforce, 2) %> Hz</div>
<div>Ratio: <%= Float.round(@ratio_with_downforce, 2) %></div>
</div>
</div>

0 comments on commit dd2b4aa

Please sign in to comment.