This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const checkboxOverides = { | |
".form-check-label": { | |
height: "full", | |
display: "flex", | |
alignItems: "center", | |
minHeight: 10 | |
}, | |
".form-check-label span": { | |
pl: 2 | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import TodosModel from "./TodosModel"; | |
import TodosView from "./TodosView"; | |
import TodosController from "./TodosController"; | |
import PubSub from "./PubSub"; | |
const pubSub = new PubSub(); | |
const model = new TodosModel(pubSub); | |
const view = new TodosView(document.getElementById("app"), pubSub); | |
new TodosController(model, view); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class PubSub { | |
constructor() { | |
this.registry = {}; | |
} | |
on(evtName, cb) { | |
this.registry[evtName] = this.registry[evtName] || []; | |
this.registry[evtName].push(cb); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class TodosController { | |
constructor(model, view) { | |
this.model = model; | |
this.view = view; | |
this.init(); | |
} | |
init() { | |
this.view.createView(); | |
this.setEventListeners(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class TodosView { | |
constructor(wrapper, pubSub) { | |
this.wrapper = wrapper; | |
this.pubSub = pubSub; | |
this.cashe = {}; | |
} | |
createView() { | |
this.wrapper.insertAdjacentHTML("afterbegin", this.renderUI()); | |
this.cashe.todosList = document.querySelector(".todos-list"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class TodosModel { | |
constructor(pubSub) { | |
this.todos = [ | |
{ title: "clean room", id: 1, done: false }, | |
{ title: "read book", id: 2, done: false }, | |
{ title: "learn classes", id: 3, done: false } | |
]; | |
this.pubSub = pubSub; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Store from "./store/index" | |
function App() { | |
const { state, setState } = Store.useStore() | |
const onInc = () => | |
setState(state => | |
state.count = state.count + 1 | |
) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useMemo, useContext, createContext } from "react" | |
import { useImmer } from "use-immer" | |
const initialState = { | |
count: 0 | |
} | |
function makeStore() { | |
const Context = createContext() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handleChange = (e) => { | |
const { name, value } = e.target | |
this.setState((prevState, props) => ({ | |
[name]: value, | |
})); | |
const lbm = this.state.kg -(this.state.kg * (this.state.fp / 100)) | |
const bmr = 370 + (21.6 * this.state.lbm) | |
this.setState((aprevState, props) => ({ | |
lbm, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for(project) do |f| %> | |
<% if project.errors.any? %> | |
<div id="error_explanation"> | |
<h2><%= pluralize(project.errors.count, "error") %> prohibited this project from being saved:</h2> | |
<ul> | |
<% project.errors.full_messages.each do |message| %> | |
<li><%= message %></li> | |
<% end %> | |
</ul> |