fix: minor ui fixes

This commit is contained in:
sriram veeraghanta 2023-09-28 13:28:24 +05:30
parent ccf6bd4e32
commit b2d17e6ec9
5 changed files with 22 additions and 51 deletions

View File

@ -25,17 +25,12 @@ const tabOptions = [
}, },
]; ];
const EmojiIconPicker: React.FC<Props> = ({ const EmojiIconPicker: React.FC<Props> = (props) => {
label, const { label, value, onChange, onIconColorChange, disabled = false } = props;
value, // states
onChange,
onIconColorChange,
disabled = false,
}) => {
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
const [openColorPicker, setOpenColorPicker] = useState(false); const [openColorPicker, setOpenColorPicker] = useState(false);
const [activeColor, setActiveColor] = useState<string>("rgb(var(--color-text-200))"); const [activeColor, setActiveColor] = useState<string>("rgb(var(--color-text-200))");
const [recentEmojis, setRecentEmojis] = useState<string[]>([]); const [recentEmojis, setRecentEmojis] = useState<string[]>([]);
const emojiPickerRef = useRef<HTMLDivElement>(null); const emojiPickerRef = useRef<HTMLDivElement>(null);
@ -52,11 +47,7 @@ const EmojiIconPicker: React.FC<Props> = ({
return ( return (
<Popover className="relative z-[1]"> <Popover className="relative z-[1]">
<Popover.Button <Popover.Button onClick={() => setIsOpen((prev) => !prev)} className="outline-none" disabled={disabled}>
onClick={() => setIsOpen((prev) => !prev)}
className="outline-none"
disabled={disabled}
>
{label} {label}
</Popover.Button> </Popover.Button>
<Transition <Transition
@ -139,15 +130,7 @@ const EmojiIconPicker: React.FC<Props> = ({
<Tab.Panel className="flex h-full w-full flex-col justify-center"> <Tab.Panel className="flex h-full w-full flex-col justify-center">
<div className="relative"> <div className="relative">
<div className="flex items-center justify-between px-1 pb-2"> <div className="flex items-center justify-between px-1 pb-2">
{[ {["#FF6B00", "#8CC1FF", "#FCBE1D", "#18904F", "#ADF672", "#05C3FF", "#000000"].map((curCol) => (
"#FF6B00",
"#8CC1FF",
"#FCBE1D",
"#18904F",
"#ADF672",
"#05C3FF",
"#000000",
].map((curCol) => (
<span <span
key={curCol} key={curCol}
className="h-4 w-4 cursor-pointer rounded-full" className="h-4 w-4 cursor-pointer rounded-full"
@ -168,9 +151,7 @@ const EmojiIconPicker: React.FC<Props> = ({
</div> </div>
<div> <div>
<TwitterPicker <TwitterPicker
className={`!absolute top-4 left-4 z-10 m-2 ${ className={`!absolute top-4 left-4 z-10 m-2 ${openColorPicker ? "block" : "hidden"}`}
openColorPicker ? "block" : "hidden"
}`}
color={activeColor} color={activeColor}
onChange={(color) => { onChange={(color) => {
setActiveColor(color.hex); setActiveColor(color.hex);
@ -193,10 +174,7 @@ const EmojiIconPicker: React.FC<Props> = ({
setIsOpen(false); setIsOpen(false);
}} }}
> >
<span <span style={{ color: activeColor }} className="material-symbols-rounded text-lg">
style={{ color: activeColor }}
className="material-symbols-rounded text-lg"
>
{icon.name} {icon.name}
</span> </span>
</button> </button>

View File

@ -0,0 +1,2 @@
export * from "./modal";
export * from "./popover";

View File

@ -61,19 +61,17 @@ export const PublishProjectModal: React.FC<Props> = observer(() => {
if (typeof window !== "undefined" && !plane_deploy_url) { if (typeof window !== "undefined" && !plane_deploy_url) {
plane_deploy_url = window.location.protocol + "//" + window.location.host + "/spaces"; plane_deploy_url = window.location.protocol + "//" + window.location.host + "/spaces";
} }
// router
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug } = router.query;
// store
const store: RootStore = useMobxStore(); const store: RootStore = useMobxStore();
const { projectPublish } = store; const { projectPublish } = store;
// hooks
const { user } = useUser(); const { user } = useUser();
const { mutateProjectDetails } = useProjectDetails(); const { mutateProjectDetails } = useProjectDetails();
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
// form info
const { const {
control, control,
formState: { isSubmitting }, formState: { isSubmitting },
@ -87,7 +85,6 @@ export const PublishProjectModal: React.FC<Props> = observer(() => {
const handleClose = () => { const handleClose = () => {
projectPublish.handleProjectModal(null); projectPublish.handleProjectModal(null);
setIsUpdateRequired(false); setIsUpdateRequired(false);
reset({ ...defaultValues }); reset({ ...defaultValues });
}; };

View File

@ -16,11 +16,9 @@ import {
PhotoFilterOutlined, PhotoFilterOutlined,
SettingsOutlined, SettingsOutlined,
} from "@mui/icons-material"; } from "@mui/icons-material";
import { PenSquare } from "lucide-react";
// hooks // hooks
import useToast from "hooks/use-toast"; import useToast from "hooks/use-toast";
// ui
import { CustomMenu, Icon, Tooltip } from "components/ui";
import { PenSquare } from "lucide-react";
// helpers // helpers
import { renderEmoji } from "helpers/emoji.helper"; import { renderEmoji } from "helpers/emoji.helper";
// types // types
@ -29,7 +27,9 @@ import { IProject } from "types";
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
import { RootStore } from "store/root"; import { RootStore } from "store/root";
// components // components
import { CustomMenu, Icon, Tooltip } from "components/ui";
import { LeaveProjectModal, DeleteProjectModal } from "components/project"; import { LeaveProjectModal, DeleteProjectModal } from "components/project";
import { PublishProjectModal } from "components/project/publish-project";
type Props = { type Props = {
project: IProject; project: IProject;
@ -132,6 +132,7 @@ export const ProjectSidebarListItem: React.FC<Props> = observer((props) => {
return ( return (
<> <>
<PublishProjectModal />
<DeleteProjectModal project={project} isOpen={deleteProjectModalOpen} onClose={handleDeleteProjectModalClose} /> <DeleteProjectModal project={project} isOpen={deleteProjectModalOpen} onClose={handleDeleteProjectModalClose} />
<LeaveProjectModal project={project} isOpen={leaveProjectModalOpen} onClose={handleLeaveProjectModalClose} /> <LeaveProjectModal project={project} isOpen={leaveProjectModalOpen} onClose={handleLeaveProjectModalClose} />
<Disclosure key={project.id} defaultOpen={projectId === project.id}> <Disclosure key={project.id} defaultOpen={projectId === project.id}>

View File

@ -1,18 +1,15 @@
import React, { useState, FC, useRef, useEffect } from "react"; import React, { useState, FC, useRef, useEffect } from "react";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import useSWR, { mutate } from "swr"; import useSWR from "swr";
import { DragDropContext, Draggable, DropResult, Droppable } from "react-beautiful-dnd"; import { DragDropContext, Draggable, DropResult, Droppable } from "react-beautiful-dnd";
import { Disclosure, Transition } from "@headlessui/react"; import { Disclosure, Transition } from "@headlessui/react";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
// hooks // hooks
import useToast from "hooks/use-toast"; import useToast from "hooks/use-toast";
import useUserAuth from "hooks/use-user-auth"; import useUserAuth from "hooks/use-user-auth";
import useProjects from "hooks/use-projects";
// components // components
import { CreateProjectModal, ProjectSidebarListItem, LeaveProjectModal } from "components/project"; import { CreateProjectModal, ProjectSidebarListItem } from "components/project";
import { PublishProjectModal } from "components/project/publish-project/modal";
// services
import projectService from "services/project.service";
// icons // icons
import { Icon } from "components/ui"; import { Icon } from "components/ui";
import { PlusIcon } from "@heroicons/react/24/outline"; import { PlusIcon } from "@heroicons/react/24/outline";
@ -21,13 +18,11 @@ import { copyTextToClipboard } from "helpers/string.helper";
import { orderArrayBy } from "helpers/array.helper"; import { orderArrayBy } from "helpers/array.helper";
// types // types
import { IProject } from "types"; import { IProject } from "types";
// fetch-keys
import { PROJECTS_LIST } from "constants/fetch-keys";
// mobx store // mobx store
import { useMobxStore } from "lib/mobx/store-provider"; import { useMobxStore } from "lib/mobx/store-provider";
export const ProjectSidebarList: FC = observer(() => { export const ProjectSidebarList: FC = observer(() => {
const { theme: themeStore, workspace: workspaceStore, project: projectStore } = useMobxStore(); const { theme: themeStore, project: projectStore } = useMobxStore();
// router // router
const router = useRouter(); const router = useRouter();
const { workspaceSlug } = router.query; const { workspaceSlug } = router.query;
@ -80,7 +75,7 @@ export const ProjectSidebarList: FC = observer(() => {
projectStore projectStore
.updateProjectView(workspaceSlug.toString(), draggableId, { sort_order: updatedSortOrder }) .updateProjectView(workspaceSlug.toString(), draggableId, { sort_order: updatedSortOrder })
.catch((error) => { .catch(() => {
setToastAlert({ setToastAlert({
type: "error", type: "error",
title: "Error!", title: "Error!",
@ -118,8 +113,6 @@ export const ProjectSidebarList: FC = observer(() => {
setToFavorite={isFavoriteProjectCreate} setToFavorite={isFavoriteProjectCreate}
user={user} user={user}
/> />
{/* publish project modal */}
<PublishProjectModal />
<div <div
ref={containerRef} ref={containerRef}
className={`h-full overflow-y-auto px-4 space-y-3 pt-3 ${ className={`h-full overflow-y-auto px-4 space-y-3 pt-3 ${