Skip to content
Draft

Tour #1960

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@sentry/nextjs": "^10.52.0",
"allotment": "^1.20.3",
"ansi-to-react": "^6.1.6",
"boarding.js": "^3.7.3",
"clsx": "^2.1.1",
"codemirror": "^6.0.1",
"dotenv": "^16.4.5",
Expand Down
120 changes: 120 additions & 0 deletions frontend/src/app/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,123 @@ body.no-scroll {
height: 100svh;
}
}

.scratch-tour-click-target {
position: relative;
isolation: isolate;
border-radius: 6px;
animation: scratch-tour-click-target-pulse 1.2s ease-out infinite;
}

@keyframes scratch-tour-click-target-pulse {
0% {
box-shadow: 0 0 0 0 rgb(192 88 255 / 60%);
}

70% {
box-shadow: 0 0 0 10px rgb(192 88 255 / 0%);
}

100% {
box-shadow: 0 0 0 0 rgb(192 88 255 / 0%);
}
}

@media (prefers-reduced-motion: reduce) {
.scratch-tour-click-target {
animation: none;
box-shadow: 0 0 0 3px rgb(192 88 255 / 60%);
}
}

#boarding-popover-item.scratch-tour-popover {
width: min(22rem, calc(100vw - 2rem));
border: 1px solid var(--g600);
border-radius: 8px;
background: var(--g200);
box-shadow: 0 18px 48px rgb(0 0 0 / 35%);
color: var(--g1700);

.boarding-popover-title {
margin-bottom: 0.45rem;
font-weight: 700;
font-size: 0.95rem;
line-height: 1.2;
}

.boarding-popover-description {
color: var(--g1200);
font-size: 0.875rem;
line-height: 1.35;

strong {
color: var(--g1700);
font-weight: 700;
}

a {
color: var(--link);
text-decoration: underline;
}

a:hover {
color: var(--g1700);
}
}

.boarding-popover-footer {
display: flex !important;
align-items: center;
justify-content: space-between;
gap: 0.75rem;
margin-top: 1rem;
}

.boarding-navigation-btns {
display: flex;
align-items: center;
gap: 0.5rem;
margin-left: auto;
}

button {
display: inline-flex;
min-height: 2rem;
align-items: center;
justify-content: center;
border: 1px solid var(--g700);
border-radius: 6px;
background: var(--g400);
padding: 0.35rem 0.65rem;
color: var(--g1700);
font-weight: 600;
font-size: 0.8125rem;
line-height: 1;
white-space: nowrap;
cursor: pointer;
}

button:hover {
background: var(--a600);
}

.boarding-next-btn {
border-color: var(--a900);
background: var(--a400);
color: white;
}

.boarding-next-btn:hover {
background: var(--a600);
}

.boarding-disabled {
opacity: 0.45;
cursor: default;
pointer-events: none;
}

.boarding-popover-tip {
border-color: var(--g200);
}
}
1 change: 1 addition & 0 deletions frontend/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ThemeProvider from "./ThemeProvider";

import "allotment/dist/style.css";
import "boarding.js/styles/main.css";
import "./globals.scss";

export const metadata = {
Expand Down
21 changes: 16 additions & 5 deletions frontend/src/components/CustomLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,22 @@ export default function CustomLayout({ renderTab, layout, onChange }: Props) {

els.push(
<Allotment.Pane key={child.key} minSize={minCollapsedHeight}>
<CustomLayout
renderTab={renderTab}
layout={child}
onChange={setChild}
/>
<div
className="size-full min-h-0"
data-tour={
child.key === 1
? "scratch-layout-left"
: child.key === 2
? "scratch-layout-right"
: undefined
}
>
<CustomLayout
renderTab={renderTab}
layout={child}
onChange={setChild}
/>
</div>
</Allotment.Pane>,
);
}
Expand Down
23 changes: 23 additions & 0 deletions frontend/src/components/Diff/Diff.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,29 @@
}
}

.columnTourTarget {
position: absolute;
top: 0;
bottom: 0;
z-index: 1;
pointer-events: none;
}

.columnTourTarget-base {
left: 0;
width: var(--diff-left-width);
}

.columnTourTarget-current {
left: var(--diff-left-width);
right: var(--diff-right-width);
}

.columnTourTarget-previous {
right: 0;
width: var(--diff-right-width);
}

