Skip to content
This repository has been archived by the owner on Apr 7, 2024. It is now read-only.

Commit

Permalink
TEST: attempting to fix onload issue
Browse files Browse the repository at this point in the history
  • Loading branch information
joeyklee committed Apr 26, 2019
1 parent 32af01a commit 019035d
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 41 deletions.
1 change: 0 additions & 1 deletion components/NavbarTop/components/MobileNavMenuModal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const html = require('choo/html');
const Modal = require('../../Modal');
const styles = require('../../../styles')
const AuthBtn = require('./AuthBtn')
const SearchInput = require('./SearchInput')
Expand Down
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ app.route('/lists/:_id', require('./views/Lists'))

app.route('/*', require('./views/404'))

if (typeof window !== 'undefined') {
document.body.appendChild(app.start())
app.mount('body')
}

module.exports = app.mount('body')
2 changes: 1 addition & 1 deletion stores/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ state.main = {
emitter.on('USERS_SET_SELECTED', (username) => {
let userid;
let query;

console.log('set - user selected!')
state.api.users.find({query:{username: username}})
.then(result => {
userid = result.data[0]._id;
Expand Down
13 changes: 8 additions & 5 deletions stores/userPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ function store(state, emitter) {
state.events.USERPAGE_SET_TAB = 'USERPAGE_SET_TAB';
state.events.USERPAGE_EDIT_PROFILE = 'USERPAGE_EDIT_PROFILE';

// IF NAVIGATED TO LIST PAGE, TRIGGER GET
emitter.on('navigate', ()=>{
if(state.route === 'users/:username'){
emitter.emit('USERS_SET_SELECTED', state.params.username)
}
emitter.on('DOMContentLoaded', () => {
// IF NAVIGATED TO LIST PAGE, TRIGGER GET
emitter.on('navigate', ()=>{
if(state.route === 'users/:username'){
emitter.emit('USERS_SET_SELECTED', state.params.username)
}
})
})



// Events
emitter.on('USERPAGE_SET_TAB', setTab)
Expand Down
44 changes: 18 additions & 26 deletions views/Users/components/UserPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,25 @@ var TITLE = `nautilists - user`

module.exports = view

function view (state, emit) {
function view(state, emit) {

if (state.title !== TITLE) emit(state.events.DOMTITLECHANGE, TITLE)

const {username} = state.params

return html`
<body class="${styles.body}" onload=${() => emit('USERS_SET_SELECTED', username)}>
${NavbarTop(state, emit)}
<main class="${styles.main} flex flex-column items-center pa2 pa0-ns">
${Header(state,emit)}
${UserTabSelect(state, emit)}
${MainView(state, emit)}
</main>
${Footer(state, emit)}
${MobileNavMenuModal(state, emit)}
${state.cache(AddFeatureBtn, 'AddFeatureBtn', state, emit).render()}
${AddLinkModal(state, emit)}
${AddListModal(state, emit)}
${EditProfileModal(state, emit)}
</body>
<body class="${styles.body}" onload=${() => emit('USERS_SET_SELECTED', state.params.username)}>
${NavbarTop(state, emit)}
<main class="${styles.main} flex flex-column items-center pa2">
${Header(state,emit)}
${UserTabSelect(state, emit)}
${MainView(state, emit)}
</main>
${Footer(state, emit)}
${MobileNavMenuModal(state, emit)}
${state.cache(AddFeatureBtn, 'AddFeatureBtn', state, emit).render()}
${AddLinkModal(state, emit)}
${AddListModal(state, emit)}
${EditProfileModal(state, emit)}
</body>
`
}

Expand All @@ -51,11 +49,11 @@ function Header(state, emit){
return html`
<header class="${styles.sectionmw7} h-auto ba bw1 dropshadow mt4 pa2">
<p class="pa0 ma0 w-100 tr">${EditProfileBtn(state, emit)}</p>
<div class="w-100 flex flex-column flex-row items-center">
<div class="w-100 flex flex-column flex-row items-center pa2">
<img class="ma0 pa0 dib h3 dropshadow ba bw1" src="/assets/${avatar}">
<h1 class="ma0 pa0 pl3 f3 f2-ns">${username}</h1>
</div>
<p>${bio}</p>
<p class="pa2">${bio}</p>
</header>
`
}
Expand All @@ -67,15 +65,12 @@ function MainView(state, emit){
switch(userPage.selectedTab){
case('lists'):
return ListTabView(state, emit)
break;
case('links'):
return LinkTabView(state, emit)
break;
case('listsFollowing'):
return ListFollowingTabView(state, emit)
break;
default:
break;
return ''

}
}
Expand All @@ -93,13 +88,10 @@ function UserTabSelect(state, emit){
switch(tabName){
case 'lists':
return 'bg-light-green navy'
break
case 'links':
return 'bg-light-pink navy'
break
case 'listsFollowing':
return 'bg-light-blue navy'
break
default:
return 'bg-pink navy'
}
Expand Down
8 changes: 0 additions & 8 deletions views/Users/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
var html = require('choo/html')
const styles = require('../../styles')
const NavbarTop = require('../../components/NavbarTop')
const MobileNavMenuModal = require('../../components/NavbarTop/components/MobileNavMenuModal')
const Footer = require('../../components/Footer')
const AddFeatureBtn = require('../../components/AddFeatureBtn')

const UsersPage = require('./components/UsersPage')
const UserPage = require('./components/UserPage')

Expand All @@ -18,10 +12,8 @@ function view (state, emit) {
switch(state.route){
case 'users':
return UsersPage(state, emit);
break;
case 'users/:username':
return UserPage(state, emit);
break;
default:
return html`<body>nothing found</body>`
}
Expand Down

0 comments on commit 019035d

Please sign in to comment.