Skip to content

Commit

Permalink
fix: fix sidebar style (#68)
Browse files Browse the repository at this point in the history
Because

- Sidebar style is not correct

This commit

- Fix sidebar style and add multiple hovered color
  • Loading branch information
EiffelFly committed Jun 28, 2022
1 parent 96dd22e commit 63d2463
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 83 deletions.
2 changes: 1 addition & 1 deletion src/components/forms/OnboardingForm/OnboardingForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ const OnboardingForm: FC<OnBoardingFormProps> = ({ user }) => {
position="ml-auto"
onClickHandler={null}
>
Start
Start
</PrimaryButton>
</FormBase>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,14 @@ const DeleteResourceModal: FC<DeleteResourceModalProps> = ({
disabled={false}
disabledBgColor="bg-instillGrey15"
bgColor="bg-white"
hoveredBgColor="hover:bg-instillGrey50"
disabledTextColor="text-instillGrey50"
textColor="text-instillGrey50"
hoveredTextColor="hover:text-instillGrey05"
width="w-full"
borderSize="border"
borderColor="border-instillGrey50"
hoveredBorderColor={null}
disabledBorderColor={null}
onClickHandler={() => setModalIsOpen(false)}
position={null}
Expand All @@ -161,13 +164,16 @@ const DeleteResourceModal: FC<DeleteResourceModalProps> = ({
disabled={canDeleteResource ? false : true}
disabledBgColor="bg-instillGrey15"
bgColor="bg-white"
hoveredBgColor="hover:bg-instillRed"
disabledTextColor="text-instillGrey30"
textColor={
canDeleteResource ? "text-instillRed" : "text-instillGrey50"
}
hoveredTextColor="hover:text-instillRed10"
width="w-full"
borderSize={canDeleteResource ? "border" : null}
borderColor="border-instillRed"
hoveredBorderColor={null}
disabledBorderColor={null}
onClickHandler={handleDeleteResource}
position={null}
Expand Down
17 changes: 15 additions & 2 deletions src/components/ui/Buttons/ButtonBase/ButtonBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ export type ButtonBaseProps = {
disabled: boolean;
onClickHandler: Nullable<(values?: any) => any>;
bgColor: Nullable<string>;
hoveredBgColor: Nullable<string>;
disabledBgColor: Nullable<string>;
textColor: Nullable<string>;
hoveredTextColor: Nullable<string>;
disabledTextColor: Nullable<string>;
borderSize: Nullable<string>;
borderColor: Nullable<string>;
hoveredBorderColor: Nullable<string>;
disabledBorderColor: Nullable<string>;
position: Nullable<string>;
dataFlag?: Nullable<string | number>;
Expand All @@ -21,10 +24,12 @@ export type ButtonBaseProps = {

const ButtonBase: FC<ButtonBaseProps> = ({
bgColor,
hoveredBgColor,
disabled,
disabledBgColor,
disabledTextColor,
textColor,
hoveredTextColor,
onClickHandler,
position,
type,
Expand All @@ -34,6 +39,7 @@ const ButtonBase: FC<ButtonBaseProps> = ({
width,
borderSize,
borderColor,
hoveredBorderColor,
disabledBorderColor,
}) => {
return (
Expand All @@ -43,11 +49,18 @@ const ButtonBase: FC<ButtonBaseProps> = ({
type={type}
data-flag={dataFlag}
className={cn(
"rounded-[1px]",
"group rounded-[1px]",
borderSize,
disabled
? cn(disabledBgColor, disabledTextColor, disabledBorderColor)
: cn(bgColor, textColor, borderColor),
: cn(
bgColor,
hoveredBgColor,
textColor,
hoveredTextColor,
borderColor,
hoveredBorderColor
),
position,
padding,
width
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export type CollapseSidebarButtonProps = Omit<
| "borderSize"
| "borderColor"
| "disabledBorderColor"
| "hoveredBgColor"
| "hoveredTextColor"
| "hoveredBorderColor"
> & {
isCollapse: boolean;
};
Expand All @@ -29,25 +32,28 @@ const CollapseSidebarButton: FC<CollapseSidebarButtonProps> = (props) => {
borderSize={null}
borderColor={null}
disabledBorderColor={null}
hoveredBorderColor={null}
bgColor="bg-instillGrey90"
textColor="text-instillGrey05"
hoveredBgColor="hover:bg-instillGrey80"
textColor={null}
hoveredTextColor={null}
disabledBgColor="bg-instillGrey90"
disabledTextColor="text-instillGrey50"
disabledTextColor={null}
padding="p-[3px]"
>
{props.isCollapse ? (
<CollapseRightIcon
width="w-[14px]"
height="h-[14px]"
position="m-auto"
color="fill-instillGrey05"
color="fill-instillGrey05 group-hover:fill-instillBlue50"
/>
) : (
<CollapseLeftIcon
width="w-[14px]"
height="h-[14px]"
position="m-auto"
color="fill-instillGrey05"
color="fill-instillGrey05 group-hover:fill-instillBlue50"
/>
)}
</ButtonBase>
Expand Down
3 changes: 3 additions & 0 deletions src/components/ui/Buttons/OutlineButton/OutlineButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const OutlineButton: FC<OutlineButtonProps> = (props) => {
borderSize={props.borderSize}
borderColor={props.borderColor}
disabledBorderColor={props.disabledBorderColor}
hoveredBgColor={props.hoveredBgColor}
hoveredBorderColor={props.hoveredBorderColor}
hoveredTextColor={props.hoveredTextColor}
padding="px-5 py-2.5"
>
{props.children}
Expand Down
6 changes: 6 additions & 0 deletions src/components/ui/Buttons/PrimaryButton/PrimaryButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export type PrimaryButtonProps = Omit<
| "borderSize"
| "borderColor"
| "disabledBorderColor"
| "hoveredBgColor"
| "hoveredTextColor"
| "hoveredBorderColor"
>;

const PrimaryButton: FC<PrimaryButtonProps> = (props) => {
Expand All @@ -25,9 +28,12 @@ const PrimaryButton: FC<PrimaryButtonProps> = (props) => {
width={null}
borderSize={null}
borderColor={null}
hoveredBorderColor={null}
disabledBorderColor={null}
bgColor="bg-instillBlue50"
hoveredBgColor="hover:bg-instillBlue80"
textColor="text-instillGrey05"
hoveredTextColor="hover:text-instillBlue10"
disabledBgColor="bg-instillGrey15"
disabledTextColor="text-instillGrey50"
padding="px-5 py-2.5"
Expand Down
86 changes: 20 additions & 66 deletions src/components/ui/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,101 +1,45 @@
import { FC, useCallback, useState } from "react";
import {
DataDestinationIcon,
DataSourceIcon,
GearIcon,
Logo,
ModelIcon,
PipelineIcon,
ResourceIcon,
} from "@instill-ai/design-system";
import Tab from "./Tab";
import { Logo } from "@instill-ai/design-system";
import Tab, { TabProps } from "./Tab";
import { CollapseSidebarButton } from "../Buttons";
import { useRouter } from "next/router";

type Tab = Omit<TabProps, "isCollapsed" | "isCurrent"> & { id: string };

const Sidebar: FC = () => {
const router = useRouter();
const [isCollapsed, setIsCollapsed] = useState(false);
const iconColor = "fill-instillGrey30";
const iconWidth = "w-[38px]";
const iconHeight = "h-[38px]";
const iconPosition = isCollapsed ? "my-auto" : "my-auto";

const tabs = [
const tabs: Tab[] = [
{
icon: (
<PipelineIcon
color={iconColor}
width={iconWidth}
height={iconHeight}
position={iconPosition}
/>
),
id: "sidebar-pipleine",
tabName: "Pipeline",
link: "/pipelines",
},
{
icon: (
<DataSourceIcon
color={iconColor}
width={iconWidth}
height={iconHeight}
position={iconPosition}
/>
),
id: "sidebar-data-source",
tabName: "Data source",
link: "/sources",
},
{
icon: (
<ModelIcon
color={iconColor}
width={iconWidth}
height={iconHeight}
position={iconPosition}
/>
),
id: "sidebar-model",
tabName: "Model",
link: "/models",
},
{
icon: (
<DataDestinationIcon
color={iconColor}
width={iconWidth}
height={iconHeight}
position={iconPosition}
/>
),
id: "sidebar-data-destination",
tabName: "Data destination",
link: "/destinations",
},
];

const subTabs = [
const subTabs: Tab[] = [
{
icon: (
<GearIcon
color={iconColor}
width={iconWidth}
height={iconHeight}
position={iconPosition}
/>
),
id: "sidebar-setting",
tabName: "Setting",
link: "/setting",
},
{
icon: (
<ResourceIcon
color={iconColor}
width={iconWidth}
height={iconHeight}
position={iconPosition}
/>
),
id: "sidebar-resources",
tabName: "Resources",
link: "/resources",
Expand All @@ -106,6 +50,16 @@ const Sidebar: FC = () => {
setIsCollapsed((prev) => !prev);
}, []);

const determineCurrentTab = useCallback(
(link: string) => {
if (router.asPath === link) {
return true;
}
return false;
},
[router.asPath]
);

return (
<div className="sticky top-0 flex h-screen flex-col bg-instillGrey90 pb-5">
<div className="relative mb-20 py-6">
Expand Down Expand Up @@ -133,8 +87,8 @@ const Sidebar: FC = () => {
key={tab.id}
tabName={tab.tabName}
link={tab.link}
icon={tab.icon}
isCollapsed={isCollapsed}
isCurrent={determineCurrentTab(tab.link)}
/>
))}
</div>
Expand All @@ -144,8 +98,8 @@ const Sidebar: FC = () => {
key={tab.id}
tabName={tab.tabName}
link={tab.link}
icon={tab.icon}
isCollapsed={isCollapsed}
isCurrent={determineCurrentTab(tab.link)}
/>
))}
</div>
Expand Down
Loading

0 comments on commit 63d2463

Please sign in to comment.