More examples and docs
Browse files- demo/scripts/demo.js +82 -0
- demo/styles/demo.scss +9 -1
- index.html +28 -0
demo/scripts/demo.js
CHANGED
|
@@ -101,6 +101,88 @@ document.querySelector('#run-single-element-with-popover')
|
|
| 101 |
popover: {
|
| 102 |
title: 'Did you know?',
|
| 103 |
description: 'You can add HTML in title or description also!',
|
|
|
|
| 104 |
}
|
| 105 |
});
|
| 106 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
popover: {
|
| 102 |
title: 'Did you know?',
|
| 103 |
description: 'You can add HTML in title or description also!',
|
| 104 |
+
position: 'top'
|
| 105 |
}
|
| 106 |
});
|
| 107 |
});
|
| 108 |
+
|
| 109 |
+
/////////////////////////////////////////////////////
|
| 110 |
+
// Highlighting single element with popover position
|
| 111 |
+
/////////////////////////////////////////////////////
|
| 112 |
+
const singleSholoWithPopoverPosition = new Sholo();
|
| 113 |
+
document.querySelector('#run-single-element-with-popover-position')
|
| 114 |
+
.addEventListener('click', (e) => {
|
| 115 |
+
e.preventDefault();
|
| 116 |
+
|
| 117 |
+
singleSholoWithPopoverPosition.highlight({
|
| 118 |
+
element: '#single-element-with-popover-position',
|
| 119 |
+
popover: {
|
| 120 |
+
title: 'Did you know?',
|
| 121 |
+
description: 'You can add HTML in title or description also!',
|
| 122 |
+
position: 'left'
|
| 123 |
+
}
|
| 124 |
+
});
|
| 125 |
+
});
|
| 126 |
+
|
| 127 |
+
/////////////////////////////////////////////////////
|
| 128 |
+
// Highlighting single element with popover position
|
| 129 |
+
/////////////////////////////////////////////////////
|
| 130 |
+
const positionBtnsSholo = new Sholo({
|
| 131 |
+
padding: 0
|
| 132 |
+
});
|
| 133 |
+
|
| 134 |
+
document.querySelector('#position-btn-left')
|
| 135 |
+
.addEventListener('click', (e) => {
|
| 136 |
+
e.preventDefault();
|
| 137 |
+
|
| 138 |
+
positionBtnsSholo.highlight({
|
| 139 |
+
element: '#position-btn-left',
|
| 140 |
+
popover: {
|
| 141 |
+
title: 'Did you know?',
|
| 142 |
+
description: 'You can add HTML in title or description also!',
|
| 143 |
+
position: 'left'
|
| 144 |
+
}
|
| 145 |
+
});
|
| 146 |
+
});
|
| 147 |
+
|
| 148 |
+
document.querySelector('#position-btn-right')
|
| 149 |
+
.addEventListener('click', (e) => {
|
| 150 |
+
e.preventDefault();
|
| 151 |
+
|
| 152 |
+
positionBtnsSholo.highlight({
|
| 153 |
+
element: '#position-btn-right',
|
| 154 |
+
popover: {
|
| 155 |
+
title: 'Did you know?',
|
| 156 |
+
description: 'You can add HTML in title or description also!',
|
| 157 |
+
position: 'right'
|
| 158 |
+
}
|
| 159 |
+
});
|
| 160 |
+
});
|
| 161 |
+
|
| 162 |
+
document.querySelector('#position-btn-bottom')
|
| 163 |
+
.addEventListener('click', (e) => {
|
| 164 |
+
e.preventDefault();
|
| 165 |
+
|
| 166 |
+
positionBtnsSholo.highlight({
|
| 167 |
+
element: '#position-btn-bottom',
|
| 168 |
+
popover: {
|
| 169 |
+
title: 'Did you know?',
|
| 170 |
+
description: 'You can add HTML in title or description also!',
|
| 171 |
+
position: 'bottom'
|
| 172 |
+
}
|
| 173 |
+
});
|
| 174 |
+
});
|
| 175 |
+
|
| 176 |
+
document.querySelector('#position-btn-top')
|
| 177 |
+
.addEventListener('click', (e) => {
|
| 178 |
+
e.preventDefault();
|
| 179 |
+
|
| 180 |
+
positionBtnsSholo.highlight({
|
| 181 |
+
element: '#position-btn-top',
|
| 182 |
+
popover: {
|
| 183 |
+
title: 'Did you know?',
|
| 184 |
+
description: 'You can add HTML in title or description also!',
|
| 185 |
+
position: 'top'
|
| 186 |
+
}
|
| 187 |
+
});
|
| 188 |
+
});
|
demo/styles/demo.scss
CHANGED
|
@@ -91,8 +91,16 @@ section {
|
|
| 91 |
background-color: #fafbfc;
|
| 92 |
border: 3px solid #e1e4e8;
|
| 93 |
border-radius: 3px;
|
| 94 |
-
box-shadow: inset 0 0 10px rgba(27,31,35,0.05);
|
| 95 |
margin-bottom: 0;
|
| 96 |
margin-top: 7px;
|
| 97 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
}
|
|
|
|
| 91 |
background-color: #fafbfc;
|
| 92 |
border: 3px solid #e1e4e8;
|
| 93 |
border-radius: 3px;
|
| 94 |
+
box-shadow: inset 0 0 10px rgba(27, 31, 35, 0.05);
|
| 95 |
margin-bottom: 0;
|
| 96 |
margin-top: 7px;
|
| 97 |
}
|
| 98 |
+
}
|
| 99 |
+
|
| 100 |
+
.position-btns a {
|
| 101 |
+
font-size: 13px;
|
| 102 |
+
padding: 10px 15px;
|
| 103 |
+
background: #f54336;
|
| 104 |
+
color: white !important;
|
| 105 |
+
border-radius: 6px;
|
| 106 |
}
|
index.html
CHANGED
|
@@ -102,8 +102,36 @@ driver.highlight({
|
|
| 102 |
}
|
| 103 |
});
|
| 104 |
</code></pre>
|
|
|
|
|
|
|
| 105 |
</div>
|
| 106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
</section>
|
| 108 |
</div>
|
| 109 |
|
|
|
|
| 102 |
}
|
| 103 |
});
|
| 104 |
</code></pre>
|
| 105 |
+
<p class="top-20">You can modify the behavior of this popover also by a certain set of options. More on it
|
| 106 |
+
below.</p>
|
| 107 |
</div>
|
| 108 |
|
| 109 |
+
<hr class="hr__fancy">
|
| 110 |
+
|
| 111 |
+
<div id="single-element-with-popover-position" class="section__example">
|
| 112 |
+
<h4>Popover Positioning</h4>
|
| 113 |
+
<p>You can also, change the position of the popover to be either <code>left</code>, <code>top</code>,
|
| 114 |
+
<code>right</code> or <code>bottom</code>.</p>
|
| 115 |
+
<a href="#" class="btn__run-demo" id="run-single-element-with-popover-position">Run it</a>
|
| 116 |
+
<pre><code class="javascript">const driver = new Driver();
|
| 117 |
+
driver.highlight({
|
| 118 |
+
element: '#some-element',
|
| 119 |
+
popover: {
|
| 120 |
+
title: 'Title for the Popover',
|
| 121 |
+
description: 'Description for it',
|
| 122 |
+
position: 'left', // can be `top`, `left`, `right`, `bottom`
|
| 123 |
+
}
|
| 124 |
+
});
|
| 125 |
+
</code></pre>
|
| 126 |
+
<div class="top-20 position-btns">
|
| 127 |
+
<a href="#" id="position-btn-left">On my Left</a>
|
| 128 |
+
<a href="#" id="position-btn-top">On my Top</a>
|
| 129 |
+
<a href="#" id="position-btn-bottom">On my Bottom</a>
|
| 130 |
+
<a href="#" id="position-btn-right">On my Right</a>
|
| 131 |
+
</div>
|
| 132 |
+
<p class="top-20">If you don't specify the position or specify it to be <code>auto</code>, it will automatically
|
| 133 |
+
find the suitable position for the popover and show it</p>
|
| 134 |
+
</div>
|
| 135 |
</section>
|
| 136 |
</div>
|
| 137 |
|