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
| .mtk13 { | |
| color: #9cdcfe; | |
| text-shadow: 0 0 2px #100c0f, 0 0 5px #ffdda926, 0 0 10px #fff3; | |
| } | |
| .mtk12 { | |
| color: #ffdda9; | |
| text-shadow: 0 0 2px #100c0f, 0 0 5px #ffdda926, 0 0 10px #fff3; | |
| } |
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 { | |
| state: { firstName: '', lastName: '' } | |
| changeAuthData(name, value) { | |
| this.setState({ | |
| ...this.state, | |
| [name]: value | |
| }) | |
| } | |
| } |
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
| // login component | |
| import { connect } from 'react-stonex | |
| const Login = ({ firstName, lastName, changeAuthData }) => ( | |
| <div> | |
| <input value={firstName} onChange={e => this.changeAuthData('firstName', e.target.value)} /> | |
| <input value={lastName} onChange={e => this.changeAuthData('lastName', e.target.value)} /> | |
| </div> | |
| ) |
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
| class Login extends React.Component { | |
| changeForm = ({ target }) => { | |
| this.setState({ [target.name]: target.value }) | |
| } | |
| render() { | |
| const { firstName, lastName } = this.state | |
| return ( |
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
| // ./modules/index.js | |
| // don't worry about context. It links when module attaching to the store! | |
| // Also all methods (like 'this.setState' ) from StonexModule class automatic will been inherited | |
| const pureModule = { | |
| state: {}, | |
| addItem(item){ | |
| this.setState({...this.state, [item.name]: item }) | |
| } | |
| } |
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 { StonexModule } from 'stonex' | |
| class UsersModule extends StonexModule { | |
| state = [] | |
| addUser = user => this.setState([...this.state, user]) | |
| removeAllUsers = () => this.resetState() | |
| } | |
| export default UsersModule |
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
| // ./modules/index.js | |
| import UsersModule from './UsersModule' | |
| import AuthModule from './AuthModule' | |
| import ModalsModule from './ModalsModule' | |
| const modules = { | |
| users: UsersModule, | |
| auth: AuthModule, | |
| modals: ModalsModule | |
| } |
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
| // store.js | |
| import { StonexStore } from 'stonex' | |
| import modules from './modules' | |
| import Logger from './modifiers/Logger' | |
| import AppStateWorker from './common/AppStateWorker' | |
| const storeConfiguration = { | |
| modifiers: [ // middlewares |
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
| // store.js | |
| import { StonexStore } from 'stonex' | |
| import modules from './modules' | |
| const store = new StonexStore(modules) |
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
| /** | |
| * @name unixTimeToDate | |
| * | |
| * @param {number} unixTimeStamp | |
| * @param {boolean} fromNow = add current time to unix timestamp | |
| * | |
| * @returns {Date} JavaScript Date type | |
| */ | |
| export const unixTimeToDate = (unixTimeStamp, fromNow = false) => |