Skip to content

Commit

Permalink
New tutorial component (#3346)
Browse files Browse the repository at this point in the history
* Component draft

* changelog

* Add steps

* First steps done

* Add step dots and read the full guide link text

* css tweaks

* css tweaks

* Cleanup

* Update snap

* Cleanup

* Basic testing

* Cleanup, testing

* Cleanup, props, testing

* Remove v-html

* Fix close

* istanbul ignore next

* Fix

* Show tutorial demo in experimentalMode

* Testing stuff
  • Loading branch information
mariopino authored and faboweb committed Dec 27, 2019
1 parent 0474a8d commit aa619ca
Show file tree
Hide file tree
Showing 8 changed files with 515 additions and 3 deletions.
1 change: 1 addition & 0 deletions changes/mario_3345-new-tutorial-component
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Added] [#3345](https://github.com/cosmos/lunie/issues/3345) New tutorial component @mariopino
Binary file added public/img/tutorials/bg1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
234 changes: 234 additions & 0 deletions src/components/common/ModalTutorial.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
<template>
<div v-focus-last class="modal-tutorial" tabindex="0" @keyup.esc="close()">
<main class="modal-tutorial-main">
<div class="modal-tutorial-header">
<a href="#" @click="prevLink">
<i class="material-icons chevron_left"></i>
</a>
<a href="#" @click="nextLink">
<i class="material-icons chevron_right"></i>
</a>
<a href="#" @click="close">
<i class="material-icons close"></i>
</a>
<div class="top-bg"></div>
</div>
<div class="content">
<div class="steps">
<span class="current-step">STEP {{ currentStep }}</span>
<div class="steps-container">
<span
v-for="(item, index) in steps.length"
:key="`step-${index}`"
:class="{ step: true, completed: index < currentStep }"
>
</span>
</div>
</div>
<template v-for="(step, index) in steps">
<template v-if="currentStep === index + 1">
<h1 :key="`title-${index}`">{{ step.title }}</h1>
<p :key="`content-${index}`">
<span
v-for="(item, contentIndex) in step.content"
:key="`content-item-${index}-${contentIndex}`"
class="content-item"
>
{{ item }}
</span>
</p>
<button
:key="`btn-${index}`"
class="button primary"
@click="nextLink"
>
{{
currentStep === steps.length
? `Read the full guide`
: `Next step`
}}
<i class="material-icons arrow_forward"></i>
</button>
</template>
</template>
</div>
</main>
</div>
</template>

<script>
export default {
name: `modal-tutorial`,
props: {
close: {
type: Function,
required: true
},
fullguide: {
type: String,
required: true
},
steps: {
type: Array,
required: true
}
},
data: function() {
return {
currentStep: 1
}
},
methods: {
nextLink() {
if (this.currentStep === this.steps.length) {
window.open(this.fullguide, "_blank")
} else {
this.currentStep++
}
},
prevLink() {
if (this.currentStep > 1) {
this.currentStep--
}
}
}
}
</script>

<style scoped>
.modal-tutorial {
position: fixed;
bottom: 0;
right: 1rem;
z-index: var(--z-modal);
width: 24rem;
height: 38rem;
display: flex;
outline: none;
}
.modal-tutorial-main {
display: flex;
flex-flow: column;
padding: 0 0 1.5rem 0;
}
.modal-tutorial h1 {
font-size: 1.6rem;
color: #000f50;
margin-bottom: 2rem;
font-weight: 400;
}
.modal-tutorial b {
font-weight: 500;
color: var(--bright);
}
.modal-tutorial .button {
width: 100%;
margin-top: 1rem;
}
.modal-tutorial-header i {
color: #7a88b8;
background: #e4e7f1;
width: 2rem;
height: 2rem;
font-size: var(--m);
display: inline-block;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
padding: 0.5rem;
margin-right: 1rem;
border-radius: 50%;
}
.modal-tutorial-header i.close {
position: absolute;
top: 0;
right: 0;
margin: 0;
}
.modal-tutorial .top-bg {
margin-top: 1rem;
background-image: url("/img/tutorials/bg1.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
width: 100%;
height: 186px;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
}
.modal-tutorial .content {
padding: 2rem;
background-color: white;
color: #445381;
}
.button {
font-family: var(--sans);
font-size: 1.1rem;
font-weight: 500;
padding: 1.2rem;
min-width: 100px;
color: #445381;
margin: 0;
border-radius: 0.4rem;
cursor: pointer;
background: #f1f3f7;
border: 2px solid #f1f3f7;
transition: all 0.5s ease;
white-space: nowrap;
outline: none;
text-align: left;
position: relative;
}
.button:hover {
background: #445381;
color: #f1f3f7;
border-color: #445381;
}
.button i.arrow_forward {
position: absolute;
top: 1rem;
right: 1rem;
margin: 0;
}
.modal-tutorial .steps-container {
position: absolute;
top: 0;
right: 0;
}
.modal-tutorial .steps .step {
height: 0.5rem;
width: 0.5rem;
border-radius: 50%;
margin-left: 2rem;
background-color: #f1f3f7;
display: inline-block;
}
.modal-tutorial .steps .step.completed {
background-color: #458dff;
}
.steps {
position: relative;
color: #458dff;
font-weight: 500;
margin-bottom: 1.5rem;
}
.content-item {
display: block;
}
</style>
59 changes: 58 additions & 1 deletion src/components/wallet/PagePortfolio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,78 @@
<template slot="managed-body">
<DelegationsOverview />
<Undelegations />
<ModalTutorial
v-if="showTutorial && session.experimentalMode"
:steps="steps"
fullguide="https://lunie.io"
:close="closeTutorial"
/>
</template>
</TmPage>
</template>

<script>
import { mapState } from "vuex"
import TmPage from "common/TmPage"
import DelegationsOverview from "staking/DelegationsOverview"
import Undelegations from "staking/Undelegations"
import ModalTutorial from "common/ModalTutorial"
export default {
name: `page-portfolio`,
components: {
TmPage,
Undelegations,
DelegationsOverview
DelegationsOverview,
ModalTutorial
},
data: () => ({
showTutorial: true,
// Tutorial steps
steps: [
{
title: "How to get tokens?",
// Each content array element will be enclosed in a span (newline)
content: [
"Praesent vitae tristique erat.",
"Integer ullamcorper ligula vel dolor sagittis nec fermentum risus pharetra.",
"Nulla mollis tempus sem, a sollicitudin est facilisis ac."
]
},
{
title: "How to get tokens?",
content: [
"Praesent vitae tristique erat.",
"Integer ullamcorper ligula vel dolor sagittis nec fermentum risus pharetra.",
"Nulla mollis tempus sem, a sollicitudin est facilisis ac."
]
},
{
title: "How to get tokens?",
content: [
"Praesent vitae tristique erat.",
"Integer ullamcorper ligula vel dolor sagittis nec fermentum risus pharetra.",
"Nulla mollis tempus sem, a sollicitudin est facilisis ac."
]
},
{
title: "How to get tokens?",
content: [
"Praesent vitae tristique erat.",
"Integer ullamcorper ligula vel dolor sagittis nec fermentum risus pharetra.",
"Nulla mollis tempus sem, a sollicitudin est facilisis ac."
]
}
]
}),
computed: {
...mapState([`session`])
},
methods: {
closeTutorial() {
/* istanbul ignore next */
this.showTutorial = false
}
}
}
</script>
Loading

0 comments on commit aa619ca

Please sign in to comment.