kamrify commited on
Commit
a56688a
·
1 Parent(s): a0908ed

Add migration guide

Browse files
docs/astro.config.mjs CHANGED
@@ -6,5 +6,12 @@ import mdx from "@astrojs/mdx";
6
 
7
  // https://astro.build/config
8
  export default defineConfig({
 
 
 
 
 
 
 
9
  integrations: [tailwind(), react(), mdx()]
10
  });
 
6
 
7
  // https://astro.build/config
8
  export default defineConfig({
9
+ markdown: {
10
+ shikiConfig: {
11
+ // theme: "material-theme"
12
+ theme: "monokai"
13
+ // theme: 'poimandres'
14
+ }
15
+ },
16
  integrations: [tailwind(), react(), mdx()]
17
  });
docs/package.json CHANGED
@@ -16,7 +16,7 @@
16
  "@types/react": "^18.2.14",
17
  "@types/react-dom": "^18.2.6",
18
  "astro": "^2.7.4",
19
- "driver.js": "1.0.3",
20
  "react": "^18.2.0",
21
  "react-dom": "^18.2.0",
22
  "react-fast-marquee": "^1.6.0",
 
16
  "@types/react": "^18.2.14",
17
  "@types/react-dom": "^18.2.6",
18
  "astro": "^2.7.4",
19
+ "driver.js": "1.0.4",
20
  "react": "^18.2.0",
21
  "react-dom": "^18.2.0",
22
  "react-fast-marquee": "^1.6.0",
docs/pnpm-lock.yaml CHANGED
@@ -24,8 +24,8 @@ dependencies:
24
  specifier: ^2.7.4
25
  version: 2.7.4
26
  driver.js:
27
- specifier: 1.0.3
28
- version: 1.0.3
29
  react:
30
  specifier: ^18.2.0
31
  version: 18.2.0
@@ -1370,8 +1370,8 @@ packages:
1370
1371
  resolution: {integrity: sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==}
1372
 
1373
1374
- resolution: {integrity: sha512-XL8K9fkI2O+r8vVumEZsOwEJSFBZzZH0Iq9VAvKUTto05FDetHGj0ORcYVPHgLsAw066h3wIx5dvU4T1dqZKEQ==}
1375
  dev: false
1376
 
1377
 
24
  specifier: ^2.7.4
25
  version: 2.7.4
26
  driver.js:
27
+ specifier: 1.0.4
28
+ version: 1.0.4
29
  react:
30
  specifier: ^18.2.0
31
  version: 18.2.0
 
1370
1371
  resolution: {integrity: sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==}
1372
 
1373
1374
+ resolution: {integrity: sha512-BYEDYSTsHOXRwXcwE75xFH1cK1sBikS0275QrdGWKc1oN99lGUeW/O3+rP24PJ+snycsnlpjOQ85t0QZ1R+zrA==}
1375
  dev: false
1376
 
