Skip to content

Commit

Permalink
Add games menu carousel indicators
Browse files Browse the repository at this point in the history
  • Loading branch information
veloce committed Jun 10, 2018
1 parent b3becd4 commit c85d2e6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/styl/games-menu.styl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#games_menu
background rgba(21,26,30,0.8)
display flex
flex-flow column nowrap
aligns-items center
justify-content center

#wrapper_games
width 100%
Expand All @@ -20,6 +24,19 @@
flex-flow row nowrap
overflow-x auto

.carouselIndicators
display flex
flex-flow row nowrap
margin-bottom 1em
.indicator
width 10px
height 10px
border 1px solid #fff
border-radius 50%
margin-right 5px
&.current
background #fff

.card
background #2a2a2a
border-radius 5px
Expand Down
19 changes: 19 additions & 0 deletions src/ui/gamesMenu.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as h from 'mithril/hyperscript'
import * as range from 'lodash/range'
import * as Siema from 'siema'
import * as utils from '../utils'
import redraw from '../utils/redraw'
import { positionsCache } from '../utils/gamePosition'
import { getOfflineGames } from '../utils/offlineGames'
import { playerName as liPlayerName } from '../lichess/player'
Expand Down Expand Up @@ -47,6 +49,7 @@ export default {
onbeforeremove: menuOnBeforeRemove
}, [
h('div.wrapper_overlay_close', { oncreate: menuOnOverlayTap }),
renderCarouselIndicators(),
h('div#wrapper_games', renderAllGames()),
])
}
Expand All @@ -70,7 +73,9 @@ function wrapperOnCreate({ dom }: Mithril.DOMNode) {
perPage: helper.isWideScreen() ? 2 : 1,
startIndex: 0,
draggable: true,
onChange: () => redraw(),
})
redraw()
}
}

Expand Down Expand Up @@ -226,6 +231,20 @@ function renderIncomingChallenge(c: Challenge) {
])
}

function renderCarouselIndicators() {
if (helper.isPortrait() && scroller) {
return h('div.carouselIndicators',
range(0, scroller.innerElements.length).map(i =>
h('i.indicator', {
className: i === scroller.currentSlide ? 'current' : ''
})
)
)
}

return null
}

function renderAllGames() {
const nowPlaying = session.nowPlaying()
const challenges = challengesApi.incoming()
Expand Down

0 comments on commit c85d2e6

Please sign in to comment.