Skip to content

Commit

Permalink
Remove Attention after first render, jump to def cursor, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinleroy committed Aug 11, 2024
1 parent 1a680ed commit 12f7c75
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 23 deletions.
1 change: 1 addition & 0 deletions ide/packages/panoptes/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@
.DefinitionWrapper.hovered.meta-pressed {
color: var(--vscode-editorLink-activeForeground);
text-decoration: underline;
cursor: pointer;
}
13 changes: 5 additions & 8 deletions ide/packages/panoptes/src/TreeView/Directory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,12 @@ export const DirNode = ({
<Node node={node} />
</span>
);
const info = (
<WrapNode wrappers={Wrappers ?? []} n={idx}>
{infoChild}
</WrapNode>
);

const info =
Wrappers === undefined ? (
infoChild
) : (
<WrapNode wrappers={Wrappers} n={idx}>
{infoChild}
</WrapNode>
);
const startOpen = startOpenP ? startOpenP(idx) : false;

return (
Expand Down
9 changes: 8 additions & 1 deletion ide/packages/panoptes/src/TreeView/Wrappers.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@
}

.WrapperBox {
display: inline-flex;
display: none;
padding-left: 0.5em;

flex-direction: row;
justify-content: space-evenly;
align-items: center;
gap: 0.25em;
}

.WrapperBox.is-hovered {
display: inline-flex;
}

.WrapperBox i:hover {
cursor: pointer;
color: var(--vscode-input-placeholderForeground);
Expand Down
24 changes: 13 additions & 11 deletions ide/packages/panoptes/src/TreeView/Wrappers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,27 @@ export const WrapNode = ({
}: React.PropsWithChildren<{ wrappers: InfoWrapper[]; n: ProofNodeIdx }>) => {
const [hovered, setHovered] = useState(false);
const [actives, setActives] = useState(Array(wrappers.length).fill(false));

const active = _.some(actives);
const className = classNames("WrapperBox", {
"is-hovered": hovered || active
});

return (
<span
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
>
{children}
{(hovered || active) && (
<span className="WrapperBox">
{_.map(wrappers, (W, i) => (
<W
key={i}
n={n}
reportActive={b => setActives(a => arrUpdate(a, i, b))}
/>
))}
</span>
)}
<span className={className}>
{_.map(wrappers, (W, i) => (
<W
key={i}
n={n}
reportActive={b => setActives(a => arrUpdate(a, i, b))}
/>
))}
</span>
</span>
);
};
Expand Down
25 changes: 22 additions & 3 deletions ide/packages/print/src/Attention.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
import React from "react";
import React, { useEffect, useRef } from "react";

import "./Attention.css";

const DURATION = 1_000;
const CN = "Attention";

const Attn = ({
children,
className = CN
}: React.PropsWithChildren<{ className?: string }>) => {
const ref = useRef<HTMLSpanElement>(null);
useEffect(() => {
setTimeout(() => ref.current?.classList.remove(className), DURATION);
}, []);

return (
<span ref={ref} className={className}>
{children}
</span>
);
};

export const TextEmphasis = ({ children }: React.PropsWithChildren) => (
<span className="AttentionText">{children}</span>
<Attn className="AttentionText">{children}</Attn>
);

const Attention = ({ children }: React.PropsWithChildren) => (
<span className="Attention">{children}</span>
<Attn>{children}</Attn>
);

export default Attention;

0 comments on commit 12f7c75

Please sign in to comment.