1377
docs/src/content/guides/migrating-from-0x.mdx ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: "Migrate to 1.x"
3
+ groupTitle: "Introduction"
4
+ sort: 6
5
+ ---
6
+
7
+ Drivers 1.x is a major release that introduces a new API and a new architecture. This page will help you migrate your code from 0.x to 1.x.
8
+
9
+ > Change in how you import the library
10
+ ```diff
11
+ - import Driver from 'driver.js';
12
+ - import 'driver.js/dist/driver.min.css';
13
+ + import { driver } from 'driver.js';
14
+ + import "driver.js/dist/driver.css";
15
+ ```
16
+
17
+ > Change in how you initialize the library
18
+ ```diff
19
+ - const driverObj = new Driver(config);
20
+ - driverObj.setSteps(steps);
21
+
22
+ + // Steps can be passed in the constructor
23
+ + const driverObj = driver({
24
+ + ...config,
25
+ + steps
26
+ + });
27
+ ```
28
+
29
+ > Changes in configuration
30
+
31
+ ```diff
32
+ const config = {
33
+ - overlayClickNext: false, // Option has been removed
34
+ - closeBtnText: 'Close', // Option has been removed (close button is now an icon)
35
+ - scrollIntoViewOptions: {}, // Option has been renamed
36
+ - opacity: 0.75,
37
+ + overlayOpacity: 0.75,
38
+ - className: 'scoped-class',
39
+ + popoverClass: 'scoped-class',
40
+ - padding: 10,
41
+ + stagePadding: 10,
42
+ - showButtons: false,
43
+ + showButtons: ['next', 'prev', 'close'], // pass an array of buttons to show
44
+ - keyboardControl: true,
45
+ + allowKeyboardControl: true,
46
+ - onHighlightStarted: (Element) {},
47
+ + onHighlightStarted?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void;
48
+ - onHighlighted: (Element) {},
49
+ + onHighlighted?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void;
50
+ - onDeselected: (Element) {}, // Called when element has been deselected
51
+ + onDeselected?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void;
52
+
53
+ - onReset: (Element) {}, // Called when overlay is about to be cleared
54
+ + onDestroyStarted?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void;
55
+ + onDestroyed?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void;
56
+ + onCloseClick?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void;
57
+
58
+ - onNext: (Element) => {}, // Called when moving to next step on any step
59
+ - onPrevious: (Element) => {}, // Called when moving to next step on any step
60
+ + // By overriding the default onNextClick and onPrevClick, you control the flow of the driver
61
+ + // Visit for more details: https://driverjs.com/docs/configuration
62
+ + onNextClick?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void;
63
+ + onPrevClick?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void;
64
+
65
+ + // New options added
66
+ + overlayColor?: string;
67
+ + stageRadius?: number;
68
+ + popoverOffset?: number;
69
+ + disableButtons?: ["next", "prev", "close"];
70
+ + showProgress?: boolean;
71
+ + progressText?: string;
72
+ + onPopoverRender?: (popover: PopoverDOM, options: { config: Config; state: State }) => void;
73
+ }
74
+ ```
75
+
76
+ > Changes in step and popover definition
77
+
78
+ ```diff
79
+ const stepDefinition = {
80
+ popover: {
81
+ - closeBtnText: 'Close', // Removed, close button is an icon
82
+ - element: '.some-element', // Required
83
+ + element: '.some-element', // Optional, if not provided, step will be shown as modal
84
+ - className: 'popover-class',
85
+ + popoverClass: string;
86
+ - showButtons: false,
87
+ + showButtons: ["next", "previous", "close"]; // Array of buttons to show
88
+ - title: ''; // Required
89
+ + title: ''; // Optional
90
+ - description: ''; // Required
91
+ + description: ''; // Optional
92
+
93
+ - // position can be left, left-center, left-bottom, top,
94
+ - // top-center, top-right, right, right-center, right-bottom,
95
+ - // bottom, bottom-center, bottom-right, mid-center
96
+ - position: 'left',
97
+ + // Now you need to specify the side and align separately
98
+ + side?: "top" | "right" | "bottom" | "left";
99
+ + align?: "start" | "center" | "end";
100
+
101
+ + // New options
102
+ + showProgress?: boolean;
103
+ + progressText?: string;
104
+ + onPopoverRender?: (popover: PopoverDOM, options: { config: Config; state: State }) => void;
105
+ + onNextClick?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void
106
+ + onPrevClick?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void
107
+ + onCloseClick?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void
108
+ }
109
+
110
+ + // New hook to control the flow of the driver
111
+ + onDeselected?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void;
112
+ + onHighlightStarted?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void;
113
+ + onHighlighted?: (element?: Element, step: DriveStep, options: { config: Config; state: State }) => void;
114
+ };
115
+ ```
116
+
117
+ > Changes in API methods.
118
+
119
+ ```diff
120
+ - driverObj.preventMove(); // async support is built-in, no longer need to call this
121
+ - activeElement.getCalculatedPosition();
122
+ - activeElement.hidePopover();
123
+ - activeElement.showPopover();
124
+ - activeElement.getNode();
125
+
126
+ - const isActivated = driverObj.isActivated;
127
+ + const isActivated = driverObj.isActive();
128
+
129
+ - driverObj.start(stepNumber = 0);
130
+ + driverObj.drive(stepNumber = 0);
131
+
132
+ - driverObj.highlight(string|stepDefinition);
133
+ + driverObj.highlight(stepDefinition)
134
+
135
+ - driverObj.reset();
136
+ + driverObj.destroy();
137
+
138
+ - driverObj.hasHighlightedElement();
139
+ + typeof driverObj.getActiveElement() !== 'undefined';
140
+
141
+ - driverObj.getHighlightedElement();
142
+ + driverObj.getActiveElement();
143
+
144
+ - driverObj.getLastHighlightedElement();
145
+ + driverObj.getPreviousElement();
146
+
147
+ + // New options added
148
+ + driverObj.moveTo(stepIndex)
149
+ + driverObj.getActiveStep(); // returns the configured step definition
150
+ + driverObj.getPreviousStep(); // returns the previous step definition
151
+ + driverObj.isLastStep();
152
+ + driverObj.isFirstStep();
153
+ + driverObj.getState();
154
+ + driverObj.getConfig();
155
+ + driverObj.setConfig(config);
156
+ + driverObj.refresh();
157
+ ```
158
+
159
+ Please make sure to visit the [documentation](https://driverjs.com/docs/configuration) for more details.