Add a login form

This commit is contained in:
Dave Smith-Hayes 2024-09-30 22:07:05 -04:00
parent eff637ffa5
commit 5553334654
4 changed files with 32 additions and 9 deletions

View File

@ -1,11 +1,12 @@
import m from "mithril";
import { MessageBox } from "./MessageBox";
import { LoginForm } from "./Login";
export const ChatApp = {
view: function () {
return m("div", { class: "container" }, [
m("h1", "A Stupid Chat Application"),
m(MessageBox)
m(LoginForm)
]);
}
};

View File

@ -0,0 +1,11 @@
import m from "mithril";
export const LoginForm = {
view: function() {
return m("form", { action: "/login" }, [
m("label", { for: "username" }, "Username"),
m("input", { type: "text", name: "username" }),
m("input", { type: "submit", value: "Login" })
]);
}
};

View File

@ -1,4 +1,8 @@
import m from "mithril";
import { ChatApp } from "./ChatApp";
const localState = {
messages: []
}
m.mount(document.getElementById("app"), ChatApp);

View File

@ -1717,28 +1717,35 @@ var require_mithril = __commonJS((exports, module) => {
});
// src/components/index.js
var import_mithril3 = __toESM(require_mithril(), 1);
var import_mithril4 = __toESM(require_mithril(), 1);
// src/components/ChatApp.js
var import_mithril2 = __toESM(require_mithril(), 1);
var import_mithril3 = __toESM(require_mithril(), 1);
// src/components/MessageBox.js
var import_mithril = __toESM(require_mithril(), 1);
var MessageBox = {
// src/components/Login.js
var import_mithril2 = __toESM(require_mithril(), 1);
var LoginForm = {
view: function() {
return import_mithril.default("div", { id: "message-box" }, "Do Something");
return import_mithril2.default("form", { action: "/login" }, [
import_mithril2.default("label", { for: "username" }, "Username"),
import_mithril2.default("input", { type: "text", name: "username" }),
import_mithril2.default("input", { type: "submit", value: "Login" })
]);
}
};
// src/components/ChatApp.js
var ChatApp = {
view: function() {
return import_mithril2.default("div", { class: "container" }, [
import_mithril2.default("h1", "A Stupid Chat Application"),
import_mithril2.default(MessageBox)
return import_mithril3.default("div", { class: "container" }, [
import_mithril3.default("h1", "A Stupid Chat Application"),
import_mithril3.default(LoginForm)
]);
}
};
// src/components/index.js
import_mithril3.default.mount(document.getElementById("app"), ChatApp);
import_mithril4.default.mount(document.getElementById("app"), ChatApp);