MCPcopy Create free account
hub / github.com/WardAnalytics/WardGraph / SavedGraphs

Function SavedGraphs

src/components/navbar/Navbar.tsx:117–169  ·  view source on GitHub ↗
({ userID })

Source from the content-addressed store, hash-verified

115}
116
117const SavedGraphs: FC<SavedGraphsProps> = ({ userID }) => {
118 const [isCreateGraphDialogOpen, setIsCreateGraphDialogOpen] = useState(false);
119
120 const { graphs } = usePersonalGraphs(userID ? userID : "");
121 const { displayedGraphs } = useMemo(() => {
122 return {
123 displayedGraphs: graphs.slice(0, SAVED_GRAPHS_LIMIT),
124 };
125 }, [graphs]);
126
127 return (
128 <>
129 <div className="flex flex-col gap-x-2.5 pl-[0.8rem]">
130 {displayedGraphs.map((graph, index) => (
131 <Transition
132 key={graph.uid}
133 show={true}
134 appear={true}
135 enter="transition-all duration-300"
136 enterFrom="opacity-0 -translate-y-5"
137 enterTo="opacity-100 translate-y-0"
138 style={{
139 transitionDelay: `${index * 50}ms`,
140 }}
141 >
142 <SavedGraphRow
143 name={graph.name}
144 href={getGraphHref(graph)}
145 isLast={index === displayedGraphs.length - 1}
146 />
147 </Transition>
148 ))}
149 <button
150 key="New Graph"
151 onClick={() => setIsCreateGraphDialogOpen(true)}
152 className="group -mb-10 flex h-10 cursor-pointer flex-row items-center gap-x-4 text-xs font-semibold text-gray-500 transition-all duration-150 hover:gap-x-[1.1rem] hover:text-gray-700"
153 >
154 <div className="mb-1 h-1/2 w-[1.5px] -translate-y-1/2 bg-gray-300" />
155 <PlusCircleIcon
156 className="absolute h-5 w-5 -translate-x-[0.6rem] rounded-full bg-white p-[0.06rem] text-gray-400 ring-[1.5px] ring-gray-300 transition-all duration-150 group-hover:text-gray-500"
157 aria-hidden="true"
158 />
159 New Graph
160 </button>
161 </div>
162 <CreateGraphDialog
163 isOpen={isCreateGraphDialogOpen}
164 setOpen={setIsCreateGraphDialogOpen}
165 graphInfo={NEW_GRAPH_INFO}
166 />
167 </>
168 );
169};
170
171const SavedGraphRow: FC<SavedGraphRowProps> = ({ name, href }) => {
172 const navigate = useNavigate();

Callers

nothing calls this directly

Calls 2

usePersonalGraphsFunction · 0.90
getGraphHrefFunction · 0.90

Tested by

no test coverage detected