.searchPanel {
position: absolute;
z-index: 120;
Expand Down
88 changes: 56 additions & 32 deletions frontend/src/components/Diff/Diff.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from "react";

import { FoldIcon, SearchIcon } from "@primer/octicons-react";
import clsx from "clsx";
import AutoSizer from "react-virtualized-auto-sizer";
import { FixedSizeList } from "react-window";
import { useDebounce } from "use-debounce";
Expand Down Expand Up @@ -479,9 +480,23 @@ export default function Diff({
>
{columnCount >= 2 && <DragBar pos={bar1Px} onChange={setBar1Px} />}
{columnCount === 3 && <DragBar pos={bar2Px} onChange={setBar2Px} />}
{columns.map((col) => (
<div
key={col}
className={clsx(
styles.columnTourTarget,
styles[`columnTourTarget-${col}`],
)}
data-tour={`scratch-diff-column-${col}-full`}
/>
))}
<div className={styles.headers}>
{columns.map((col) => (
<div key={col} className={styles.header}>
<div
key={col}
className={styles.header}
data-tour={`scratch-diff-column-${col}`}
>
{COLUMN_LABELS[col]}
<CopyButton
title="Copy content"
Expand All @@ -508,37 +523,46 @@ export default function Diff({
{col === rightmostColumn && (
<>
<div className={styles.spacer} />
<ToggleButton
label="T"
title="Target column"
enabled={columnState.base}
setEnabled={(enabled) =>
setColumn("base", enabled)
}
/>
<ToggleButton
label="C"
title="Current column"
enabled={columnState.current}
setEnabled={(enabled) =>
setColumn("current", enabled)
}
/>
<ToggleButton
label="3"
title="3-way diff"
enabled={threeWayDiffEnabled}
setEnabled={handleSetThreeWayDiff}
/>
<ToggleButton
label={<FoldIcon size={16} />}
disabledLabel="Collapse streaks of "
enabledLabel="Show all "
title="matching lines"
padding="px-1 py-1"
enabled={compressionEnabled}
setEnabled={setCompressionEnabled}
/>
<div
className="flex items-center gap-1"
data-tour="scratch-diff-toggles"
>
<ToggleButton
label="T"
title="Target column"
enabled={columnState.base}
setEnabled={(enabled) =>
setColumn("base", enabled)
}
dataTour="scratch-diff-toggle-target"
/>
<ToggleButton
label="C"
title="Current column"
enabled={columnState.current}
setEnabled={(enabled) =>
setColumn("current", enabled)
}
dataTour="scratch-diff-toggle-current"
/>
<ToggleButton
label="3"
title="3-way diff"
enabled={threeWayDiffEnabled}
setEnabled={handleSetThreeWayDiff}
dataTour="scratch-diff-toggle-three-way"
/>
<ToggleButton
label={<FoldIcon size={16} />}
disabledLabel="Collapse streaks of "
enabledLabel="Show all "
title="matching lines"
padding="px-1 py-1"
enabled={compressionEnabled}
setEnabled={setCompressionEnabled}
dataTour="scratch-diff-toggle-compression"
/>
</div>
</>
)}
</div>
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/Diff/ToggleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ type ToggleButtonProps = {
disabledLabel?: string;
enabledLabel?: string;
padding?: string;
dataTour?: string;
};

export default function ToggleButton({
Expand All @@ -19,6 +20,7 @@ export default function ToggleButton({
disabledLabel = "Show ",
enabledLabel = "Hide ",
padding = "px-2 py-1",
dataTour,
}: ToggleButtonProps) {
return (
<button
Expand All @@ -31,6 +33,7 @@ export default function ToggleButton({
? `${enabled ? enabledLabel : disabledLabel}${title}`
: undefined
}
data-tour={dataTour}
className={clsx(
padding,
"text-md",
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/Editor/CodeMirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export interface Props {
viewRef?: RefObject<EditorView | null>;
extensions: Extension; // const
placeholder?: string;
dataTour?: string;
}

export default function CodeMirror({
Expand All @@ -70,6 +71,7 @@ export default function CodeMirror({
viewRef: viewRefProp,
extensions,
placeholder: placeholderText,
dataTour,
}: Props) {
const { ref: el, width } = useSize<HTMLDivElement>();

Expand Down Expand Up @@ -204,6 +206,7 @@ export default function CodeMirror({
ref={el}
onMouseMove={debouncedOnMouseMove}
className={clsx(styles.container, className)}
data-tour={dataTour}
style={
{
"--cm-font-size": `${fontSize}px`,
Expand Down
Loading