Skip to content

Commit 42c37e3

Browse files
committed
Minor refactor on onboarding script
And add first-time warning popup on Tweaks
1 parent c931424 commit 42c37e3

File tree

4 files changed

+140
-71
lines changed

4 files changed

+140
-71
lines changed

src/app/index.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,14 @@ function initializeComponents(): void {
316316
compElemItem.on("click", "button.component-toggle", () => {
317317
setCompInfo(comp);
318318

319+
if (!isTweaksWarned) {
320+
if (comp.startsWith("tweak")) {
321+
driverTweaksfirsttimeGet().drive();
322+
localStorage.setItem(flagKeyTweaksfirsttime, "");
323+
isTweaksWarned = true;
324+
}
325+
}
326+
319327
currViewedComp?.removeClass("viewed");
320328
currViewedComp = compElemItem;
321329
currViewedComp.addClass("viewed");
@@ -967,6 +975,17 @@ const updateCompListFilterState: () => void = initSearch(d, () => {
967975
});
968976
updateCompListFilterState();
969977

978+
import {
979+
introFirsttimeInit,
980+
981+
flagKeyTweaksfirsttime,
982+
driverTweaksfirsttimeGet,
983+
} from "./scripts/intro";
984+
985+
let isTweaksWarned: boolean = localStorage.getItem(flagKeyTweaksfirsttime) !== null;
986+
970987
$(document).on("load", () => {
971988
$("components-selector-container-inner").css("height", "100%");
972-
});
989+
});
990+
991+
introFirsttimeInit();

src/app/scripts/intro.ts

Lines changed: 99 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,111 @@
11
import { driver, type Driver } from "driver.js";
22

3-
document.getElementById("help-button").addEventListener("click", () => {
4-
driverInitialIntro.drive();
5-
});
3+
export function introFirsttimeInit(): void {
4+
const flagKeyFirsttime: string = "pitch-flagKeyFirsttime";
5+
6+
document.getElementById("help-button").addEventListener("click", () => {
7+
driverFirsttime.drive();
8+
});
9+
10+
const driverFirsttime: Driver = driver({
11+
showProgress: true,
12+
overlayOpacity: 1.0,
13+
allowClose: false,
14+
steps: [
15+
{ popover: {
16+
align: "center",
17+
description: `
18+
<div class="intro-popover">
19+
<img src="./pitch-logo.svg" class="pitch-logo">
20+
Welcome to Pitch.
21+
<br>
22+
CSS components and tweaks, designed specifically for your itch.io project pages.
23+
</div>`,
24+
}},
25+
{ element: "#components-list", popover: {
26+
title: "find ur perfec components",
27+
description: `
28+
Click on the component's name to see
29+
live preview and its HTML codes.
30+
`,
31+
side: "right",
32+
align: "center",
33+
}},
34+
{ element: "#components-list > .onboard-check-dummy", popover: {
35+
title: "Add the components",
36+
description: `
37+
Tick the checkbox to add it to your selection.
38+
`,
39+
side: "right",
40+
align: "center",
41+
}},
42+
{ element: "#compile-components-btn", popover: {
43+
title: "Copy the CSS",
44+
description: `
45+
Copy the CSS codes of your selected components.
46+
`,
47+
side: "top",
48+
align: "end",
49+
}},
50+
{ element: "#show-css-btn", popover: {
51+
title: "Can't copy the CSS?",
52+
description: `
53+
Click here, and copy the CSS codes manually, if you're unable to copy it via the button.
54+
`,
55+
side: "top",
56+
align: "end",
57+
}},
58+
{ element: ".theme-selector-container", popover: {
59+
title: "Theme preview",
60+
description: `
61+
The components are designed to adapt to your page's theme.
62+
Click on the various theme preset to see how they would look on different themes.
63+
`,
64+
side: "bottom",
65+
align: "end",
66+
}},
67+
{ element: "#help-button", popover: {
68+
title: "Help",
69+
description: `
70+
Click on this button to re-run this guide again.
71+
`,
72+
side: "bottom",
73+
align: "end",
74+
}},
75+
],
76+
});
77+
78+
if (localStorage.getItem(flagKeyFirsttime) === null) {
79+
driverFirsttime.drive();
80+
localStorage.setItem(flagKeyFirsttime, "");
81+
}
82+
}
83+
84+
// Tweaks-related info
85+
86+
export const flagKeyTweaksfirsttime: string = "pitch-flagKeyTweaksfirsttime";
687

7-
const driverInitialIntro: Driver = driver({
8-
showProgress: true,
88+
export const driverTweaksfirsttimeGet: () => Driver = (): Driver => driver({
89+
showProgress: false,
990
overlayOpacity: 1.0,
10-
allowClose: false,
91+
allowClose: true,
1192
steps: [
1293
{ popover: {
1394
align: "center",
1495
description: `
15-
<div class="intro-popover">
16-
<img src="./pitch-logo.svg" class="pitch-logo">
17-
Welcome to Pitch.
18-
<br>
19-
CSS components and tweaks, designed specifically for your itch.io project pages.
96+
<div class="tweaks-intro">
97+
<h1>Here be dragons!</h1>
98+
<p>
99+
Pitch's Tweaks relies on itch.io's HTML structures,
100+
which can change in the future if the site got updated, and might possibly breaks the Tweaks' functionalities!!
101+
</p>
102+
<p>
103+
We'll keep you updated if there's breaking changes, and update the Tweaks as soon as possible.
104+
</p>
105+
<p>
106+
Follow the project, so you won't miss it!!
107+
</p>
20108
</div>`,
21109
}},
22-
{ element: "#components-list", popover: {
23-
title: "find ur perfec components",
24-
description: `
25-
Click on the component's name to see
26-
live preview and its HTML codes.
27-
`,
28-
side: "right",
29-
align: "center",
30-
}},
31-
{ element: "#components-list > .onboard-check-dummy", popover: {
32-
title: "Add the components",
33-
description: `
34-
Tick the checkbox to add it to your selection.
35-
`,
36-
side: "right",
37-
align: "center",
38-
}},
39-
{ element: "#compile-components-btn", popover: {
40-
title: "Copy the CSS",
41-
description: `
42-
Copy the CSS codes of your selected components.
43-
`,
44-
side: "top",
45-
align: "end",
46-
}},
47-
{ element: "#show-css-btn", popover: {
48-
title: "Can't copy the CSS?",
49-
description: `
50-
Click here, and copy the CSS codes manually, if you're unable to copy it via the button.
51-
`,
52-
side: "top",
53-
align: "end",
54-
}},
55-
{ element: ".theme-selector-container", popover: {
56-
title: "Theme preview",
57-
description: `
58-
The components are designed to adapt to your page's theme.
59-
Click on the various theme preset to see how they would look on different themes.
60-
`,
61-
side: "bottom",
62-
align: "end",
63-
}},
64-
{ element: "#help-button", popover: {
65-
title: "Help",
66-
description: `
67-
Click on this button to re-run this guide again.
68-
`,
69-
side: "bottom",
70-
align: "end",
71-
}},
72110
],
73111
});
74-
75-
const introFlagKey: string = "pitchIntroFinished";
76-
77-
if (localStorage.getItem(introFlagKey) === null) {
78-
driverInitialIntro.drive();
79-
localStorage.setItem(introFlagKey, "");
80-
}

src/app/styles/_intro.scss

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,24 @@ svg.driver-overlay > path {
5252
transform: rotate(-35deg);
5353
margin-right: -1em;
5454
}
55+
}
56+
57+
58+
#driver-popover-content:has(.tweaks-intro) {
59+
60+
max-width: 35em !important;
61+
62+
& .driver-popover-prev-btn {
63+
display: none !important;
64+
}
65+
}
66+
67+
.tweaks-intro {
68+
& h1 {
69+
font-family: "Courgette";
70+
}
71+
72+
& p {
73+
font-size: 1.25em;
74+
}
5575
}

src/app/vendor.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,4 @@ import "@fontsource/pixelify-sans";
1919
// Syntax highlighter theme
2020
import "./styles/prismjs-theme.scss";
2121

22-
import "driver.js/dist/driver.css";
23-
import "./scripts/intro";
22+
import "driver.js/dist/driver.css";

0 commit comments

Comments
 (0)