Skip to content

Commit 8a0d296

Browse files
committed
hide config panel initially
1 parent 4a3de58 commit 8a0d296

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

src/lib/context.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createContext } from "react";
1+
import { Dispatch, SetStateAction, createContext } from "react";
22
import Sigma from "sigma";
33

44
import { ModalName } from "../views/modals";
@@ -25,6 +25,9 @@ type GraphContextType = {
2525
isPanelExpanded: boolean;
2626
setIsPanelExpanded: (isPanelExpanded: boolean) => void;
2727

28+
showEditionPanel: boolean;
29+
setShowEditionPanel: Dispatch<SetStateAction<boolean>>;
30+
2831
navState: NavState;
2932
computedData: ComputedData;
3033
hovered: string | Set<string> | undefined;
@@ -45,5 +48,5 @@ type GraphContextType = {
4548
};
4649
export const GraphContext = createContext<GraphContextType>(
4750
// "Fake" initial value (proper value will be given by Provider)
48-
null as unknown as GraphContextType,
51+
null as unknown as GraphContextType
4952
);

src/views/EditionPanel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ interface Option {
5656
}
5757

5858
const EditionPanel: FC<{ isExpanded: boolean }> = ({ isExpanded }) => {
59-
const { navState, data, setNavState, openModal, setPanel } = useContext(GraphContext);
59+
const { navState, data, setNavState, openModal, setPanel, setShowEditionPanel } = useContext(GraphContext);
6060
const { fields, fieldsIndex } = data;
6161
const { filterable, colorable, sizeable, subtitleFields } = navState;
6262

@@ -106,6 +106,7 @@ const EditionPanel: FC<{ isExpanded: boolean }> = ({ isExpanded }) => {
106106
style={{ top: 15, right: 15 }}
107107
onClick={() => {
108108
setNavState({ ...navState, role: "x" });
109+
setShowEditionPanel(false); // Add this line to hide the panel
109110
}}
110111
>
111112
<FaTimes />

src/views/GraphView.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ const GraphView: FC<{ embed?: boolean }> = ({ embed = false }) => {
7575
(newNavState: NavState) => {
7676
navigate(
7777
location.hash.replace(/^#/, "").replace(/\?.*/, "") +
78-
"?" +
79-
navStateToQueryURL(data ? cleanNavState(newNavState, data) : newNavState),
78+
"?" +
79+
navStateToQueryURL(data ? cleanNavState(newNavState, data) : newNavState),
8080
);
8181
},
8282
[data, location.hash, navigate],
@@ -88,6 +88,7 @@ const GraphView: FC<{ embed?: boolean }> = ({ embed = false }) => {
8888

8989
const [computedData, setComputedData] = useState<ComputedData | null>(null);
9090

91+
const [showEditionPanel, setShowEditionPanel] = useState(false); // Add this state
9192
// Refresh aggregations and filtered items lists:
9293
useEffect(() => {
9394
if (data) {
@@ -165,10 +166,10 @@ const GraphView: FC<{ embed?: boolean }> = ({ embed = false }) => {
165166

166167
let promise:
167168
| Promise<{
168-
name: string;
169-
extension: string;
170-
textContent: string;
171-
}>
169+
name: string;
170+
extension: string;
171+
textContent: string;
172+
}>
172173
| undefined;
173174

174175
if (!url && !local) {
@@ -267,6 +268,9 @@ const GraphView: FC<{ embed?: boolean }> = ({ embed = false }) => {
267268
isPanelExpanded,
268269
setIsPanelExpanded,
269270

271+
showEditionPanel,
272+
setShowEditionPanel,
273+
270274
modal: modalName,
271275
openModal: (modal: ModalName) => setModalName(modal),
272276
closeModal: () => setModalName(undefined),
@@ -280,7 +284,7 @@ const GraphView: FC<{ embed?: boolean }> = ({ embed = false }) => {
280284
}}
281285
>
282286
{navState.local && <LocalWarningBanner />}
283-
<EditionPanel isExpanded={(navState.role || DEFAULT_ROLE) === "d"} />
287+
{showEditionPanel && <EditionPanel isExpanded={true} />}
284288
<main className={cx("graph-view", isPanelExpanded ? "panel-expanded" : "panel-collapsed")} ref={domRoot}>
285289
<div className="wrapper">
286290
<ContextPanel />

src/views/ReadabilityBlock.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ import { GraphContext } from "../lib/context";
2727
import { NavState } from "../lib/navState";
2828

2929
const ReadabilityBlock: FC = () => {
30-
const { navState, setNavState } = useContext(GraphContext);
31-
30+
// const { navState, setNavState } = useContext(GraphContext);
31+
const { navState, setNavState, showEditionPanel, setShowEditionPanel } = useContext(GraphContext);
3232
const [initialNavState] = useState<NavState>(navState);
3333

3434
const minLabelSize = typeof navState.minLabelSize === "number" ? navState.minLabelSize : DEFAULT_LABEL_SIZE;
@@ -63,14 +63,17 @@ const ReadabilityBlock: FC = () => {
6363
type="button"
6464
className="btn btn-outline-dark flex-grow-1"
6565
disabled={navState.role === "d"}
66-
onClick={() =>
66+
onClick={() => {
67+
// Toggle the edition panel
68+
setShowEditionPanel(!showEditionPanel);
69+
// Also set the role if needed
6770
setNavState({
6871
...navState,
6972
role: "d",
70-
})
71-
}
73+
});
74+
}}
7275
>
73-
<FaGear /> Configure this graph for Retina
76+
<FaGear /> Configure this graph for DeepGit
7477
</button>
7578
)}
7679
</div>

src/views/modals/PublishModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const PublishModal: FC<{ close: () => void }> = ({ close }) => {
7272
}}
7373
>
7474
<p>
75-
To be able to <strong>share</strong> your visualizations online, Retina needs to be able to access your graph
75+
To be able to <strong>share</strong> your visualizations online, DeepGit needs to be able to access your graph
7676
file <strong>online</strong>, through HTTP. You can publish it on a server or your own, a cloud provider...
7777
</p>
7878

@@ -81,7 +81,7 @@ const PublishModal: FC<{ close: () => void }> = ({ close }) => {
8181
<a href="https://gist.github.com/" target="_blank" rel="noreferrer">
8282
GitHub Gist
8383
</a>
84-
, a site where you can freely upload your graph for Retina:
84+
, a site where you can freely upload your graph for DeepGit:
8585
</p>
8686

8787
<ol>

0 commit comments

Comments
 (0)