Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lichess-org/lila
Browse files Browse the repository at this point in the history
* 'master' of github.com:lichess-org/lila:
  Remove hopscotch dependency, use shepherd.js
  • Loading branch information
ornicar committed Mar 19, 2024
2 parents bfa49a2 + 14e771b commit 801f6a5
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 68 deletions.
10 changes: 3 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions ui/@types/lichess/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ interface Site {
jsModule(name: string): string;
loadIife(path: string, opts?: AssetUrlOpts): Promise<void>;
loadEsm<T, ModuleOpts = any>(name: string, opts?: { init?: ModuleOpts; url?: AssetUrlOpts }): Promise<T>;
hopscotch: any;
userComplete(opts: UserCompleteOpts): Promise<UserComplete>;
};
idleTimer(delay: number, onIdle: () => void, onWakeUp: () => void): void;
Expand Down Expand Up @@ -303,7 +302,6 @@ interface Window {
$as<T>(cash: Cash): T;
readonly chrome?: unknown;
readonly moment: any;
readonly hopscotch: any;
readonly stripeHandler: any;
readonly Stripe: any;
readonly Textcomplete: any;
Expand Down
5 changes: 0 additions & 5 deletions ui/pagelets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"debounce-promise": "^3.1.2",
"emoji-mart": "^5.5.2",
"flatpickr": "^4.6.13",
"hopscotch": "^0.3.1",
"lichess-pgn-viewer": "^2.0.1",
"prop-types": "^15.8.1",
"tablesort": "^5.3.0",
Expand Down Expand Up @@ -82,10 +81,6 @@
"src": "node_modules/cropperjs/dist/cropper.min.css",
"dest": "../../public/npm"
},
{
"src": "node_modules/hopscotch/dist/**",
"dest": "../../public/npm/hopscotch/dist"
},
{
"src": "../../node_modules/chessground/dist/chessground.min.js",
"dest": "../../public/npm"
Expand Down
24 changes: 0 additions & 24 deletions ui/pagelets/src/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,30 +41,6 @@ export function initModule(opts: { i18n: I18nDict }): void {
});
});

if ($('#perfStat.correspondence .view_games').length && site.once('user-correspondence-view-games'))
site.asset.hopscotch().then(() => {
window.hopscotch
.configure({
i18n: {
nextBtn: 'OK, got it',
},
})
.startTour({
id: 'correspondence-games',
showPrevButton: true,
isTourBubble: false,
steps: [
{
title: 'Recently finished games',
content:
'Would you like to display the list of your correspondence games, sorted by completion date?',
target: $('#perfStat.correspondence .view_games')[0],
placement: 'bottom',
},
],
});
});

$('.user-show .angles').each(function (this: HTMLElement) {
const $angles = $(this),
$content = $('.angle-content'),
Expand Down
4 changes: 3 additions & 1 deletion ui/round/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
"voice": "workspace:*",
"nvui": "workspace:*",
"board": "workspace:*",
"shepherd.js": "^11.2.0",
"snabbdom": "3.5.1"
},
"lichess": {
"modules": {
"esm": {
"src/main.ts": "round",
"src/plugins/nvui.ts": "round.nvui"
"src/plugins/nvui.ts": "round.nvui",
"src/plugins/tour.ts": "round.tour"
}
}
}
Expand Down
29 changes: 9 additions & 20 deletions ui/round/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
MoveMetadata,
Position,
NvuiPlugin,
RoundTour,
} from './interfaces';
import { defined, Toggle, toggle } from 'common';
import { Redraw } from 'common/snabbdom';
Expand Down Expand Up @@ -593,27 +594,15 @@ export default class RoundController implements MoveRootCtrl {
challengeRematch = async () => {
await xhr.challengeRematch(this.data.game.id);
site.pubsub.emit('challenge-app.open');
if (site.once('rematch-challenge'))
setTimeout(() => {
site.asset.hopscotch(function () {
window.hopscotch
.configure({
i18n: { doneBtn: 'OK, got it' },
})
.startTour({
id: 'rematch-challenge',
showPrevButton: true,
steps: [
{
title: 'Challenged to a rematch',
content: 'Your opponent is offline, but they can accept this challenge later!',
target: '#challenge-app',
placement: 'bottom',
},
],
});
});
if (site.once('rematch-challenge')) {
setTimeout(async () => {
const [tour] = await Promise.all([
site.asset.loadEsm<RoundTour>('round.tour'),
site.asset.loadCssPath('shepherd'),
]);
tour.corresRematchOffline();
}, 1000);
}
};

private makeCorrespondenceClock = (): void => {
Expand Down
4 changes: 4 additions & 0 deletions ui/round/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,7 @@ export interface MoveMetadata {
}

export type Position = 'top' | 'bottom';

export interface RoundTour {
corresRematchOffline: () => void;
}
31 changes: 31 additions & 0 deletions ui/round/src/plugins/tour.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { RoundTour } from '../interfaces';
import Shepherd from 'shepherd.js';

export function initModule(): RoundTour {
return {
corresRematchOffline,
};

function corresRematchOffline() {
const tour = new Shepherd.Tour();

tour.addStep({
title: 'Challenged to a rematch',
text: 'Your opponent is offline, but they can accept this challenge later!',
attachTo: {
element: 'button.rematch',
on: 'bottom',
},
buttons: [
{
action() {
return this.next();
},
text: 'Ok, got it',
},
],
});

tour.start();
}
}
9 changes: 0 additions & 9 deletions ui/site/src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,6 @@ export const userComplete = async (opts: UserCompleteOpts): Promise<UserComplete
return userComplete as UserComplete;
};

export const hopscotch = () => {
return Promise.all([
loadCss('npm/hopscotch/dist/css/hopscotch.min.css'),
loadIife('npm/hopscotch/dist/js/hopscotch.min.js', {
noVersion: true,
}),
]);
};

export function embedChessground() {
return import(url('npm/chessground.min.js'));
}

0 comments on commit 801f6a5

Please sign in to comment.