如何實現前端新手引導功能?

大家好,我是若川。我持續組織了近一年的源碼共讀活動,感興趣的可以?點此掃碼加我微信?lxchuan12?參與,每周大家一起學習200行左右的源碼,共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》?包含20余篇源碼文章。歷史面試系列。另外:目前建有江西|湖南|湖北籍前端群,可加我微信進群。

以下內容來自公眾號:前端充電寶,作者:?CUGGZ。

在產品發布新版本或者有新功能上線時,經常需要新手引導功能來引導用戶了解應用。下面就來分享幾個開箱即用的新手引導組件庫,幫你快速實現新手引導功能!

Intro.js

Intro.js 是一個使用廣泛的產品引導庫,它在 Github 上擁有 21.6k Star。其具有以下特點:

  • 無依賴:它不需要任何其他依賴。

  • 小而快:庫文件較小使得引導過程流暢直觀。JavaScript 文件的整體大小為 10KB,CSS 為 2.5KB。

  • 用戶友好:提供可以根據喜好選擇的各種主題。

  • 瀏覽器兼容性:適用于所有主流瀏覽器,如 Google Chrome、Mozilla Firefox、Opera、Safari 等 。

  • 文檔完善:文檔包含要介紹的每個元素的樣本和示例。

f10110bdbea9b2d8ef526d01af9a90a2.gif

可以通過以下命令來安裝 Intro.js:

npm?install?intro.js?-?save

安裝完成后,只需三個簡單的步驟即可將其添加到項目中:

  1. 將 JavaScript 和 CSS 文件(intro.js 和 introjs.css)添加到項目中。

  2. 將 data-intro 和 data-step 屬性添加到相關的 HTML 元素。這將為特定元素啟用 intro.js。

  3. 調用以下 JavaScript 函數:

introJs().start();

可以使用以下附加參數在特定元素或類上調用 Intro.js:

introJs(".introduction-farm").start();

Github:https://github.com/usablica/intro.js

shepherd

Shepherd 在 Github 上擁有 10.7k GitHub Star。它支持在多個前端框架中開箱即用,包括 React、Vue、Angular 等。其具有以下特點:

  • 輔助功能:提供鍵盤導航支持,遵循 a11y 規范,還可以使用 JavaScript 啟用 DOM 元素內的焦點捕獲。

  • 高度可定制:允許在不影響性能的情況下更改外觀。

  • 框架支持:隨時融入項目的前端框架。

  • 文檔完善:文檔涵蓋安裝和自定義,包括項目的主題和樣式。

c1fc90f893a4a9725a94750ae3ec4102.gif

可以使用以下命令來安裝 shepherd.js:

npm?install?shepherd.js?-save
npm?install?react-shepherd?--save
npm?install?vue-shepherd?--save
npm?install?angular-shepherd?--save

安裝完成之后,可以按如下方式來使用 shepherd(以 React 為例):

import?React,?{?Component,?useContext?}?from?'react'
import?{?ShepherdTour,?ShepherdTourContext?}?from?'react-shepherd'
import?newSteps?from?'./steps'const?tourOptions?=?{defaultStepOptions:?{cancelIcon:?{enabled:?true}},useModalOverlay:?true
};function?Button()?{const?tour?=?useContext(ShepherdTourContext);return?(<button?className="button?dark"?onClick={tour.start}>Start?Tour</button>);
}class?App?extends?Component?{render()?{return?(<div><ShepherdTour?steps={newSteps}?tourOptions={tourOptions}><Button?/></ShepherdTour></div>);}
}
  • shepherd:https://github.com/shipshapecode/shepherd

  • react-shepherd:https://github.com/shipshapecode/react-shepherd

  • vue-shepherd:https://github.com/shipshapecode/vue-shepherd

  • angular-shepherd:https://github.com/shipshapecode/angular-shepherd

React Joyride

React Joyride 在 GitHub 上擁有超過 5.1k Star,在 React 項目中開箱即用,用于向現有用戶介紹新功能。其具有以下特點:

  • 易于使用

  • 高度可定制

  • 文檔完善

  • 積極維護

