Skip to content

Commit

Permalink
feat: home onboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
ifaouibadi committed Feb 21, 2024
1 parent fe218f1 commit ebeee48
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 61 deletions.
3 changes: 2 additions & 1 deletion components.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"src/components/structures/LeftPanel.tsx": "src/components/structures/LeftPanel.tsx",
"src/components/views/rooms/RoomList.tsx": "src/components/views/rooms/RoomList.tsx",
"src/components/views/rooms/RoomSublist.tsx": "src/components/views/rooms/RoomSublist.tsx",
"src/components/views/dialogs/FeedbackDialog.tsx": "src/components/views/dialogs/FeedbackDialog.tsx"
"src/components/views/dialogs/FeedbackDialog.tsx": "src/components/views/dialogs/FeedbackDialog.tsx",
"src/components/views/user-onboarding/UserOnboardingHeader.tsx": "src/components/views/user-onboarding/UserOnboardingHeader.tsx"
}
80 changes: 80 additions & 0 deletions res/css/superhero/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,83 @@ h2 .sh_VerifiedIcon {
.cpd-theme-light svg.light_logo {
display: block !important;
}

.sh_userOnboarding {
display: flex;
flex-direction: row-reverse;
align-items: flex-start;
gap: 20px;
padding-left: 32px;
width: 100%;
background-color: var(--cpd-color-gray-300);
border-radius: 16px;
}

.sh_userOnboarding_bot_art {
flex: 0.3;
display: flex;
height: 100%;
border-top-right-radius: 16px;
/** gradiant background */
background: linear-gradient(180deg, rgba(97, 71, 255, 0.15) 0%, rgba(37, 40, 45, 0.15) 100%);
}

.cpd-theme-light .sh_userOnboarding_bot_art {
background: linear-gradient(180deg, rgba(97, 71, 255, 0.15) 0%, rgba(240, 240, 245, 0.15) 100%);
}

.sh_userOnboarding_bot_art svg {
margin-right: -18px;
}

.sh_userOnboarding_content {
flex: 0.7;
padding-top: 32px;
padding-bottom: 32px;
}

.sh_userOnboarding_content h1 {
font-weight: 700;
font-size: 42px;
line-height: 50.4px;
}

.sh_userOnboarding_content p {
opacity: 70%;
font-weight: 400;
font-size: 20px;
line-height: 24px;
}

.sh_userOnboarding_download_link {
display: flex;
flex-direction: row;
margin-bottom: 20px;
margin-top: 8px;
}

.sh_userOnboarding_download_option {
display: flex;
flex-direction: row;
background-color: var(--cpd-color-theme-bg);
margin-right: 10px;
border-radius: 8px;
padding: 7px 18px 7px 18px;
justify-content: center;
align-items: center;
}

.sh_userOnboarding_download_option_label {
padding: 0px 4px 0px 4px;
font-weight: 510;
font-size: 16px;
line-height: 22px;
text-align: center;
}

.sh_userOnboarding_btn {
border-radius: 8px;
padding: 7px 18px 7px 18px;
margin-top: 8px;
margin-bottom: 20px;
}
9 changes: 9 additions & 0 deletions res/themes/superhero/img/arts/welcome-ae-bot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 12 additions & 60 deletions src/components/structures/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@ limitations under the License.
import SdkConfig from "matrix-react-sdk/src/SdkConfig";
import AutoHideScrollbar from "matrix-react-sdk/src/components/structures/AutoHideScrollbar";
import EmbeddedPage from "matrix-react-sdk/src/components/structures/EmbeddedPage";
import AccessibleButton from "matrix-react-sdk/src/components/views/elements/AccessibleButton";
import { useMatrixClientContext } from "matrix-react-sdk/src/contexts/MatrixClientContext";
import { DirectoryMember, startDmOnFirstMessage } from "matrix-react-sdk/src/utils/direct-messages";
import { getHomePageUrl } from "matrix-react-sdk/src/utils/pages";
import { useUserOnboardingTasks } from "matrix-react-sdk/src/hooks/useUserOnboardingTasks";
import { UserOnboardingList } from "matrix-react-sdk/src/components/views/user-onboarding/UserOnboardingList";
import { useUserOnboardingContext } from "matrix-react-sdk/src/hooks/useUserOnboardingContext";
import * as React from "react";
import { useAtom } from "jotai";

import { Icon as ChatScreenShot } from "../../../res/themes/superhero/img/arts/chat-screenshot.svg";
import { Icon as ChromeIcon } from "../../../res/themes/superhero/img/icons/chrome.svg";
import { Icon as FirefoxIcon } from "../../../res/themes/superhero/img/icons/firefox.svg";
import { Icon as SuperheroLogo } from "../../../res/themes/superhero/img/logos/superhero-logo.svg";
import { botAccountsAtom } from "../../atoms";
import { UserOnboardingHeader } from "../views/user-onboarding/UserOnboardingHeader";



interface IProps {
justRegistered?: boolean;
Expand All @@ -38,64 +36,18 @@ const HomePage: React.FC<IProps> = () => {
const cli = useMatrixClientContext();
const config: any = SdkConfig.get();
const pageUrl = getHomePageUrl(config, cli);
const [botAccounts] = useAtom(botAccountsAtom);

const context = useUserOnboardingContext();
const tasks = useUserOnboardingTasks(context);

if (pageUrl) {
return <EmbeddedPage className="mx_HomePage" url={pageUrl} scrollbar={true} />;
}

return (
<AutoHideScrollbar className="mx_HomePage mx_HomePage_default" element="main">
<div className="mx_HomePage_default_wrapper">
<ChatScreenShot className="chat_screen_shot" />
<div className="mx_HomePage_title">
<SuperheroLogo />
<div>is so much better with our Wallet</div>
</div>
<div className="mx_HomePage_default_buttons_title">
<span style={{ fontWeight: "bold" }}>1. </span>Download extension for your browser
</div>
<div className="mx_HomePage_default_buttons browsers">
<AccessibleButton
onClick={(): void => {
window.open("https://addons.mozilla.org/en-US/firefox/addon/superhero-wallet/", "_blank");
}}
className="mx_HomePage_button_custom"
>
<FirefoxIcon />
from Firefox Add-ons
</AccessibleButton>
<AccessibleButton
onClick={(): void => {
window.open(
"https://chromewebstore.google.com/detail/superhero/mnhmmkepfddpifjkamaligfeemcbhdne",
"_blank",
);
}}
className="mx_HomePage_button_custom"
>
<ChromeIcon />
from Chrome Web Store
</AccessibleButton>
</div>
<div className="mx_HomePage_default_buttons_title">
<span style={{ fontWeight: "bold" }}>2.</span>Connect your wallet with $uperhero Bot
</div>
<div className="mx_HomePage_default_buttons">
<AccessibleButton
onClick={(): void => {
startDmOnFirstMessage(cli, [
new DirectoryMember({
user_id: botAccounts?.superheroBot || "",
}),
]);
}}
className="mx_HomePage_button_custom"
>
Chat with $uperhero Bot
</AccessibleButton>
</div>
</div>
<AutoHideScrollbar className="mx_UserOnboardingPage" style={{ maxWidth: "100%" }}>
<UserOnboardingHeader />
<UserOnboardingList tasks={tasks} />
</AutoHideScrollbar>
);
};
Expand Down
106 changes: 106 additions & 0 deletions src/components/views/user-onboarding/UserOnboardingHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import SdkConfig from "matrix-react-sdk/src/SdkConfig";
import AccessibleButton from "matrix-react-sdk/src/components/views/elements/AccessibleButton";
import { useMatrixClientContext } from "matrix-react-sdk/src/contexts/MatrixClientContext";
import { _t } from "matrix-react-sdk/src/languageHandler";
import { DirectoryMember, startDmOnFirstMessage } from "matrix-react-sdk/src/utils/direct-messages";
import * as React from "react";
import { useAtom } from "jotai";

import { botAccountsAtom } from "../../../atoms";
import { Icon as ChromeIcon } from "../../../../res/themes/superhero/img/icons/chrome.svg";
import { Icon as FirefoxIcon } from "../../../../res/themes/superhero/img/icons/firefox.svg";
import { Icon as WelcomeAeBot } from "../../../../res/themes/superhero/img/arts/welcome-ae-bot.svg";

export function UserOnboardingHeader(): JSX.Element {
const cli = useMatrixClientContext();
const [botAccounts] = useAtom(botAccountsAtom);
const title = _t("onboarding|welcome_to_brand", {
brand: SdkConfig.get("brand"),
});

return (
<div className="sh_userOnboarding">
<div className="sh_userOnboarding_bot_art">
<WelcomeAeBot />
</div>

<div className="sh_userOnboarding_content">
<h1>{title}</h1>
<p>
With free end-to-end encrypted messaging, and unlimited voice and video calls, Superhero is a great
way to stay in touch. But that's not all! With Superhero Chat you will be able to access token-gated
chat rooms and create your own communities.
</p>

<div>
<div className="mx_Heading_h2">Let's get started!</div>

<div>
<div>
<p>Download and install Superhero Wallet browser extension:</p>
<div className="sh_userOnboarding_download_link">
<AccessibleButton
onClick={(): void => {
window.open(
"https://chromewebstore.google.com/detail/superhero/mnhmmkepfddpifjkamaligfeemcbhdne",
"_blank",
);
}}
className="sh_userOnboarding_download_option"
>
<ChromeIcon style={{ width: "22px", height: "22px", top: "7px", left: "18px" }} />
<div className="sh_userOnboarding_download_option_label">from Chrome Web Store</div>
</AccessibleButton>
<AccessibleButton
onClick={(): void => {
window.open(
"https://addons.mozilla.org/en-US/firefox/addon/superhero-wallet/",
"_blank",
);
}}
className="sh_userOnboarding_download_option"
>
<FirefoxIcon style={{ width: "22px", height: "22px", top: "7px", left: "18px" }} />
<div className="sh_userOnboarding_download_option_label">from Firefox Add-ons</div>
</AccessibleButton>
</div>
</div>

<div>
<p>Say hello to Wallet Bot and connect your Superhero Wallet:</p>
<AccessibleButton
onClick={(): void => {
startDmOnFirstMessage(cli, [
new DirectoryMember({
user_id: botAccounts?.superheroBot || "",
}),
]);
}}
kind="primary"
className="sh_userOnboarding_btn"
>
Chat With Wallet Bot
</AccessibleButton>
</div>
</div>
</div>
</div>
</div>
);
}

0 comments on commit ebeee48

Please sign in to comment.