Skip to content

Commit

Permalink
Add email form
Browse files Browse the repository at this point in the history
  • Loading branch information
olinelson committed Dec 22, 2024
1 parent 870d5ff commit 6b03714
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
6 changes: 6 additions & 0 deletions frontend/javascript/controllers/example_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 1,6 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
connect() {
console.log("Hello, Stimulus!", this.element)
}
}
26 changes: 26 additions & 0 deletions frontend/javascript/index.js
Original file line number Diff line number Diff line change
@@ -1,7 1,33 @@
import "$styles/index.css";
import "$styles/pico.css";
import * as Turbo from "@hotwired/turbo";
import { Application } from "@hotwired/stimulus";

/**
* Adds support for declarative shadow DOM. Requires your HTML <head> to include:
* `<meta name="turbo-cache-control" content="no-cache" />`
*/
import * as TurboShadow from "turbo-shadow";

// Import all JavaScript & CSS files from src/_components
import components from "$components/**/*.{js,jsx,js.rb,css}";

console.info("Bridgetown is loaded!");

window.Stimulus = Application.start();

import controllers from "./controllers/**/*.{js,js.rb}";
Object.entries(controllers).forEach(([filename, controller]) => {
if (
filename.includes("_controller.") ||
filename.includes("-controller.")
) {
const identifier = filename
.replace("./controllers/", "")
.replace(/[_-]controller\..*$/, "")
.replace(/_/g, "-")
.replace(/\//g, "--");

Stimulus.register(identifier, controller.default);
}
});
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 15,10 @@
"postcss-load-config": "^4.0.1",
"postcss-preset-env": "^9.1.2",
"read-cache": "^1.0.0"
},
"dependencies": {
"@hotwired/stimulus": "^3.2.2",
"@hotwired/turbo": "^8.0.12",
"turbo-shadow": "^1.2.0"
}
}
16 changes: 16 additions & 0 deletions src/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 36,22 @@ layout: default
<% end %>
</section>

<section id="email-list">
<h4>Email list</h4>
<form method="POST" action="https://octopus.olinelson.com/contacts">
<input hidden name="return_to" value="https://olinelson.com#email-list"/>
<fieldset role="group">
<input
type="email"
name="contact[email]"
placeholder="Enter your email"
autocomplete="email"
/>
<input type="submit" value="Join"/>
</fieldset>
</form>
</section>

<section>
<h4>Links</h4>

Expand Down
15 changes: 15 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 421,16 @@
resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz#c57c8afbb4054a3ab8317591a0b7320360b444ae"
integrity sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==

"@hotwired/stimulus@^3.2.2":
version "3.2.2"
resolved "https://registry.yarnpkg.com/@hotwired/stimulus/-/stimulus-3.2.2.tgz#071aab59c600fed95b97939e605ff261a4251608"
integrity sha512-eGeIqNOQpXoPAIP7tC1 1Yc1yl1xnwYqg 3mzqxyrbE5pg5YFBZcA6YoTiByJB6DKAEsiWtl6tjTJS4IYtbB7A==

"@hotwired/turbo@^8.0.12":
version "8.0.12"
resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-8.0.12.tgz#50aa8345d7f62402680c6d2d9814660761837001"
integrity sha512-l3BiQRkD7qrnQv6ms6sqPLczvwbQpXt5iAVwjDvX0iumrz6yEonQkNAzNjeDX25/OJMFDTxpHjkJZHGpM9ikWw==

"@isaacs/cliui@^8.0.2":
version "8.0.2"
resolved "https://registry.yarnpkg.com/@isaacs/cliui/-/cliui-8.0.2.tgz#b37667b7bc181c168782259bab42474fbf52b550"
Expand Down Expand Up @@ -1130,6 1140,11 @@ supports-preserve-symlinks-flag@^1.0.0:
resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09"
integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8 muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==

turbo-shadow@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/turbo-shadow/-/turbo-shadow-1.2.0.tgz#0b1534ec073a39b96e6d5a39738d196f5a82760a"
integrity sha512-E62rmb07CG9mA71asc3JRhKgzyfmW1OSl/m5qF1l4zT81xAYQaMIIhO/EfKdhVHeomxJNH3cOZ761tN2gA/leQ==

update-browserslist-db@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.1.tgz#80846fba1d79e82547fb661f8d141e0945755fe5"
Expand Down

0 comments on commit 6b03714

Please sign in to comment.