diff --git a/demo/scripts/demo.js b/demo/scripts/demo.js index 20ba3f1582727dc01e14a98dbd358f2e25ea0a68..48dbf1343bf013993842d7f2c8787c0903235a71 100644 --- a/demo/scripts/demo.js +++ b/demo/scripts/demo.js @@ -101,6 +101,88 @@ document.querySelector('#run-single-element-with-popover') popover: { title: 'Did you know?', description: 'You can add HTML in title or description also!', + position: 'top' } }); }); + +///////////////////////////////////////////////////// +// Highlighting single element with popover position +///////////////////////////////////////////////////// +const singleSholoWithPopoverPosition = new Sholo(); +document.querySelector('#run-single-element-with-popover-position') + .addEventListener('click', (e) => { + e.preventDefault(); + + singleSholoWithPopoverPosition.highlight({ + element: '#single-element-with-popover-position', + popover: { + title: 'Did you know?', + description: 'You can add HTML in title or description also!', + position: 'left' + } + }); + }); + +///////////////////////////////////////////////////// +// Highlighting single element with popover position +///////////////////////////////////////////////////// +const positionBtnsSholo = new Sholo({ + padding: 0 +}); + +document.querySelector('#position-btn-left') + .addEventListener('click', (e) => { + e.preventDefault(); + + positionBtnsSholo.highlight({ + element: '#position-btn-left', + popover: { + title: 'Did you know?', + description: 'You can add HTML in title or description also!', + position: 'left' + } + }); + }); + +document.querySelector('#position-btn-right') + .addEventListener('click', (e) => { + e.preventDefault(); + + positionBtnsSholo.highlight({ + element: '#position-btn-right', + popover: { + title: 'Did you know?', + description: 'You can add HTML in title or description also!', + position: 'right' + } + }); + }); + +document.querySelector('#position-btn-bottom') + .addEventListener('click', (e) => { + e.preventDefault(); + + positionBtnsSholo.highlight({ + element: '#position-btn-bottom', + popover: { + title: 'Did you know?', + description: 'You can add HTML in title or description also!', + position: 'bottom' + } + }); + }); + +document.querySelector('#position-btn-top') + .addEventListener('click', (e) => { + e.preventDefault(); + + positionBtnsSholo.highlight({ + element: '#position-btn-top', + popover: { + title: 'Did you know?', + description: 'You can add HTML in title or description also!', + position: 'top' + } + }); + }); \ No newline at end of file diff --git a/demo/styles/demo.scss b/demo/styles/demo.scss index a8c5c7d02bdcef56b8aa226989c845d2a61ccdea..f386d9fac211e731daa3b03cd39796f67eae55ba 100644 --- a/demo/styles/demo.scss +++ b/demo/styles/demo.scss @@ -91,8 +91,16 @@ section { background-color: #fafbfc; border: 3px solid #e1e4e8; border-radius: 3px; - box-shadow: inset 0 0 10px rgba(27,31,35,0.05); + box-shadow: inset 0 0 10px rgba(27, 31, 35, 0.05); margin-bottom: 0; margin-top: 7px; } +} + +.position-btns a { + font-size: 13px; + padding: 10px 15px; + background: #f54336; + color: white !important; + border-radius: 6px; } \ No newline at end of file diff --git a/index.html b/index.html index fd5f0323b8c6fd120928504ac815ed649a984b69..9f8aeed873bed37d7269867859f1ba6323f69e4e 100644 --- a/index.html +++ b/index.html @@ -102,8 +102,36 @@ driver.highlight({ } }); +

You can modify the behavior of this popover also by a certain set of options. More on it + below.

+
+ +
+

Popover Positioning

+

You can also, change the position of the popover to be either left, top, + right or bottom.

+ Run it +
const driver = new Driver();
+driver.highlight({
+  element: '#some-element',
+  popover: {
+    title: 'Title for the Popover',
+    description: 'Description for it',
+    position: 'left', // can be `top`, `left`, `right`, `bottom`
+  }
+});
+
+
+ On my Left + On my Top + On my Bottom + On my Right +
+

If you don't specify the position or specify it to be auto, it will automatically + find the suitable position for the popover and show it

+