kamrify commited on
Commit
a3fea2b
·
1 Parent(s): 06b7251

Add examples

Browse files
Files changed (1) hide show
  1. readme.md +90 -1
readme.md CHANGED
@@ -47,4 +47,93 @@ Or grab the code from `dist` directory and include it directly
47
  ```html
48
  <link rel="stylesheet" href="/dist/driver.min.css">
49
  <script src="/dist/driver.min.js"></script>
50
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  ```html
48
  <link rel="stylesheet" href="/dist/driver.min.css">
49
  <script src="/dist/driver.min.js"></script>
50
+ ```
51
+
52
+ ![](./demo/images/split.png)
53
+
54
+ ## Usage and Demo
55
+
56
+ Demos and many more usage examples can be found [through the docs page](http://kamranahmed.info/driver).
57
+
58
+ ### Highlighting Single Element – [Demo](http://kamranahmed.info/driver#single-element-no-popover)
59
+
60
+ If all you want is just highlight a single element, you can do that simply by passing the selector
61
+
62
+ ```javascript
63
+ const driver = new Driver();
64
+ driver.highlight('#create-post');
65
+ ```
66
+ A real world usage example for this could be using it to dim the background and highlight the required element e.g. the way facebook does it on creating a post.
67
+
68
+ ### Popover on Highlighted Element – [Demo](http://kamranahmed.info/driver#single-element-with-popover)
69
+
70
+ You can show additional details beside the highlighted element using the popover
71
+
72
+ ```javascript
73
+ const driver = new Driver();
74
+ driver.highlight({
75
+ element: '#some-element',
76
+ popover: {
77
+ title: 'Title for the Popover',
78
+ description: 'Description for it',
79
+ }
80
+ });
81
+ ```
82
+
83
+ Also, `title` and `description` can have HTML as well.
84
+
85
+ ### Positioning the Popover – [Demo](http://kamranahmed.info/driver#single-element-with-popover-position)
86
+
87
+ By default, driver automatically finds the suitable position for the popover and displays it, you can override it using `position` property
88
+
89
+ ```javascript
90
+ const driver = new Driver();
91
+ driver.highlight({
92
+ element: '#some-element',
93
+ popover: {
94
+ title: 'Title for the Popover',
95
+ description: 'Description for it',
96
+ position: 'left', // can be `top`, `left`, `right`, `bottom`
97
+ }
98
+ });
99
+ ```
100
+
101
+ ### Creating Feature Introductions – [Demo](http://kamranahmed.info/driver)
102
+
103
+ Feature introductions are helpful in onboarding new users and giving them idea about different parts of the application, you can create them seemlessly with driver. Define the steps and call the `start` when you want to start presenting
104
+
105
+ ```javascript
106
+ const driver = new Driver();
107
+
108
+ // Define the steps for introduction
109
+ driver.defineSteps([
110
+ {
111
+ element: '#first-element-introduction',
112
+ popover: {
113
+ title: 'Title on Popover',
114
+ description: 'Body of the popover',
115
+ position: 'left'
116
+ }
117
+ },
118
+ {
119
+ element: '#second-element-introduction',
120
+ popover: {
121
+ title: 'Title on Popover',
122
+ description: 'Body of the popover',
123
+ position: 'top'
124
+ }
125
+ },
126
+ {
127
+ element: '#third-element-introduction',
128
+ popover: {
129
+ title: 'Title on Popover',
130
+ description: 'Body of the popover',
131
+ position: 'right'
132
+ }
133
+ },
134
+ ]);
135
+
136
+ // Start the introduction
137
+ driver.start();
138
+ ```
139
+