Skip to content

Commit

Permalink
Added webpack and codes of spotlight
Browse files Browse the repository at this point in the history
  • Loading branch information
cttricks committed Aug 26, 2024
1 parent fddcce7 commit b627b44
Show file tree
Hide file tree
Showing 12 changed files with 5,195 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
!.vscode/extensions.json
.idea
.DS_Store
src
node_modules
dist/*.txt
231 changes: 231 additions & 0 deletions dist/spotlight.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions dist/spotlight.min.js

Large diffs are not rendered by default.

53 changes: 48 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@ <h2>#Examples</h2>
<button data-style="highlight-only">Highlight Only</button>
<button data-style="confirm-before-exit">Confirm on Exit</button>
<button data-style="change-overlay-color">Overlay Color</button>
<!-- Spotlight; ./custom-popup.webp; Design and integrate custom models with options to customize and use pictures, GIFs, and more in your explanations. -->
<button data-style="custom-model">Custom Model</button>
<!-- Spotlight; ./docs/assets/img/demo-tour/custom-popup.webp; Use pictures, GIFs, and more in your explanations. -->
<button data-style="popover-with-img">Popover with Image</button>
<!-- Spotlight; Spotlight JS includes an <strong>onEvent</strong> callback that captures and emits all events from start to finish. -->
<button data-style="about-event-handling">Event Handling</button>
<button data-style="event-listener">Event Listener</button>
</div>
<p class="mt-4">
Additional features are planned for future updates. If you have any suggestions, feel free to
Expand All @@ -129,6 +129,7 @@ <h2>#Examples</h2>
</section>

<div class="hr-line"></div>

<section class="container-lg github-starts">
<div class="text-center">
<h2>Unlock the full potential of your web projects</h2>
Expand All @@ -151,6 +152,7 @@ <h2>Unlock the full potential of your web projects</h2>
</div>
</div>
</section>

<footer class="py-4 mt-4">
<div>
<span>MIT Licensed © </span>
Expand Down Expand Up @@ -180,9 +182,19 @@ <h2>Unlock the full potential of your web projects</h2>
</footer>

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
<!-- <script type="module" src="./dist/spotlight.js" ></script> -->

<script type="module">
// Let's import spotlight.js

// Let's Start with
import { spotlight } from './dist/spotlight.min.js';

const Spotlight = await spotlight();

// Event Handler
Spotlight.addEventListener('exit', (e) => {
Spotlight.setCover({ hex: '#000000', alpha: 0.5});
});

// Below codes are to handel the events of this page Only
document.querySelector('footer span').innerHTML += new Date().getFullYear();
Expand All @@ -193,7 +205,38 @@ <h2>Unlock the full potential of your web projects</h2>

document.body.addEventListener('click', (e) => {
if((e.target.getAttribute('type')??'') === 'link') return handelButtonClickWithLinkAttr(e.target);
console.log(e.target);

let toggle = e.target.getAttribute('data-style');

if(!toggle) return;
e.preventDefault();

switch(toggle){
case 'highlight-only':
Spotlight.start({ from: 3, highlightOnly: true });
break;

case 'confirm-before-exit':
Spotlight.start({ from: 3, highlightOnly: true, confirmOnExit: true });
break;

case 'change-overlay-color':
Spotlight.setCover({ hex: '#bfff5c', alpha: 0.5});
Spotlight.start({ from: 3, highlightOnly: true });
break;

case 'popover-with-img':
Spotlight.start({ from: 4});
break;

case 'event-listener':
Spotlight.start({ from: 5 });
break;

default:
console.log(`${toggle} is not a toggle event`);
}

});

</script>
Expand Down
Loading

0 comments on commit b627b44

Please sign in to comment.