|
1 | | -Got it! Let’s create a **detailed GitHub README** for your library, now named **`lcwTourGuide`**. I’ll include title, description, features, installation, usage, options, styling, and contributing instructions. |
| 1 | +# lcwTourGuide |
2 | 2 |
|
3 | | -````markdown |
4 | | -# 🧭 lcwTourGuide |
| 3 | +**lcwTourGuide** is a lightweight JavaScript library for creating guided tours on web pages. Easily highlight elements, add tooltips, and guide users through your UI with callbacks for start, step change, and end events. |
5 | 4 |
|
6 | | -`lcwTourGuide` is a lightweight, dependency-free JavaScript library for creating guided tours and onboarding experiences on your website. |
7 | | -It highlights elements, shows tooltips, automatically positions them, and provides callback hooks for easy customization. |
| 5 | +## Features |
8 | 6 |
|
9 | | ---- |
10 | | - |
11 | | -## ✨ Features |
12 | | -- 🚀 Pure JavaScript, no dependencies |
13 | | -- 🎯 Highlights target elements with an overlay |
14 | | -- 📜 Scrolls automatically to show the highlighted element and tooltip |
15 | | -- 🧩 Smart tooltip positioning (auto-adjusts above/below based on space) |
16 | | -- 🔄 Step navigation (`Next`, `Previous`, `Done`) |
17 | | -- ⚡ Callback hooks for `onStart`, `onStep`, `onEnd` |
18 | | -- 🎨 Fully customizable with CSS |
| 7 | +- Highlight elements on your page. |
| 8 | +- Display tooltips with custom text. |
| 9 | +- Navigate steps with "Next" and "Previous". |
| 10 | +- Callbacks for `onStart`, `onStep`, and `onEnd`. |
| 11 | +- Easy to integrate via CDN or npm. |
19 | 12 |
|
20 | | ---- |
| 13 | +## Installation |
21 | 14 |
|
22 | | -## 📦 Installation |
23 | | - |
24 | | -Include the script and styles in your project: |
| 15 | +### Via CDN |
25 | 16 |
|
26 | 17 | ```html |
27 | | -<link rel="stylesheet" href="lcwTourGuide.css"> |
28 | | -<script src="lcwTourGuide.js"></script> |
29 | | -```` |
| 18 | +<link rel="stylesheet" href="https://yourusername.github.io/lcwTourGuide/src/lcwTourGuide.css"> |
| 19 | +<script src="https://yourusername.github.io/lcwTourGuide/dist/lcwTourGuide.min.js"></script> |
30 | 20 |
|
31 | | -Or copy the class code directly into your project. |
32 | 21 |
|
33 | | ---- |
34 | 22 |
|
35 | 23 | ## 🚀 Usage |
36 | 24 |
|
37 | 25 | ### 1. Mark elements for the tour |
38 | 26 |
|
39 | | -Add `data-tour-step` and `data-tour-text` attributes to elements: |
| 27 | +Add `data-lcw-tour-step` and `data-lcw-tour-text` attributes to elements: |
40 | 28 |
|
41 | | -```html |
42 | | -<button data-tour-step="1" data-tour-text="Click here to create a new item"> |
| 29 | +``` |
| 30 | +<button data-lcw-tour-step="1" data-lcw-tour-text="Click here to create a new item"> |
43 | 31 | New Item |
44 | 32 | </button> |
45 | 33 |
|
46 | | -<input type="text" data-tour-step="2" data-tour-text="Enter the name here"> |
| 34 | +<input type="text" data-lcw-tour-step="2" data-lcw-tour-text="Enter the name here"> |
47 | 35 |
|
48 | | -<div data-tour-step="3" data-tour-text="Finally, click Save"> |
| 36 | +<div data-lcw-tour-step="3" data-lcw-tour-text="Finally, click Save"> |
49 | 37 | Save |
50 | 38 | </div> |
51 | 39 | ``` |
52 | 40 |
|
53 | | -* `data-tour-step="1"` → defines the order |
54 | | -* `data-tour-text="..."` → tooltip text |
| 41 | +* `data-lcw-tour-step="1"` → defines the order |
| 42 | +* `data-lcw-tour-text="..."` → tooltip text |
55 | 43 |
|
56 | | ---- |
57 | 44 |
|
58 | 45 | ### 2. Initialize the tour |
59 | 46 |
|
60 | | -```js |
| 47 | +``` |
61 | 48 | document.addEventListener('DOMContentLoaded', () => { |
62 | 49 | const tour = new lcwTourGuide({ |
63 | 50 | onStart: () => console.log("✅ Tour started"), |
@@ -85,29 +72,66 @@ document.addEventListener('DOMContentLoaded', () => { |
85 | 72 |
|
86 | 73 | Default styles can be customized: |
87 | 74 |
|
88 | | -```css |
89 | | -.tour-tooltip { |
90 | | - background: #222; |
91 | | - color: #fff; |
92 | | - border-radius: 8px; |
93 | | - padding: 15px; |
94 | | - max-width: 250px; |
| 75 | +``` |
| 76 | +.lcw-tour-tooltip { |
| 77 | + position: absolute; |
| 78 | + background: #ffffff; |
| 79 | + color: #444; |
| 80 | + padding: 16px; |
| 81 | + border-radius: 6px; |
| 82 | + max-width: 280px; |
| 83 | + z-index: 10001; |
| 84 | + font-size: 14px; |
| 85 | + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4); |
95 | 86 | } |
96 | | -.tour-highlight { |
97 | | - box-shadow: 0 0 0 3px #00bcd4; |
| 87 | + |
| 88 | +.lcw-tour-tooltip button { |
| 89 | + margin-top: 10px; |
| 90 | + margin-right: 5px; |
| 91 | + padding: 5px 10px; |
| 92 | + border: none; |
| 93 | + background: #007bff; |
| 94 | + color: white; |
| 95 | + border-radius: 4px; |
| 96 | + cursor: pointer; |
98 | 97 | } |
99 | | -.tour-overlay { |
100 | | - background: rgba(0, 0, 0, 0.5); |
| 98 | + |
| 99 | +.lcw-tour-tooltip button:hover { |
| 100 | + background: #0056b3; |
101 | 101 | } |
102 | | -``` |
103 | 102 |
|
104 | | ---- |
| 103 | +.lcw-tour-overlay { |
| 104 | + position: fixed; |
| 105 | + top: 0; |
| 106 | + left: 0; |
| 107 | + width: 100vw; |
| 108 | + height: 100vh; |
| 109 | + background: rgba(0, 0, 0, 0.6); |
| 110 | + z-index: 10000; |
| 111 | +} |
105 | 112 |
|
106 | | -## 🛠 Example |
| 113 | +.lcw-tour-highlight { |
| 114 | + position: relative; |
| 115 | + z-index: 10002; |
| 116 | + box-shadow: 0 0 0 4px rgba(0, 123, 255, 0.7); |
| 117 | + border-radius: 4px; |
| 118 | + background-color: white; |
| 119 | +} |
107 | 120 |
|
108 | | - |
| 121 | +.lcw-tour-close { |
| 122 | + position: absolute; |
| 123 | + top: 8px; |
| 124 | + right: 10px; |
| 125 | + color: white; |
| 126 | + font-size: 18px; |
| 127 | + cursor: pointer; |
| 128 | + font-weight: bold; |
| 129 | +} |
109 | 130 |
|
110 | | ---- |
| 131 | +.lcw-tour-close:hover { |
| 132 | + color: #ff6b6b; |
| 133 | +} |
| 134 | +``` |
111 | 135 |
|
112 | 136 | ## 📜 License |
113 | 137 |
|
|
0 commit comments