Skip to content

Commit e3e7d7e

Browse files
authored
perf: improve header perf and css styles (#141)
1 parent c1c5a9a commit e3e7d7e

File tree

5 files changed

+206
-272
lines changed

5 files changed

+206
-272
lines changed

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

Lines changed: 89 additions & 168 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,41 @@
44

55
* {
66
outline: none !important;
7+
text-rendering: optimizeLegibility;
8+
-webkit-font-smoothing: antialiased;
9+
-moz-osx-font-smoothing: grayscale;
10+
backface-visibility: hidden;
11+
12+
/* WebKit (Chrome, Safari, Edge) specific scrollbar styles */
13+
&::-webkit-scrollbar {
14+
width: 6px;
15+
height: 6px;
16+
}
17+
18+
&::-webkit-scrollbar-track {
19+
border-radius: 10px;
20+
background: transparent;
21+
}
22+
23+
&::-webkit-scrollbar-thumb {
24+
border-radius: 10px;
25+
background: rgba(255, 255, 255, 0.3);
26+
}
27+
28+
&::-webkit-scrollbar-thumb:hover {
29+
background: rgba(255, 255, 255, .4);
30+
}
31+
}
32+
33+
@-moz-document url-prefix() {
34+
* {
35+
scrollbar-width: thin;
36+
scrollbar-color: rgba(255, 255, 255, 0.4) transparent;
37+
scrollbar-width: 6px;
38+
}
739
}
840

41+
942
button {
1043
@apply hover:bg-none;
1144
@apply outline-none;
@@ -36,89 +69,80 @@ button {
3669
overflow: hidden;
3770
&::before {
3871
content: attr(data-text);
39-
display: block;
72+
@apply block;
4073
@apply truncate;
4174
}
4275
}
4376

44-
/* Default scrollbar styles for all elements in shadow DOM */
45-
:host *::-webkit-scrollbar {
46-
width: 6px;
47-
height: 6px;
48-
}
49-
50-
:host *::-webkit-scrollbar-track {
51-
background: transparent;
52-
}
53-
54-
:host *::-webkit-scrollbar-thumb {
55-
background: rgba(255, 255, 255, 0.2);
56-
border-radius: 3px;
57-
}
58-
59-
:host *::-webkit-scrollbar-thumb:hover {
60-
background: rgba(255, 255, 255, 0.3);
77+
#react-scan-toolbar {
78+
@apply fixed left-0 top-0;
79+
@apply flex flex-col;
80+
@apply rounded-lg shadow-lg;
81+
@apply font-mono text-[13px] text-white;
82+
@apply bg-black;
83+
@apply select-none;
84+
@apply cursor-move;
85+
@apply opacity-0;
86+
@apply z-[999999999];
87+
@apply animate-fade-in animation-duration-300 animation-delay-300;
88+
@apply shadow-[0_4px_12px_rgba(0,0,0,0.2)];
89+
max-width: calc(100vw - 48px); /* 48px = SAFE_AREA * 2 */
90+
max-height: calc(100vh - 48px);
6191
}
6292

63-
/* For Firefox */
64-
:host * {
65-
scrollbar-width: thin;
66-
scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.1);
67-
}
6893

69-
/* We will refactor this later */
70-
.react-scan-header-right {
71-
display: flex;
72-
gap: 4px;
94+
/* HEADER */
95+
.react-scan-header {
96+
@apply flex items-center gap-x-2;
97+
@apply pl-3 pr-2;
98+
@apply min-h-9;
99+
@apply rounded-t-lg;
100+
@apply border-b-1 border-white/10;
101+
@apply whitespace-nowrap overflow-hidden;
73102
}
74103

75104
.react-scan-replay-button,
76105
.react-scan-close-button {
77-
display: flex;
78-
align-items: center;
79-
padding: 4px;
80-
border: none;
81-
border-radius: 4px;
82-
color: #fff;
83-
cursor: pointer;
84-
transition: opacity 150ms ease;
85-
position: relative;
86-
overflow: hidden;
106+
@apply flex items-center;
107+
@apply p-1;
108+
@apply min-w-fit;
109+
@apply rounded;
110+
@apply transition-colors duration-150;
87111
}
88112

89-
.react-scan-close-button {
90-
background: rgba(255, 255, 255, 0.01);
91-
}
113+
.react-scan-replay-button {
114+
@apply relative;
115+
@apply overflow-hidden;
116+
@apply !bg-purple-500/50;
92117

93-
.react-scan-close-button:hover {
94-
background: rgba(255, 255, 255, 0.15);
95-
}
118+
&:hover {
119+
@apply bg-purple-500/25;
120+
}
96121

97-
.react-scan-replay-button {
98-
background: rgba(142, 97, 227, 0.5) !important;
99-
}
122+
&.disabled {
123+
@apply opacity-50;
124+
@apply pointer-events-none;
125+
}
100126

101-
.react-scan-replay-button.disabled {
102-
opacity: 0.5;
103-
pointer-events: none;
127+
&:before {
128+
content: '';
129+
@apply absolute;
130+
@apply inset-0;
131+
@apply -translate-x-full;
132+
animation: shimmer 2s infinite;
133+
background: linear-gradient(to right,
134+
transparent,
135+
rgba(142, 97, 227, 0.3),
136+
transparent);
137+
}
104138
}
105139

106-
.react-scan-replay-button:hover {
107-
background: rgba(142, 97, 227, 0.25);
108-
}
140+
.react-scan-close-button {
141+
@apply bg-white/10;
109142

110-
.react-scan-replay-button::before {
111-
content: '';
112-
position: absolute;
113-
inset: 0;
114-
transform: translateX(-100%);
115-
animation: shimmer 2s infinite;
116-
background: linear-gradient(
117-
to right,
118-
transparent,
119-
rgba(142, 97, 227, 0.3),
120-
transparent
121-
);
143+
&:hover {
144+
@apply bg-white/15;
145+
}
122146
}
123147

124148
@keyframes shimmer {
@@ -127,75 +151,15 @@ button {
127151
}
128152
}
129153

130-
#react-scan-toolbar {
131-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
132-
'Helvetica Neue', Arial, sans-serif;
133-
z-index: 2147483651;
134-
text-rendering: optimizeLegibility;
135-
-webkit-font-smoothing: antialiased;
136-
-moz-osx-font-smoothing: grayscale;
137-
backface-visibility: hidden;
154+
/* pivanov */
138155

139-
max-width: calc(100vw - 48px); /* 48px = SAFE_AREA * 2 */
140-
max-height: calc(100vh - 48px);
141-
}
142156

143157
.react-scan-inspector {
144158
font-size: 13px;
145159
color: #fff;
146160
width: 100%;
147161
}
148162

149-
.react-scan-header {
150-
@apply flex items-center justify-between gap-x-4;
151-
@apply rounded-t-lg;
152-
@apply overflow-hidden;
153-
@apply py-2 px-4;
154-
@apply border-b-1 border-white/10;
155-
}
156-
157-
.react-scan-header-left {
158-
display: flex;
159-
gap: 8px;
160-
align-items: center;
161-
}
162-
163-
.react-scan-header-right {
164-
display: flex;
165-
gap: 4px;
166-
align-items: center;
167-
}
168-
169-
.react-scan-replay-button {
170-
padding: 4px;
171-
display: flex;
172-
align-items: center;
173-
justify-content: center;
174-
background: rgba(255, 255, 255, 0.1);
175-
border: none;
176-
border-radius: 4px;
177-
color: #fff;
178-
cursor: pointer;
179-
transition: all 150ms ease;
180-
outline: none;
181-
}
182-
183-
.react-scan-replay-button:hover {
184-
background: rgba(255, 255, 255, 0.15);
185-
}
186-
187-
.react-scan-component-name {
188-
font-weight: 500;
189-
color: #fff;
190-
@apply truncate;
191-
}
192-
193-
.react-scan-metrics {
194-
color: #888;
195-
font-size: 12px;
196-
@apply truncate;
197-
}
198-
199163
.react-scan-section {
200164
@apply flex flex-col py-1;
201165
@apply py-2 px-4;
@@ -338,49 +302,6 @@ button {
338302
outline-offset: -2px;
339303
}
340304

341-
.react-scan-props::-webkit-scrollbar {
342-
width: 6px;
343-
height: 6px;
344-
}
345-
346-
.react-scan-props::-webkit-scrollbar-track {
347-
background: transparent;
348-
}
349-
350-
.react-scan-props::-webkit-scrollbar-thumb {
351-
background: rgba(255, 255, 255, 0.2);
352-
border-radius: 3px;
353-
}
354-
355-
.react-scan-props::-webkit-scrollbar-thumb:hover {
356-
background: rgba(255, 255, 255, 0.3);
357-
}
358-
359-
#react-scan-toolbar::-webkit-scrollbar {
360-
width: 4px;
361-
height: 4px;
362-
}
363-
364-
#react-scan-toolbar::-webkit-scrollbar-track {
365-
background: rgba(255, 255, 255, 0.1);
366-
border-radius: 4px;
367-
}
368-
369-
#react-scan-toolbar::-webkit-scrollbar-thumb {
370-
background: rgba(255, 255, 255, 0.3);
371-
border-radius: 4px;
372-
}
373-
374-
#react-scan-toolbar::-webkit-scrollbar-thumb:hover {
375-
background: rgba(255, 255, 255, 0.4);
376-
}
377-
378-
/* For Firefox */
379-
#react-scan-toolbar * {
380-
scrollbar-width: thin;
381-
scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.1);
382-
}
383-
384305
.nav-button {
385306
opacity: var(--nav-opacity, 1);
386307
}

0 commit comments

Comments
 (0)