From 6b03714b69eeb27ba0142128c8e002da67754cc9 Mon Sep 17 00:00:00 2001 From: olinelson Date: Sun, 22 Dec 2024 21:03:23 +1100 Subject: [PATCH] Add email form --- .../controllers/example_controller.js | 6 +++++ frontend/javascript/index.js | 26 +++++++++++++++++++ package.json | 5 ++++ src/index.erb | 16 ++++++++++++ yarn.lock | 15 +++++++++++ 5 files changed, 68 insertions(+) create mode 100644 frontend/javascript/controllers/example_controller.js diff --git a/frontend/javascript/controllers/example_controller.js b/frontend/javascript/controllers/example_controller.js new file mode 100644 index 0000000..876629c --- /dev/null +++ b/frontend/javascript/controllers/example_controller.js @@ -0,0 +1,6 @@ +import { Controller } from "@hotwired/stimulus" +export default class extends Controller { + connect() { + console.log("Hello, Stimulus!", this.element) + } +} diff --git a/frontend/javascript/index.js b/frontend/javascript/index.js index 64e098e..e416d9f 100644 --- a/frontend/javascript/index.js +++ b/frontend/javascript/index.js @@ -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 to include: + * `` + */ +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); + } +}); diff --git a/package.json b/package.json index 5b79453..08431b7 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/index.erb b/src/index.erb index 2bb3f66..85776ba 100644 --- a/src/index.erb +++ b/src/index.erb @@ -36,6 +36,22 @@ layout: default <% end %> +
+

Email list

+
+ +
+ + +
+
+
+

Links

diff --git a/yarn.lock b/yarn.lock index 5bf74d7..c0e1e32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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"