8e7b9c52310b9ba62d033bfcfb13ba4b.gif

可以使用以下命令來安裝 react-joyride:

npm?i?react-joyride

可以通過以下方式來在 React 中使用 react-joyride:

import?Joyride?from?'react-joyride';export?class?App?extends?React.Component?{state?=?{steps:?[{target:?'.my-first-step',content:?'This?is?my?awesome?feature!',},{target:?'.my-other-step',content:?'This?another?awesome?feature!',},...]};render?()?{const?{?steps?}?=?this.state;return?(<div?className="app"><Joyridesteps={steps}.../>...</div>);}
}

Github:https://github.com/gilbarbara/react-joyride

Vue Tour

Vue Tour 是一個輕巧、簡單且可自定義的新手指引插件,可以與 Vue.js 一起使用。它提供了一種快速簡便的方法來指導用戶使用應用。它在 Github 上擁有 2.1 k Star。

644ce612631d2a9d3f0cea9e2707b1fa.gif

可以通過以下命令來安裝 Vue Tour:

npm?install?vue-tour

然后在應用入口導入插件(如果使用 vue-cli 搭建項目,通常是 main.js),并在 Vue 中注冊它。可以添加默認提供的樣式或根據自己的喜好自定義它們。

import?Vue?from?'vue'
import?App?from?'./App.vue'
import?VueTour?from?'vue-tour'require('vue-tour/dist/vue-tour.css')Vue.use(VueTour)new?Vue({render:?h?=>?h(App)
}).$mount('#app')

最后將 v-tour 組件放入模板中的任何位置(通常在 App.vue 中),并向其傳遞一系列步驟。每個步驟的 target 屬性可以將應用的任何組件中的 DOM 元素作為 target(只要在相關步驟彈出時它存在于 DOM 中)。

