Skip to content

Commit

Permalink
refactor(guide): 🎉 add guide tour
Browse files Browse the repository at this point in the history
  • Loading branch information
gokhangunduz committed Sep 18, 2023
1 parent d4d9955 commit 4d74786
Show file tree
Hide file tree
Showing 24 changed files with 431 additions and 142 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@reduxjs/toolkit": "^1.9.1",
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@types/reactour": "^1.18.2",
"@uiw/react-markdown-preview": "^4.1.13",
"animate.css": "^4.1.1",
"apexcharts": "^3.37.0",
Expand Down Expand Up @@ -45,6 +46,7 @@
"react-full-screen": "^1.1.1",
"react-gravatar": "^2.6.3",
"react-icons": "^4.7.1",
"react-joyride": "^2.5.5",
"react-joystick-component": "^6.2.0",
"react-redux": "^8.0.5",
"react-router-dom": "^6.7.0",
Expand All @@ -55,8 +57,10 @@
"react-terminal": "^1.3.1",
"react-toggle": "^4.1.3",
"react-top-loading-bar": "^2.3.1",
"react-use": "^17.4.0",
"react-use-size": "^3.0.1",
"react-zoom-pan-pinch": "^3.0.6",
"reactour": "^1.19.1",
"redux-persist": "^6.0.0",
"roslib": "^1.3.0",
"sonner": "^0.1.1",
Expand Down
12 changes: 12 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2153,6 +2153,14 @@ video {
padding: 2rem;
}

.\!p-8 {
padding: 2rem !important;
}

.\!p-10 {
padding: 2.5rem !important;
}

