Skip to content

Commit 34013c8

Browse files
committed
add collapsable toolbar
1 parent 7f91643 commit 34013c8

File tree

6 files changed

+326
-106
lines changed

6 files changed

+326
-106
lines changed

packages/scan/src/auto.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { IS_CLIENT } from '~web/utils/constants';
66
import { scan } from './index';
77

88
if (IS_CLIENT) {
9-
scan();
9+
scan({
10+
dangerouslyForceRunInProduction: true
11+
});
1012
window.reactScan = scan;
1113
}
1214

packages/scan/src/web/assets/css/styles.tailwind.css

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727

2828
&::-webkit-scrollbar-thumb:hover {
29-
background: rgba(255, 255, 255, .4);
29+
background: rgba(255, 255, 255, 0.4);
3030
}
3131

3232
&::-webkit-scrollbar-corner {
@@ -42,7 +42,6 @@
4242
}
4343
}
4444

45-
4645
button {
4746
@apply hover:bg-none;
4847
@apply outline-none;
@@ -112,9 +111,13 @@ svg {
112111
* text rendering. The new properties work together to force proper
113112
* GPU acceleration without z-index side effects:
114113
*/
115-
transform: translate3d(0, 0, 0); /* Forces GPU acceleration without causing stacking issues */
116-
backface-visibility: hidden; /* Prevents blurry text during transforms */
117-
perspective: 1000; /* Creates proper 3D context for crisp text */
114+
transform: translate3d(
115+
0,
116+
0,
117+
0
118+
); /* Forces GPU acceleration without causing stacking issues */
119+
backface-visibility: hidden; /* Prevents blurry text during transforms */
120+
perspective: 1000; /* Creates proper 3D context for crisp text */
118121
-webkit-transform-style: preserve-3d; /* Ensures consistent text rendering across browsers */
119122
transform-style: preserve-3d;
120123
}
@@ -263,15 +266,17 @@ svg {
263266
}
264267

265268
&:before {
266-
content: '';
269+
content: "";
267270
@apply absolute;
268271
@apply inset-0;
269272
@apply -translate-x-full;
270273
animation: shimmer 2s infinite;
271-
background: linear-gradient(to right,
274+
background: linear-gradient(
275+
to right,
272276
transparent,
273277
rgba(142, 97, 227, 0.3),
274-
transparent);
278+
transparent
279+
);
275280
}
276281
}
277282

@@ -348,8 +353,12 @@ svg {
348353
}
349354

350355
@keyframes blink {
351-
from { @apply opacity-100; }
352-
to { @apply opacity-0; }
356+
from {
357+
@apply opacity-100;
358+
}
359+
to {
360+
@apply opacity-0;
361+
}
353362
}
354363