<template><div><div?id="v-step-0">A?DOM?element?on?your?page.?The?first?step?will?pop?on?this?element?because?its?ID?is?'v-step-0'.</div><div?class="v-step-1">A?DOM?element?on?your?page.?The?second?step?will?pop?on?this?element?because?its?ID?is?'v-step-1'.</div><div?data-v-step="2">A?DOM?element?on?your?page.?The?third?and?final?step?will?pop?on?this?element?because?its?ID?is?'v-step-2'.</div><v-tour?name="myTour"?:steps="steps"></v-tour></div>
</template><script>export?default?{name:?'my-tour',data?()?{return?{steps:?[{target:?'#v-step-0',??//?We're?using?document.querySelector()?under?the?hoodheader:?{title:?'Get?Started',},content:?`Discover?<strong>Vue?Tour</strong>!`},{target:?'.v-step-1',content:?'An?awesome?plugin?made?with?Vue.js!'},{target:?'[data-v-step="2"]',content:?'Try?it,?you\'ll?love?it!<br>You?can?put?HTML?in?the?steps?and?completely?customize?the?DOM?to?suit?your?needs.',params:?{placement:?'top'?//?Any?valid?Popper.js?placement.?See?https://popper.js.org/popper-documentation.html#Popper.placements}}]}},mounted:?function?()?{this.$tours['myTour'].start()}}
</script>

Github:https://github.com/pulsardev/vue-tour

Reactour

Reactour 是一個用于創建 React 應用導覽的流行庫。在 GitHub 上擁有 3.2K Star,它提供了一種簡單的方式來引導用戶瀏覽網站和應用。

e8b625f242fc90a6c3333a7822bb666c.gif

可以通過以下命令來安裝 reactour:

npm?i?-S?@reactour/tour

安裝完成之后,在應用的根組件添加 TourProvider,傳遞元素的步驟以在瀏覽期間突出顯示:

import?{?TourProvider?}?from?'@reactour/tour'ReactDOM.render(<TourProvider?steps={steps}><App?/></TourProvider>,document.getElementById('root')
)const?steps?=?[{selector:?'.first-step',content:?'This?is?my?first?Step',},//?...
]

然后在應用樹中的某個地方,使用 useTour hook 來控制 Tour:

import?{?useTour?}?from?'@reactour/tour'function?App()?{const?{?setIsOpen?}?=?useTour()return?(<><p?className="first-step">Lorem?ipsum?dolor?sit?amet,?consectetur?adipiscing?elit.?Praesent?atfinibus?nulla,?quis?varius?justo.?Vestibulum?lorem?lorem,?viverra?portametus?nec,?porta?luctus?orci</p><button?onClick={()?=>?setIsOpen(true)}>Open?Tour</button></>)
}

Github:https://github.com/elrumordelaluz/reactour

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/274457.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/274457.shtml
英文地址,請注明出處:http://en.pswp.cn/news/274457.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

hp-ux鎖定用戶密碼_UX設計101:提出正確的問題-規劃和促進用戶訪談

hp-ux鎖定用戶密碼這是什么&#xff1f; (What is this?) This session is part of a learning curriculum that I designed to incrementally skill up and empower a team of Designers and Researchers whose skillset and ways of working needed to evolve to keep up wi…

我與掘金合作出了源碼共讀第一期,首發超400人報名,快來參與~

大家好&#xff0c;我是若川。最近有不少新朋友關注我。對我不是很了解的&#xff0c;或許可以讀我的2021年度總結。誠邀各位新老讀者朋友參加源碼共讀活動。同時我和掘金合作&#xff0c;共同出了源碼共讀第一期&#xff0c;11月25日——12月25日&#xff0c;獎品豐厚。我是前…

ASP.NET repeater添加序號列的方法

ASP.NET repeater添加序號列的方法 1、<itemtemplate> <tr><td> <%# Container.ItemIndex 1%> </td></tr> </itemtemplate> 2、<itemtemplate> <tr><td> <%# this.rpResult.Items.Count 1%> </td>&…

mac基本操作技巧_6個基本設計技巧

mac基本操作技巧“In everything you do, refine your skills and knowledge about fundamental concepts and simple cases. Once is never enough. As you revisit fundamentals, you will find new insights. It may appear that returning to basics is a step backward an…

如何突破技術瓶頸(適合P6以下)

大家好&#xff0c;我是若川。我持續組織了近一年的源碼共讀活動&#xff0c;感興趣的可以 點此掃碼加我微信 lxchuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試…

stack smash_扶手椅VGUX:Super Smash Bros.Ultimate

stack smashEasily far the most exciting news out of Super Smash Bros. Ultimate’s announcement was that every single character would be returning to the game.asily迄今為止最令人興奮的消息了任天堂明星大亂斗最終宣布的是&#xff0c; 每一個字符會被返回到游戲中…

《Two Dozen Short Lessons in Haskell》學習(十)- Private Definitions — the where-clause

《Two Dozen Short Lessons in Haskell》&#xff08;Copyright © 1995, 1996, 1997 by Rex Page&#xff0c;有人翻譯為Haskell二十四學時教程&#xff0c;該書如果不用于贏利&#xff0c;可以任意發布&#xff0c;但需要保留他們的copyright&#xff09;這本書是學習 Ha…

我和掘金合作的源碼共讀小冊報名快1000人了~

眾所周知&#xff0c;我和掘金合作出了源碼共讀第一期。我是前端領讀員。現在報名快1000人了~獎品豐厚。也有一些小伙伴已經寫了好幾期筆記了~但相對1000人寫的還是太少。什么&#xff1f;你不知道&#xff1f;那也很正常&#xff0c;畢竟我的公眾號常讀人數比較少。大部分人都…

【短語學習】盈余量分析(earned value analysis)

作者&#xff1a;gnuhpc 出處&#xff1a;http://www.cnblogs.com/gnuhpc/ 各種形式的盈余量分析是衡量執行時最常用的方法。它把范圍、成本和進度等度量標準結合在一起以幫助項目管理小組評估項目執行。對每項活動而言&#xff0c;盈余量分析包括計算三個主要數值&#xff1a;…

配音劇本_網絡的各個階段:劇本如何傳達更好的UX

配音劇本讓我們將焦點放在使用劇本技巧提升顯微鏡上。 (Let’s put the spotlight on elevating microcopy with playwriting techniques.) “Anything you put in a play — any speech — has got to do one of two things: either define character or push the action of t…

極致編譯速度,一文搞定webpack5升級

大家好&#xff0c;我是若川。我持續組織了近一年的源碼共讀活動&#xff0c;感興趣的可以 點此掃碼加我微信 lxchuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試…

Java學習筆記(7)——輸入輸出

1、File 不同的操作系統對于檔案系統路徑的設定各有差別&#xff0c;例如在Windows中&#xff0c;一個路徑的表示法可能是&#xff1a; "c:\\Windows\\Fonts\\" 而在Linux下的路徑設定可能是&#xff1a; "/home/justin/" Windows的路徑指定是使用UNC&…

全庫模式 用戶模式 表模式_暗模式,亮模式和用戶的故事

全庫模式 用戶模式 表模式I have been working on designing a UI for an app that has individuals over the age of 60 as its main audience. At some point, I found my design more appealing in dark mode. As a UX designer, I know that my opinions and preferences d…

Rollup 與 Webpack 的 Tree-shaking

大家好&#xff0c;我是若川。我持續組織了近一年的源碼共讀活動&#xff0c;感興趣的可以 點此掃碼加我微信 lxchuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試…

聚類與分類的主要區別在于:_經驗在于細節:分析流服務的用戶體驗

聚類與分類的主要區別在于&#xff1a;看不見的差異 (The Invisible Difference) When app markets mature the overlap in features and designs grows closer as they catch up and copy each other. The more similar the apps are to one another, the more important the …

asp.net 動態創建TextBox控件 如何加載狀態信息

接著上文Asp.net TextBox的TextChanged事件你真的清楚嗎&#xff1f; 這里我們來說說狀態數據時如何加載的。雖然在Control中有調用狀態轉存的方法&#xff0c;但是這里有一個判斷條件 if (_controlState > ControlState.ViewStateLoaded) 一般的get請求這里的條件是不滿足…

從零實現一個迷你 Webpack

大家好&#xff0c;我是若川。我持續組織了近一年的源碼共讀活動&#xff0c;感興趣的可以 點此掃碼加我微信 lxchuan12 參與&#xff0c;每周大家一起學習200行左右的源碼&#xff0c;共同進步。同時極力推薦訂閱我寫的《學習源碼整體架構系列》 包含20余篇源碼文章。歷史面試…

ios 刷新遮罩遮罩_在Adobe XD中進行遮罩的3種方法

ios 刷新遮罩遮罩Are you new to Adobe XD? Or maybe you’re just stuck on how to create a simple mask? Here are 3 quick tips for how to mask your photos and designs in Adobe XD.您是Adobe XD的新手嗎&#xff1f; 或者&#xff0c;也許您只是停留在如何創建簡單的…

C#除法運算

C#中進行算術運算容易牽扯到類型的自動轉換&#xff0c;這種自動轉換稱之為隱式轉換&#xff0c;當然還可以人為的強制轉換 隱式轉換要求&#xff1a;不丟失精度&#xff0c;而且轉換前后都為數值 強制轉換&#xff1a;容易丟失可能會丟失精度 1 namespace 除法運算2 {3 cl…

Vite 4.0 正式發布!

源碼共讀我新出了&#xff1a;第40期 | vite 是如何解析用戶配置的 .env 的鏈接&#xff1a;https://www.yuque.com/ruochuan12/notice/p40也可以點擊文末閱讀原文查看&#xff0c;歡迎學習記筆記~12 月 9 日&#xff0c;Vite 4.0 正式發布。下面就來看看 Vite 4.0 有哪些更新吧…