.\!px-0 {
padding-left: 0px !important;
padding-right: 0px !important;
Expand Down Expand Up @@ -2748,6 +2756,10 @@ video {
opacity: 0.9;
}

.opacity-50 {
opacity: 0.5;
}

.\!shadow {
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1) !important;
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color) !important;
Expand Down
1 change: 1 addition & 0 deletions src/components/CountWidget/CountWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface ICountWidget {
export default function CountWidget({ data }: ICountWidget): ReactElement {
return (
<Widget
dataTut="counter-widget"
title={`State Counter`}
subtitle={`State Counter`}
icon={<GoGraph size={20} className="text-layer-light-700" />}
Expand Down
18 changes: 18 additions & 0 deletions src/components/GuideContainer/GuideContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, { ReactElement } from "react";

interface IGuideContainer {
title: string;
text: string;
}

export default function GuideContainer({
title,
text,
}: IGuideContainer): ReactElement {
return (
<div className="flex flex-col gap-2">
<span className="text-lg font-medium">{title}</span>
<p className="text-sm">{text}</p>
</div>
);
}
1 change: 1 addition & 0 deletions src/components/InformationWidget/InformationWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function InformationWidget({
}: IInformationWidget): ReactElement {
return (
<div
data-tut="information-widget"
className={`w-full flex flex-col justify-around rounded-lg bg-layer-light-50 shadow-lg p-8 animate__animated animate__fadeIn border border-layer-light-200 h-[21rem] ${className}`}
style={{
backgroundImage: `url("/images/abstract-white.jpg")`,
Expand Down
1 change: 1 addition & 0 deletions src/components/RegionsWidget/RegionsWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export default function RegionsWidget({

return (
<Widget
dataTut="regions-widget"
title={`${title} Regions`}
subtitle={`Locations of the ${title}`}
icon={<GoGraph size={20} className="text-layer-light-700" />}
Expand Down
1 change: 1 addition & 0 deletions src/components/ResourcesWidget/ResourcesWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default function ResourcesWidget({
}: IResourcesWidget): ReactElement {
return (
<Widget
dataTut="resources-widget"
title={`Software Resources`}
subtitle={`${title} Resources`}
icon={<GoGraph size={20} className="text-layer-light-700" />}
Expand Down
6 changes: 3 additions & 3 deletions src/components/SidebarMenu/SidebarMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Fragment, ReactElement, useEffect, useState } from "react";
import {
envOnPremiseFleet,
// envOnPremiseFleet,
envOnPremiseRobot,
} from "../../helpers/envProvider";
import SidebarStaticItem from "../SidebarStaticItem/SidebarStaticItem";
Expand Down Expand Up @@ -96,12 +96,12 @@ export default function PrivateSidebar(): ReactElement {
</Fragment>
) : (
<Fragment>
{!(envOnPremiseFleet || envOnPremiseRobot) && (
{/* {!(envOnPremiseFleet || envOnPremiseRobot) && (
<SidebarStaticItem
to="/marketplace"
imgSrc={`/svg/general/marketplace/marketplace-gray.svg`}
/>
)}
)} */}
<SideBarMenuItem
type="organization"
description="You can access all your organizations here."
Expand Down
1 change: 1 addition & 0 deletions src/components/SidebarMenuItem/SideBarMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export default function SideBarMenuItem({

return (
<div
data-tut={type + "-sidebar-menu-item"}
onClick={() => !loading && !disabled && handleClick()}
className={`${activeSwitcher()} relative transition-500 p-2 rounded-md cursor-pointer hover:scale-90 select-none animate__animated animate__fadeInLeft ${
(loading || disabled) && "!cursor-not-allowed"
Expand Down
19 changes: 15 additions & 4 deletions src/components/SidebarStaticItem/SidebarStaticItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { ReactElement, useState } from "react";
import { Link, useLocation } from "react-router-dom";
import SidebarMenuItemToolTip from "../SidebarMenuItemToolTip/SidebarMenuItemToolTip";
import { useLocation, useNavigate } from "react-router-dom";

interface ISidebarStaticItem {
to: string;
Expand All @@ -15,15 +15,26 @@ export default function SidebarStaticItem({

const location = useLocation();

const navigate = useNavigate();

return (
<Link
to={to}
<div
className={`transition-all duration-500 p-2 rounded-md cursor-pointer hover:scale-90 animate__animated animate__fadeInLeft relative select-none ${
location?.pathname?.includes(to) &&
"bg-layer-light-100 transition-all duration-500"
}`}
onClick={() => navigate(to)}
onMouseEnter={() => setIsHover(true)}
onMouseLeave={() => setIsHover(false)}
data-tut={
to === "/marketplace"
? "marketplace-sidebar-menu-item"
: to === "/billing"
? "billing-sidebar-menu-item"
: to === "/user-role-management"
? "user-role-management-sidebar-menu-item"
: "item"
}
>
<img
draggable="false"
Expand Down Expand Up @@ -53,6 +64,6 @@ export default function SidebarStaticItem({
}
/>
)}
</Link>
</div>
);
}
1 change: 1 addition & 0 deletions src/components/Table/GeneralTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function GeneralTable({
}: IGeneralTable): ReactElement {
return (
<div
data-tut="general-table"
className="flex flex-col pt-4 px-4 pb-0 rounded-lg shadow-lg bg-layer-light-50 animate__animated animate__fadeIn border border-layer-light-200"
style={loading ? { backgroundColor: "rgba(0, 0, 0, 0.4)" } : {}}
>
Expand Down
90 changes: 90 additions & 0 deletions src/components/TourGuide/TourGuide.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import React, { Fragment, ReactElement, useState } from "react";
import {
setIsShowedFleetGuide,
setIsShowedInstanceGuide,
setIsShowedMainGuide,
setIsShowedOrganizationGuide,
setIsShowedRoboticsCloudGuide,
} from "../../toolkit/GuideSlice";
import Button from "../Button/Button";
import { disableBodyScroll, enableBodyScroll } from "body-scroll-lock";
import { useAppDispatch, useAppSelector } from "../../hooks/redux";
import Tour from "reactour";

interface ITourGuide {
type: "main" | "organization" | "roboticscloud" | "instance" | "fleet";
tourConfig: any[];
}

export default function TourGuide({
type,
tourConfig,
}: ITourGuide): ReactElement {
const [isTourOpen, setIsTourOpen] = useState<boolean>(false);

const dispatch = useAppDispatch();
const {
isShowedMainGuide,
isShowedOrganizationGuide,
isShowedRoboticsCloudGuide,
isShowedInstanceGuide,
isShowedFleetGuide,
} = useAppSelector((state) => state.guide);

const handleIsOpen = () => {
switch (type) {
case "main":
return !isShowedMainGuide || isTourOpen;
case "organization":
return !isShowedOrganizationGuide || isTourOpen;
case "roboticscloud":
return !isShowedRoboticsCloudGuide || isTourOpen;
case "instance":
return !isShowedInstanceGuide || isTourOpen;
case "fleet":
return !isShowedFleetGuide || isTourOpen;
default:
return isTourOpen;
}
};

function handleCloseGuide() {
setIsTourOpen(false);

switch (type) {
case "main":
return dispatch(setIsShowedMainGuide());
case "organization":
return dispatch(setIsShowedOrganizationGuide());
case "roboticscloud":
return dispatch(setIsShowedRoboticsCloudGuide());
case "instance":
return dispatch(setIsShowedInstanceGuide());
case "fleet":
return dispatch(setIsShowedFleetGuide());
}
}

return (
<Fragment>
<Button
text="Show Guide"
className="!w-48 !h-10 !text-xs"
onClick={() => {
setIsTourOpen(true);
}}
/>
<Tour
onRequestClose={handleCloseGuide}
steps={tourConfig}
isOpen={handleIsOpen()}
maskClassName="opacity-50"
className="!p-10 text-sm"
rounded={5}
accentColor={"#ac2dfe"}
onAfterOpen={(target: any) => disableBodyScroll(target)}
onBeforeClose={(target: any) => enableBodyScroll(target)}
/>
</Fragment>
);
}
1 change: 1 addition & 0 deletions src/components/UsagesWidget/UsagesWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function UsagesWidget({
}: IUsagesWidget): ReactElement {
return (
<Widget
dataTut="usages-widget"
title={`Hardware Resources & Usages`}
subtitle={`${title} Usages`}
icon={<GoGraph size={20} className="text-layer-light-700" />}
Expand Down
Loading

0 comments on commit 4d74786

Please sign in to comment.