Skip to content

Commit

Permalink
Add onboarding for casual mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayyy committed Feb 13, 2025
1 parent 3148998 commit 57b22b6
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 8 deletions.
2 changes: 1 addition & 1 deletion public/_locales
Submodule _locales updated 1 files
+7 −0 en/messages.json
32 changes: 31 additions & 1 deletion public/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,6 @@ ytd-compact-playlist-renderer .ytd-compact-playlist-renderer #video-title:not(.c
}

.cbNoticeButton:hover {
background-color: rgba(235, 235, 235, 0.2);
background-color: #0e78ca;
}

Expand Down Expand Up @@ -681,6 +680,37 @@ ytd-compact-playlist-renderer .ytd-compact-playlist-renderer #video-title:not(.c
justify-content: space-around;
}

.cbCasualVoteLogoContainer {
display: flex;
justify-content: center;
}

.cbCasualVoteLogoContainer img {
width: 50%;
}

.cbCasualVoteDescription {
font-size: 14px;
padding-left: 15px;
padding-right: 15px;
}

.cbCasualVoteDescription > div {
padding: 5px;
}

.casualOnboarding .cbVoteButton {
font-size: 18px;
}

.casualVoteMenuInner .cbNoticeButton:hover {
background-color: #22893e;
}

.casualOnboarding .cbCasualVoteTitle {
padding-top: 10px;
}

/* For autoplay */
.ytp-autonav-endscreen-video-info .cbShowOriginal img.cbShowOriginalImage {
height: 18px;
Expand Down
1 change: 1 addition & 0 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ waitFor(() => Config.isReady()).then(() => {
if (!Config.config!.userID) {
const newUserID = generateUserID();
Config.config!.userID = newUserID;
Config.config!.showInfoAboutCasualMode = false;
}

Config.config!.showInfoAboutRandomThumbnails = true;
Expand Down
2 changes: 2 additions & 0 deletions src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ interface SBConfig {
channelOverrides: Record<string, ConfigurationID>;
customConfigurations: Record<ConfigurationID, CustomConfiguration>;
showInfoAboutRandomThumbnails: boolean;
showInfoAboutCasualMode: boolean;
showIconForFormattedTitles: boolean;
countReplacements: boolean;
titleReplacements: number;
Expand Down Expand Up @@ -207,6 +208,7 @@ const syncDefaults = {
channelOverrides: {},
customConfigurations: {},
showInfoAboutRandomThumbnails: false,
showInfoAboutCasualMode: true,
showIconForFormattedTitles: true,
countReplacements: true,
titleReplacements: 0,
Expand Down
1 change: 1 addition & 0 deletions src/options/CasualChoiceComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const CasualChoiceComponent = () => {
onClick={() => {
setCasualMode(true);
Config.config!.casualMode = true;
Config.config!.showInfoAboutCasualMode = false;
setOpenAddCategoryMenu(false);
}}>
<div className="casualChoiceTitle">
Expand Down
58 changes: 58 additions & 0 deletions src/submission/CasualVoteOnboardingComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import * as React from "react";
import { FormattedText } from "../popup/FormattedTextComponent";

export interface CasualVoteComponentProps {
close: () => void;
}

export const CasualVoteOnboardingComponent = (props: CasualVoteComponentProps) => {

return (
<div className="casualVoteMenuInner casualOnboarding"
onClick={(e) => e.stopPropagation()}
onMouseDown={(e) => e.stopPropagation()}>

<div className="cbCasualVoteTitle">
<FormattedText
langKey="newCasualMode"
/>
</div>

<div className="cbCasualVoteLogoContainer">
<img
className="cbCasualVoteLogo"
src={chrome.runtime.getURL("icons/logo-casual.svg")}
/>
</div>

<div className="cbCasualVoteDescription">
{chrome.i18n.getMessage("CasualModeDescription").split("\n").map((line, index) => (
<div key={index}>{line}</div>
))}
</div>

<div className="cbVoteButtonContainer">
<button className="cbNoticeButton cbVoteButton"
onClick={() => {
chrome.runtime.sendMessage({ "message": "openConfig" });
props.close();
}}>
<FormattedText
langKey="OpenSettings"
/>
</button>
</div>

<div className="cbVoteButtonContainer">
<button className="cbNoticeButton cbVoteButton"
onClick={() => {
props.close();
}}>
<FormattedText
langKey="Dismiss"
/>
</button>
</div>
</div>
);
};
26 changes: 20 additions & 6 deletions src/submission/casualVoteButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Config from "../config/config";
import { closeGuidelineChecklist } from "./SubmissionChecklist";
import { TitleButton } from "./titleButton";
import { CasualVoteComponent } from "./CasualVoteComponent";
import { CasualVoteOnboardingComponent } from "./CasualVoteOnboardingComponent";

const casualVoteButtonIcon = `
<?xml version="1.0" encoding="UTF-8"?>
Expand All @@ -33,6 +34,7 @@ export class CasualVoteButton extends TitleButton {
closeGuidelineChecklist();

super.close();
this.updateIcon();
}

clearExistingVotes(): void {
Expand All @@ -46,11 +48,17 @@ export class CasualVoteButton extends TitleButton {

render(): void {
if (this.root) {
this.root?.render(<CasualVoteComponent
videoID={getVideoID()!}
existingVotes={this.existingVotes}
submitClicked={(categories, downvote) => this.submitPressed(categories, downvote)}
/>);
if (shouldShowCasualOnboarding()) {
this.root?.render(<CasualVoteOnboardingComponent close={() => this.close()} />);

Config.config!.showInfoAboutCasualMode = false;
} else {
this.root?.render(<CasualVoteComponent
videoID={getVideoID()!}
existingVotes={this.existingVotes}
submitClicked={(categories, downvote) => this.submitPressed(categories, downvote)}
/>);
}
}
}

Expand Down Expand Up @@ -82,12 +90,18 @@ export class CasualVoteButton extends TitleButton {
}

updateIcon(): void {
if (Config.config!.extensionEnabled && Config.config!.casualMode) {
if (Config.config!.extensionEnabled &&
(Config.config!.casualMode || shouldShowCasualOnboarding())) {
this.button.style.removeProperty("display");

super.updateIcon();
} else {
this.button.style.display = "none";
}
}
}

function shouldShowCasualOnboarding(): boolean {
// Check if userID not blank to ensure sync config is working
return !Config.config!.casualMode && Config.config!.showInfoAboutCasualMode && !!Config.config!.userID;
}

0 comments on commit 57b22b6

Please sign in to comment.