Skip to content

Commit

Permalink
Use larry for welcome message
Browse files Browse the repository at this point in the history
  • Loading branch information
bradp committed Mar 18, 2023
1 parent 38826db commit 8d317d3
Showing 1 changed file with 16 additions and 47 deletions.
63 changes: 16 additions & 47 deletions mh-spring-egg-hunt-helper.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -1608,66 +1608,35 @@
});
}

const showOnboardingArrow = (options) => {
options = options || {};

if (! options.highlight) {
/**
* Create a Larry popup.
*/
const createLarryWelcomePopup = () => {
if (getSetting('has-seen-egg-welcome-popup', false)) {
return;
}

options.arrowPosition = options.arrowPosition || 'topLeft';

if (options.beforeShow) {
options.beforeShow();
}

const highlightClick = document.querySelector(options.highlight);
if (highlightClick) {
highlightClick.addEventListener('click', () => {
console.log('🥚️ Clicked highlight'); // eslint-disable-line no-console
onboardingView.hideBouncyArrow();
if (options.onClose) {
options.onClose();
}
});
}
addStyles('#overlayPopup.egg-larry-popup .jsDialogContainer { background-image: url(https://i.mouse.rip/larry-welcome.png);}');

const onboardingView = new hg.views.OnboardingTutorialView;
const message = {
content: {
body: onboardingView.wrapInfoArrow(options.content, options.next || 'Next'),
},
highlight_dom: null,
on_show_callback: () => {
onboardingView.showBouncyArrow(options.pointArrow, options.arrowPosition);
if (options.onShow) {
options.onShow();
}
},
on_close_callback: () => {
onboardingView.hideBouncyArrow();
if (options.onClose) {
options.onClose();
}
},
css_class: 'larryCircle',
content: { body: '<div class="custom-larry-popup"><span class="text">Thanks for installing the SEH Helper! <p>You can find it under the Camp menu.</span> <a href="#" id="spring-egg-hunt-helper" class="action jsDialogClose">Continue</a></div>' },
css_class: 'larryOffice egg-larry-popup',
show_overlay: true,
is_modal: true
};

hg.views.MessengerView.addMessage(message);
hg.views.MessengerView.go();
};

showOnboardingArrow({
content: 'Welcome to the Spring Egg Hunt Helper! Click here to open the book.',
highlight: '.mousehuntHud-menu ul li.camp',
pointArrow: '.mousehuntHud-menu ul li.camp',
arrowPosition: 'topLeft',
onClose: () => {
console.log('🥚️ Closed onboarding'); // eslint-disable-line no-console
const larryPopup = document.querySelector('#spring-egg-hunt-helper');
if (larryPopup) {
larryPopup.addEventListener('click', () => {
saveSetting('has-seen-egg-welcome-popup', true);
});
}
})
};

createLarryWelcomePopup();

// TODO: uncomment this when the 1.4.0 of mousehunt-utils is released.
// createWelcomePopup({
Expand Down

0 comments on commit 8d317d3

Please sign in to comment.