Skip to content

Commit

Permalink
feat(hooks): Add useIntro hook
Browse files Browse the repository at this point in the history
feat: Add guide demo
  • Loading branch information
kailong502431556 committed Jan 25, 2022
1 parent cb558f8 commit 0832194
Show file tree
Hide file tree
Showing 15 changed files with 235 additions and 50 deletions.
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -33,6 +33,7 @@
"echarts": "^5.2.2",
"echarts-wordcloud": "^2.0.0",
"element-plus": "1.3.0-beta.7",
"intro.js": "^4.3.0",
"lodash-es": "^4.17.21",
"mockjs": "^1.1.0",
"nprogress": "^0.2.0",
Expand All @@ -50,6 +51,7 @@
"@iconify/json": "^1.1.459",
"@intlify/vite-plugin-vue-i18n": "^3.2.1",
"@purge-icons/generated": "^0.7.0",
"@types/intro.js": "^3.0.2",
"@types/lodash-es": "^4.17.5",
"@types/node": "^17.0.10",
"@types/nprogress": "^0.2.0",
Expand Down
90 changes: 58 additions & 32 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/components/ContentWrap/index.ts
@@ -0,0 +1,3 @@
import ContentWrap from './src/ContentWrap.vue'

export { ContentWrap }
35 changes: 35 additions & 0 deletions src/components/ContentWrap/src/ContentWrap.vue
@@ -0,0 +1,35 @@
<script setup lang="ts">
import { ElCard, ElTooltip } from 'element-plus'
import { propTypes } from '@/utils/propTypes'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const prefixCls = getPrefixCls('content-wrap')
defineProps({
title: propTypes.string.def(''),
message: propTypes.string.def('')
})
</script>

<template>
<ElCard :class="prefixCls" shadow="never">
<template v-if="title" #header>
<div class="flex items-center">
{{ title }}
<ElTooltip v-if="message" effect="dark" placement="right">
<template #content>
<div class="max-w-200px">{{ message }}</div>
</template>
<Icon class="ml-5px" icon="bi:question-circle-fill" :size="14" />
</ElTooltip>
</div>
</template>
<div>
<slot></slot>
</div>
</ElCard>
</template>

<style lang="less" scoped></style>
1 change: 1 addition & 0 deletions src/components/Menu/src/Menu.vue
Expand Up @@ -70,6 +70,7 @@ export default defineComponent({
return () => (
<div
id={prefixCls}
class={[
`${prefixCls} ${prefixCls}__${unref(menuMode)}`,
'h-[100%] overflow-hidden z-100 flex-col bg-[var(--left-menu-bg-color)]',
Expand Down
3 changes: 2 additions & 1 deletion src/components/TabMenu/src/TabMenu.vue
Expand Up @@ -12,7 +12,7 @@ import { cloneDeep } from 'lodash-es'
import { filterMenusPath, initTabMap, tabPathMap } from './helper'
import { useDesign } from '@/hooks/web/useDesign'
const { getPrefixCls } = useDesign()
const { getPrefixCls, variables } = useDesign()
const prefixCls = getPrefixCls('tab-menu')
Expand Down Expand Up @@ -106,6 +106,7 @@ export default defineComponent({
return () => (
<div
id={`${variables.namespace}-menu`}
class={[
prefixCls,
'relative bg-[var(--left-menu-bg-color)] top-1px',
Expand Down
2 changes: 1 addition & 1 deletion src/components/TagsView/src/TagsView.vue
Expand Up @@ -148,7 +148,7 @@ watch(
</script>

<template>
<div :class="prefixCls" class="h-[var(--tags-view-height)] flex w-full relative">
<div :id="prefixCls" :class="prefixCls" class="h-[var(--tags-view-height)] flex w-full relative">
<span
:class="`${prefixCls}__tool`"
class="w-[var(--tags-view-height)] h-[var(--tags-view-height)] text-center leading-[var(--tags-view-height)] cursor-pointer"
Expand Down
41 changes: 41 additions & 0 deletions src/hooks/web/useIntro.ts
@@ -0,0 +1,41 @@
import introJs from 'intro.js'
import { IntroJs, Step, Options } from 'intro.js'
import 'intro.js/introjs.css'
import { useI18n } from '@/hooks/web/useI18n'
import { useDesign } from '@/hooks/web/useDesign'

export const useIntro = (setps?: Step[], options?: Options) => {
const { t } = useI18n()

const { variables } = useDesign()

const defaultSetps: Step[] = setps || [
{
element: `#${variables.namespace}-menu`,
title: t('common.menu'),
intro: t('common.menuDes'),
position: 'right'
},
{
element: `#${variables.namespace}-tags-view`,
title: t('common.tagsView'),
intro: t('common.tagsViewDes'),
position: 'bottom'
}
]

const defaultOptions: Options = options || {
prevLabel: t('common.prevLabel'),
nextLabel: t('common.nextLabel'),
skipLabel: t('common.skipLabel'),
doneLabel: t('common.doneLabel')
}

const introRef: IntroJs = introJs()

introRef.addSteps(defaultSetps).setOptions(defaultOptions)

return {
introRef
}
}

0 comments on commit 0832194

Please sign in to comment.