355364
.react-scan-arrow {
@@ -380,7 +389,7 @@ svg {
380389
@apply overflow-hidden;
381390

382391
&:before {
383-
content: '';
392+
content: "";
384393
@apply absolute top-0 left-0;
385394
@apply w-[1px] h-full;
386395
@apply bg-gray-500/30;
@@ -393,7 +402,7 @@ svg {
393402
@apply py-2 px-4;
394403
@apply text-[#888];
395404

396-
>div {
405+
> div {
397406
@apply flex items-center justify-between;
398407
@apply transition-colors duration-300;
399408
}
@@ -427,7 +436,7 @@ svg {
427436
}
428437

429438
input:checked {
430-
+div {
439+
+ div {
431440
@apply bg-[#5f3f9a];
432441

433442
&::before {
@@ -438,7 +447,7 @@ svg {
438447
}
439448
}
440449

441-
>div {
450+
> div {
442451
@apply absolute inset-1;
443452
@apply bg-neutral-700;
444453
@apply rounded-full;
@@ -602,7 +611,6 @@ svg {
602611
}
603612
}
604613

605-
606614
.tree-node-search-highlight {
607615
@apply truncate;
608616

@@ -663,15 +671,13 @@ svg {
663671
&::before {
664672
@apply bottom-0 translate-y-full;
665673
}
666-
667674
}
668675

669676
&.is-open {
670677
@apply translate-y-0;
671678
}
672679
}
673680

674-
675681
.react-scan-header-item {
676682
@apply absolute inset-0 -translate-y-[200%];
677683
@apply transition-transform duration-300;
@@ -681,12 +687,11 @@ svg {
681687
}
682688
}
683689

684-
.react-scan-components-tree:has(.resize-v-line:hover, .resize-v-line:active) .tree {
690+
.react-scan-components-tree:has(.resize-v-line:hover, .resize-v-line:active)
691+
.tree {
685692
overflow: hidden;
686693
}
687694

688-
689-
690695
.react-scan-expandable {
691696
display: grid;
692697
grid-template-rows: 0fr;
@@ -702,4 +707,4 @@ svg {
702707
grid-template-rows: 1fr;
703708
transition-duration: 100ms;
704709
}
705-
}
710+
}

packages/scan/src/web/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export const MIN_SIZE = {
77

88
export const MIN_CONTAINER_WIDTH = 240;
99

10-
export const LOCALSTORAGE_KEY = 'react-scan-widget-settings-v2';
10+
export const LOCALSTORAGE_KEY = "react-scan-widget-settings-v2";
11+
export const LOCALSTORAGE_COLLAPSED_KEY = "react-scan-widget-collapsed-v1";

packages/scan/src/web/state.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
import { signal } from '@preact/signals';
1+
import { signal } from "@preact/signals";
22
import {
33
LOCALSTORAGE_KEY,
44
MIN_CONTAINER_WIDTH,
55
MIN_SIZE,
66
SAFE_AREA,
7-
} from './constants';
8-
import { IS_CLIENT } from './utils/constants';
9-
import { readLocalStorage, saveLocalStorage } from './utils/helpers';
10-
import type { Corner, WidgetConfig, WidgetSettings } from './widget/types';
7+
LOCALSTORAGE_COLLAPSED_KEY,
8+
} from "./constants";
9+
import { IS_CLIENT } from "./utils/constants";
10+
import { readLocalStorage, saveLocalStorage } from "./utils/helpers";
11+
import type { Corner, WidgetConfig, WidgetSettings } from "./widget/types";
12+
import type { CollapsedPosition } from "./widget/types";
1113

1214
export const signalIsSettingsOpen = /* @__PURE__ */ signal(false);
1315
export const signalRefWidget = /* @__PURE__ */ signal<HTMLDivElement | null>(
14-
null,
16+
null
1517
);
1618

1719
export const defaultWidgetConfig = {
18-
corner: 'bottom-right' as Corner,
20+
corner: "bottom-right" as Corner,
1921
dimensions: {
2022
isFullWidth: false,
2123
isFullHeight: false,
@@ -90,24 +92,30 @@ export interface SlowDowns {
9092

9193
export type WidgetStates =
9294
| {
93-
view: 'none';
95+
view: "none";
9496
}
9597
| {
96-
view: 'inspector';
98+
view: "inspector";
9799
// extra params
98100
}
99101
// | {
100102
// view: 'settings';
101103
// // extra params
102104
// }
103105
| {
104-
view: 'notifications';
106+
view: "notifications";
105107
// extra params
106108
};
107109
// | {
108110
// view: 'summary';
109111
// // extra params
110112
// };
111113
export const signalWidgetViews = signal<WidgetStates>({
112-
view: 'none',
114+
view: "none",
113115
});
116+
117+
const storedCollapsed = readLocalStorage<CollapsedPosition | null>(
118+
LOCALSTORAGE_COLLAPSED_KEY
119+
);
120+
export const signalWidgetCollapsed =
121+
/* @__PURE__ */ signal<CollapsedPosition | null>(storedCollapsed ?? null);

0 commit comments

Comments
 (0)