Startinga basic frontend application.

This commit is contained in:
Dave Smith-Hayes 2024-02-24 22:54:16 -05:00
parent 523197902f
commit dda9cf2fe2
5 changed files with 47 additions and 18 deletions

View File

@ -1,4 +1,4 @@
await Bun.build({
entrypoints: [ './src/index.ts' ],
outdir: './public/js'
entrypoints: [ './src/index.ts' ],
outdir: './public/js'
});

View File

@ -4,6 +4,6 @@
<title>Slovocast</title>
</head>
<body>
<script src="js/index.js" ></script>
<script src="js/index.js"></script>
</body>
</html>

View File

@ -1923,12 +1923,40 @@ var require_mithril = __commonJS((exports, module) => {
});
// src/index.ts
var import_mithril2 = __toESM(require_mithril(), 1);
// src/components/UserList.ts
var import_mithril = __toESM(require_mithril(), 1);
// src/models/User.ts
class User {
username;
constructor(username) {
this.username = username;
}
getUsername() {
return this.username;
}
}
// src/components/UserList.ts
var users = [
new User("U1"),
new User("U2"),
new User("U3")
];
var oninit = function() {
};
var view = function() {
return import_mithril.default(".UserList", import_mithril.default("ul", users.map((u) => import_mithril.default("li", u.getUsername()))));
};
var UserList = { oninit, view };
var UserList_default = UserList;
// src/index.ts
var App = {
view: function() {
return import_mithril.default("body", [
import_mithril.default("div", "Hello!")
]);
return import_mithril2.default("body", [UserList_default]);
}
};
import_mithril.default.mount(document.body, App);
import_mithril2.default.mount(document.body, App);

View File

@ -7,12 +7,15 @@ const users: User[] = [
new User('U3')
];
export default const UserList = {
getList: function () {
return users.map(u => m('li', u.getUsername()));
},
view: function () {
return m('li', { id: 'UserList' }, this.getList());
}
const oninit = function () {
// get the users value
};
const view = function () {
return m('.UserList',
m('ul', users.map(u => m('li', u.getUsername())))
);
}
const UserList = { oninit, view };
export default UserList;

View File

@ -3,9 +3,7 @@ import UserList from './components/UserList';
const App = {
view: function() {
return m('body', [
UserList
]);
return m('body', [ UserList ]);
}
}