Stackedit/src/components/Tour.vue

255 lines
6.7 KiB
Vue
Raw Normal View History

2018-01-21 00:11:05 +00:00
<template>
2018-09-20 10:52:57 +00:00
<div class="tour" @keydown.esc.stop="skip">
2018-01-21 00:11:05 +00:00
<div class="tour-step" :class="'tour-step--' + step" :style="stepStyle">
<div class="tour-step__inner" v-if="step === 'welcome'">
2022-05-26 23:55:37 +00:00
<h2>欢迎回来</h2>
2022-05-27 00:54:38 +00:00
<p>新的<b>StackEdit中文版</b>在这里</p>
2022-05-26 23:55:37 +00:00
<p>请单击<b>下一步</b>快速浏览</p>
2018-01-21 00:11:05 +00:00
<div class="tour-step__button-bar">
2022-05-26 23:55:37 +00:00
<button class="button" @click="finish">跳过</button>
<button class="button button--resolve" @click="next">下一步</button>
2018-01-21 00:11:05 +00:00
</div>
</div>
<div class="tour-step__inner" v-else-if="step === 'editor'">
2022-05-26 23:55:37 +00:00
<h2>您的Markdown编辑器</h2>
2022-08-07 02:48:53 +00:00
<p>StackEdit中文版实时将Markdown转换为HTML</p>
2022-06-01 23:45:13 +00:00
<p>点击 <icon-side-preview></icon-side-preview> </p>
2018-01-21 00:11:05 +00:00
<div class="tour-step__button-bar">
2022-05-26 23:55:37 +00:00
<button class="button" @click="finish">跳过</button>
<button class="button button--resolve" @click="next">下一步</button>
2018-01-21 00:11:05 +00:00
</div>
</div>
<div class="tour-step__inner" v-else-if="step === 'explorer'">
2022-05-26 23:55:37 +00:00
<h2>文件资源管理器</h2>
2022-08-07 02:48:53 +00:00
<p>StackEdit中文版可以管理文档空间中的多个文件和文件夹</p>
2022-05-26 23:55:37 +00:00
<p>点击 <icon-folder></icon-folder> </p>
2018-01-21 00:11:05 +00:00
<div class="tour-step__button-bar">
2022-05-26 23:55:37 +00:00
<button class="button" @click="finish">跳过</button>
<button class="button button--resolve" @click="next">下一步</button>
2018-01-21 00:11:05 +00:00
</div>
</div>
<div class="tour-step__inner" v-else-if="step === 'menu'">
2022-08-07 02:48:53 +00:00
<h2>切换侧边栏</h2>
<p>StackEdit中文版还可以同步和发布文件管理协作文档空间...</p>
2022-05-26 23:55:37 +00:00
<p>点击 <icon-provider provider-id="stackedit"></icon-provider> </p>
2018-01-21 00:11:05 +00:00
<div class="tour-step__button-bar">
2022-05-26 23:55:37 +00:00
<button class="button" @click="finish">跳过</button>
<button class="button button--resolve" @click="next">下一步</button>
2018-01-21 00:11:05 +00:00
</div>
</div>
2022-08-07 02:48:53 +00:00
<div class="tour-step__inner" v-else-if="step === 'theme'">
<h2>切换主题</h2>
<p>StackEdit中文版可以切换黑白主题</p>
<p>点击 <icon-switch-theme></icon-switch-theme> </p>
<div class="tour-step__button-bar">
<button class="button" @click="finish">跳过</button>
<button class="button button--resolve" @click="next">下一步</button>
</div>
</div>
2018-01-21 00:11:05 +00:00
<div class="tour-step__inner" v-else-if="step === 'end'">
<h2>Enjoy!</h2>
2022-08-07 02:48:53 +00:00
<p>如果您喜欢StackEdit中文版请在<a href="https://gitee.com/mafgwo/stackedit">Gitee仓库</a>上点一下Star谢谢</p>
2018-01-21 00:11:05 +00:00
<div class="tour-step__button-bar">
2022-05-26 23:55:37 +00:00
<button class="button button--resolve" @click="finish">确认</button>
2018-01-21 00:11:05 +00:00
</div>
</div>
</div>
</div>
</template>
<script>
import Vue from 'vue';
2018-09-19 08:59:22 +00:00
import store from '../store';
2018-01-21 00:11:05 +00:00
const steps = [
'welcome',
'editor',
'explorer',
'menu',
2022-08-07 02:48:53 +00:00
'theme',
2018-01-21 00:11:05 +00:00
'end',
];
export default {
data: () => ({
stepIdx: 0,
stepStyles: {},
}),
computed: {
step() {
return steps[this.stepIdx];
},
stepStyle() {
return this.stepStyles[this.step] || {};
},
},
methods: {
updatePositions() {
document.querySelectorAll('[tour-step-anchor]').cl_each((anchorElt) => {
const anchorRect = anchorElt.getBoundingClientRect();
const anchorSteps = (anchorElt.getAttribute('tour-step-anchor') || '').split(',');
anchorSteps.forEach((step) => {
const style = {
top: `${anchorRect.top + (anchorRect.height / 2)}px`,
left: `${anchorRect.left + (anchorRect.width / 2)}px`,
};
switch (step) {
case 'welcome':
case 'end': {
style.top = `${anchorRect.top}px`;
break;
}
case 'editor':
2022-08-07 02:48:53 +00:00
case 'menu':
case 'theme': {
2018-01-21 00:11:05 +00:00
style.left = `${anchorRect.left}px`;
break;
}
case 'explorer': {
style.left = `${anchorRect.left + anchorRect.width}px`;
break;
}
default:
return;
}
Vue.set(this.stepStyles, step, style);
});
});
},
finish() {
2018-09-19 08:59:22 +00:00
store.dispatch('data/patchLayoutSettings', {
2018-01-21 00:11:05 +00:00
welcomeTourFinished: true,
});
},
next() {
this.stepIdx += 1;
},
},
mounted() {
this.$watch(
2018-09-19 08:59:22 +00:00
() => store.getters['layout/styles'],
2018-01-21 00:11:05 +00:00
() => this.updatePositions(),
{ immediate: true },
);
},
};
</script>
<style lang="scss">
2018-05-06 00:46:33 +00:00
@import '../styles/variables.scss';
2018-01-21 00:11:05 +00:00
.tour {
position: absolute;
top: 0;
left: 0;
}
.tour-step {
position: absolute;
}
2018-09-20 10:52:57 +00:00
$tour-step-background: transparentize(mix(#f3f3f3, $selection-highlighting-color, 75%), 0.025);
2022-08-07 02:48:53 +00:00
$tour-step-darkbackground: transparentize(mix(#4d4d4d, $selection-highlighting-color, 75%), 0.025);
2018-07-17 19:58:40 +00:00
$tour-step-width: 240px;
2018-01-21 00:11:05 +00:00
.tour-step__inner {
position: absolute;
background-color: $tour-step-background;
2018-08-17 10:13:08 +00:00
padding: 1.5em;
2018-01-21 00:11:05 +00:00
font-size: 0.9em;
line-height: 1.33;
width: $tour-step-width;
text-align: center;
border-radius: $border-radius-base;
2022-08-07 02:48:53 +00:00
.app--dark & {
background-color: $tour-step-darkbackground;
}
2018-01-21 00:11:05 +00:00
h2 {
margin: 0;
&::after {
display: none;
}
}
.icon,
.icon-provider {
width: 1.25em;
height: 1.25em;
vertical-align: bottom;
display: inline-block;
}
&::before {
content: '';
position: absolute;
}
.tour-step--welcome &,
.tour-step--end & {
left: -$tour-step-width/2;
2018-02-07 21:25:29 +00:00
top: 36px;
2018-01-21 00:11:05 +00:00
border-bottom-right-radius: 0;
&::before {
bottom: -10px;
right: 0;
border-top: 10px solid $tour-step-background;
border-left: 10px solid transparent;
2022-08-07 02:48:53 +00:00
.app--dark & {
border-top: 10px solid $tour-step-darkbackground;
}
2018-01-21 00:11:05 +00:00
}
}
.tour-step--editor &,
2022-08-07 02:48:53 +00:00
.tour-step--menu &,
.tour-step--theme & {
2018-01-21 00:11:05 +00:00
right: 15px;
border-top-right-radius: 0;
&::before {
top: 0;
right: -10px;
border-top: 10px solid $tour-step-background;
border-right: 10px solid transparent;
2022-08-07 02:48:53 +00:00
.app--dark & {
border-top: 10px solid $tour-step-darkbackground;
}
2018-01-21 00:11:05 +00:00
}
}
.tour-step--explorer & {
left: 15px;
border-top-left-radius: 0;
&::before {
top: 0;
left: -10px;
border-top: 10px solid $tour-step-background;
border-left: 10px solid transparent;
2022-08-07 02:48:53 +00:00
.app--dark & {
border-top: 10px solid $tour-step-darkbackground;
}
2018-01-21 00:11:05 +00:00
}
}
}
.tour-step__button-bar {
2018-08-17 10:13:08 +00:00
margin-top: 1.5em;
display: flex;
flex-direction: row;
justify-content: flex-end;
2018-07-17 19:58:40 +00:00
.button {
font-size: 1.1em;
}
2018-01-21 00:11:05 +00:00
}
</style>