Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs-src/src/content/docs/guides/install.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ with:
```html
<script
type="module"
src="https://cdn.jsdelivr.net/npm/shepherd.js@15.0.0/dist/js/shepherd.mjs"
src="https://cdn.jsdelivr.net/npm/shepherd.js@17.0.0/dist/js/shepherd.mjs"
></script>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/shepherd.js@15.0.0/dist/css/shepherd.css"
href="https://cdn.jsdelivr.net/npm/shepherd.js@17.0.0/dist/css/shepherd.css"
/>
```

Expand Down
31 changes: 31 additions & 0 deletions landing/src/components/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,34 @@ const { isHome } = Astro.props;
}
</div>
</header>

<script>
// Handle demo button click - redirect to home if not already there
function setupDemoButton() {
const showTourBtn = document.querySelector('#showTour');

if (!showTourBtn) return;

// Remove any existing listeners
const newBtn = showTourBtn.cloneNode(true) as HTMLElement;
showTourBtn.parentNode?.replaceChild(newBtn, showTourBtn);

newBtn.addEventListener('click', () => {
// Check if we're on the home page
if (window.location.pathname !== '/') {
// Store flag to start tour after navigation
sessionStorage.setItem('startTourOnLoad', 'true');
window.location.href = '/';
} else {
// We're already on home page, dispatch event to start tour
window.dispatchEvent(new CustomEvent('startTour'));
}
});
}

// Run on initial load
document.addEventListener('DOMContentLoaded', setupDemoButton);

// Run on Astro page transitions
document.addEventListener('astro:page-load', setupDemoButton);
</script>
17 changes: 13 additions & 4 deletions landing/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import MainPage from '@layouts/MainPage.astro';
<Code
code={`
<link rel="stylesheet" href="shepherd.js/dist/css/shepherd.css"/>
<script type="module" src="shepherd.js/dist/shepherd.mjs"></script>
<script type="module" src="shepherd.js/dist/js/shepherd.mjs"></script>

`}
lang="js"
Expand Down Expand Up @@ -94,9 +94,16 @@ import MainPage from '@layouts/MainPage.astro';
// wait for shepherd to be ready
setTimeout(function () {
const shepherd = setupShepherd();
const startBtn = document.querySelector('#showTour');

startBtn?.addEventListener('click', () => shepherd.start());

// Check if we should auto-start the tour (after redirect from another page)
const shouldStartTour = sessionStorage.getItem('startTourOnLoad');
if (shouldStartTour) {
sessionStorage.removeItem('startTourOnLoad');
shepherd.start();
}

// Listen for custom event from Demo button when already on home page
window.addEventListener('startTour', () => shepherd.start());
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}, 400);
}

Expand Down Expand Up @@ -297,6 +304,8 @@ import MainPage from '@layouts/MainPage.astro';

function ready() {
document.addEventListener('DOMContentLoaded', init);
// Also listen for Astro page transitions
document.addEventListener('astro:page-load', init);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
}

ready();
Expand Down
2 changes: 1 addition & 1 deletion shepherd.js/dummy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ <h3>Example</h3>

<!-- Shepherd -->
<script type="module">
import Shepherd from '../dist/esm/shepherd.mjs';
import Shepherd from '../dist/js/shepherd.mjs';

window.Shepherd = Shepherd;

Expand Down
2 changes: 1 addition & 1 deletion shepherd.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"Robbie Wagner <rwwagner90@gmail.com>",
"Chuck Carpenter <chuck@shipshape.io>"
],
"main": "./dist/cjs/shepherd.cjs",
"main": "./dist/cjs/shepherd.mjs",
"module": "./dist/js/shepherd.mjs",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
"exports": {
".": {
Expand Down