Skip to content

Commit

Permalink
Change all functions to arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
josephspurrier committed Jul 8, 2020
1 parent 4f39386 commit be5dd8c
Show file tree
Hide file tree
Showing 16 changed files with 91 additions and 52 deletions.
2 changes: 1 addition & 1 deletion src/app/ui/src/component/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var View = {
}
},
removeFlash: (i) => {
View.list = View.list.filter(function (v) {
View.list = View.list.filter((v) => {
return v !== i;
});
},
Expand Down
34 changes: 17 additions & 17 deletions src/app/ui/src/component/flash.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,84 +18,84 @@ export default {
};

export const success = () => ({
oninit: function () {
oninit: () => {
Flash.timeout = -1;
Flash.success(text("Text", "This is a success message."));
},
onremove: function () {
onremove: () => {
Flash.clear();
},
view: () => <Flash />,
});

export const failed = () => ({
oninit: function () {
oninit: () => {
Flash.timeout = -1;
Flash.failed(text("Text", "This is a failed message."));
},
onremove: function () {
onremove: () => {
Flash.clear();
},
view: () => <Flash />,
});

export const warning = () => ({
oninit: function () {
oninit: () => {
Flash.timeout = -1;
Flash.warning(text("Text", "This is a warning message."));
},
onremove: function () {
onremove: () => {
Flash.clear();
},
view: () => <Flash />,
});

export const primary = () => ({
oninit: function () {
oninit: () => {
Flash.timeout = -1;
Flash.primary(text("Text", "This is a primary message."));
},
onremove: function () {
onremove: () => {
Flash.clear();
},
view: () => <Flash />,
});

export const link = () => ({
oninit: function () {
oninit: () => {
Flash.timeout = -1;
Flash.link(text("Text", "This is a link message."));
},
onremove: function () {
onremove: () => {
Flash.clear();
},
view: () => <Flash />,
});

export const info = () => ({
oninit: function () {
oninit: () => {
Flash.timeout = -1;
Flash.info(text("Text", "This is a info message."));
},
onremove: function () {
onremove: () => {
Flash.clear();
},
view: () => <Flash />,
});

export const dark = () => ({
oninit: function () {
oninit: () => {
Flash.timeout = -1;
Flash.dark(text("Text", "This is a dark message."));
},
onremove: function () {
onremove: () => {
Flash.clear();
},
view: () => <Flash />,
});

export const Action = () => ({
oninit: function () {
oninit: () => {
Flash.timeout = number("Timeout (milliseconds)", "2000");
Flash.prepend = boolean("Prepend", false);
let s = select(
Expand All @@ -112,9 +112,9 @@ export const Action = () => ({
"success"
);
Flash[s](text("Text", "This is a test message."));
button("Show Message", function () {});
button("Show Message", () => {});
},
onremove: function () {
onremove: () => {
Flash.clear();
},
view: () => <Flash />,
Expand Down
42 changes: 42 additions & 0 deletions src/app/ui/src/component/input.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import m from "mithril"; // eslint-disable-line no-unused-vars
import { withKnobs, text, select } from "@storybook/addon-knobs";
import { withA11y } from "@storybook/addon-a11y";
import Input from "./input";
import "~/style/main.scss";

export default {
title: "Component/Input",
component: Input,
decorators: [withKnobs, withA11y],
};

export const input = () => ({
oninit: (vnode) => {
vnode.state.type = select(
"Type",
{
text: "text",
color: "color",
date: "date",
"datetime-local": "datetime-local",
email: "email",
hidden: "hidden",
month: "month",
number: "number",
password: "password",
range: "range",
search: "search",
time: "time",
week: "week",
},
"text"
);
},
view: (vnode) => (
<Input
label="First Name"
value={text("Value", "John")}
type={vnode.state.type}
/>
),
});
2 changes: 1 addition & 1 deletion src/app/ui/src/component/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import m from "mithril"; // eslint-disable-line no-unused-vars
import CookieStore from "@/module/cookiestore";

var View = () => {
let logout = function () {
let logout = () => {
CookieStore.clear();
m.route.set("/");
};
Expand Down
3 changes: 0 additions & 3 deletions src/app/ui/src/component/menu.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,3 @@ export default {
export const menu = () => ({
view: () => <Menu />,
});
menu.story = {
name: "Menu",
};
2 changes: 1 addition & 1 deletion src/app/ui/src/component/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var View = () => {
NoteStore.runUpdate(vnode.attrs.id, e.target.value);
vnode.state.saving = "Saving...";
m.redraw();
setTimeout(function () {
setTimeout(() => {
vnode.state.saving = "";
m.redraw();
}, 1000);
Expand Down
20 changes: 10 additions & 10 deletions src/app/ui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,61 @@ m.route.prefix = "";

m.route(document.body, "/", {
"/": {
onmatch: function () {
onmatch: () => {
if (CookieStore.isLoggedIn()) return Index;
else m.route.set("/login");
},
},
"/notepad": {
onmatch: function () {
onmatch: () => {
if (CookieStore.isLoggedIn()) return Notepad;
else m.route.set("/login");
},
},
"/login": {
onmatch: function () {
onmatch: () => {
if (CookieStore.isLoggedIn()) m.route.set("/");
else return Login;
},
},
"/register": {
onmatch: function () {
onmatch: () => {
if (CookieStore.isLoggedIn()) m.route.set("/");
else return Register;
},
},
"/about": {
render: function () {
render: () => {
return m(LayoutMain, m(AboutPage));
},
},
"/:404...": {
view: function () {
view: () => {
return m(LayoutMain, m(ErrorPage));
},
},
});

var Index = {
view: function () {
view: () => {
return m(LayoutMain, m(HomePage));
},
};

var Notepad = {
view: function () {
view: () => {
return m(LayoutMain, m(NotepadPage));
},
};

var Login = {
view: function () {
view: () => {
return m(LayoutMain, m(LoginPage));
},
};

var Register = {
view: function () {
view: () => {
return m(LayoutMain, m(RegisterPage));
},
};
2 changes: 1 addition & 1 deletion src/app/ui/src/layout/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Flash from "@/component/flash";

var View = () => {
return {
view: function (vnode) {
view: (vnode) => {
return m("main.layout", [
m(Menu),
m("section", vnode.children),
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/app/ui/src/store/notestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var NoteStore = {
NoteStore.delete(id)
.then(() => {
Flash.success("Note deleted.");
NoteStore.list = NoteStore.list.filter(function (i) {
NoteStore.list = NoteStore.list.filter((i) => {
return i.id !== id;
});
})
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/src/store/userregister.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var UserRegister = {
body: UserRegister.user,
});
},
submit: function (e) {
submit: (e) => {
Submit.start(e);

UserRegister.register()
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/src/view/login.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { withKnobs, select, text } from "@storybook/addon-knobs";
import { withA11y } from "@storybook/addon-a11y";
import LoginPage from "@/view/login";
import Flash from "@/component/flash";
import MockRequest from "@/component/mockrequest";
import MockRequest from "@/module/mockrequest";
import "~/style/main.scss";

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/src/view/notepad.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { withKnobs } from "@storybook/addon-knobs";
import { withA11y } from "@storybook/addon-a11y";
import NotepadPage from "@/view/notepad";
import Flash from "@/component/flash";
import MockRequest from "@/component/mockrequest";
import MockRequest from "@/module/mockrequest";
import "~/node_modules/@fortawesome/fontawesome-free/js/all.js";
import "~/style/main.scss";

Expand Down
2 changes: 1 addition & 1 deletion src/app/ui/src/view/register.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { withKnobs, select, text } from "@storybook/addon-knobs";
import { withA11y } from "@storybook/addon-a11y";
import RegisterPage from "@/view/register";
import Flash from "@/component/flash";
import MockRequest from "@/component/mockrequest";
import MockRequest from "@/module/mockrequest";
import "~/style/main.scss";

export default {
Expand Down

0 comments on commit be5dd8c

Please sign in to comment.