Skip to content

Commit

Permalink
🔨 Add fade-in after words are loaded (#34)
Browse files Browse the repository at this point in the history
* Add fade transition

* Add wordsLoaded state & trigger load from parent
  • Loading branch information
stormwarning authored Jun 15, 2019
1 parent 18ab42e commit 33ed254
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
9 changes: 9 additions & 0 deletions assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ body {
.hover-gibson:focus {
color: var(--blue);
}

.fade-enter-active,
.fade-leave-active {
transition: opacity 500ms ease-in-out;
}
.fade-enter,
.fade-leave-to {
opacity: 0;
}
8 changes: 1 addition & 7 deletions components/Ipsum.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</template>

<script>
import { mapGetters, mapActions } from 'vuex'
import { mapGetters } from 'vuex'
import Word from '~/components/Word'
Expand Down Expand Up @@ -50,13 +50,7 @@ export default {
},
},
mounted() {
this.fetchWords()
},
methods: {
...mapActions(['fetchWords']),
buildParagraph(pLength) {
let numSentences = Math.max(
2,
Expand Down
27 changes: 25 additions & 2 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,24 @@
Gibson Ipsum
</h1>
<intro></intro>
<!--<span class="dib mr4 mr5-ns">By @stormwarning</span>-->
</div>
<controls></controls>
</header>
<ipsum></ipsum>
<transition name="fade" mode="out-in">
<ipsum v-if="wordsLoaded"></ipsum>
<main v-else class="h-100 ph2 pb6 ml5 ph0-ns pv6-ns ml0-ns code">
<p class="f6 measure-wide mt4 mt0-ns center"
>The sky above the port was the color of television, tuned
to a dead channel...</p
>
</main>
</transition>
</article>
</template>

<script>
import { mapActions, mapGetters } from 'vuex'
import Ipsum from '~/components/Ipsum'
import Intro from '~/components/Intro'
import Controls from '~/components/Controls'
Expand All @@ -33,5 +42,19 @@ export default {
Intro,
Controls,
},
computed: {
...mapGetters({
wordsLoaded: 'getWordsLoaded',
}),
},
mounted() {
this.fetchWords()
},
methods: {
...mapActions(['fetchWords']),
},
}
</script>
6 changes: 6 additions & 0 deletions store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ export const state = () => ({
l33t: false,
nihongo: false,
words: [],
wordsLoaded: false,
randomAdjective: 'cyberpunk',
})

export const getters = {
getParagraphs: (state) => state.paragraphs,
getSentences: (state) => state.sentences,
getWordList: (state) => state.words,
getWordsLoaded: (state) => state.wordsLoaded,
getAdjective: (state) => state.randomAdjective,
getNihongo: (state) => state.nihongo,
}
Expand All @@ -48,6 +50,9 @@ export const mutations = {
setWordList(state, wordData) {
state.words = wordData
},
setWordsLoaded(state, boolean) {
state.wordsLoaded = boolean
},
setAdjective(state, adjective) {
state.randomAdjective = adjective
},
Expand All @@ -63,6 +68,7 @@ export const actions = {

getAllWords(dataURL, (wordlist) => {
commit('setWordList', wordlist)
commit('setWordsLoaded', true)

let filteredWords = wordlist.filter((word) => {
return (
Expand Down

1 comment on commit 33ed254

@vercel
Copy link

@vercel vercel bot commented on 33ed254 Jun 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully aliased the URL https://gibsonipsum-qdzgircwkh.now.sh to the following alias.

Please sign in to comment.