mirror of
https://github.com/garrytan/gstack.git
synced 2026-05-08 06:26:45 +02:00
feat: sidebar CSS inspector — element picker, box model, rule cascade, quick edit
Extension changes for the visual CSS inspector: - inspector.js: element picker with hover highlight, CSS selector generation, basic mode fallback (getComputedStyle + CSSOM), page alteration handlers - inspector.css: picker overlay styles (blue highlight + tooltip) - background.js: inspector message routing (picker <-> server <-> sidepanel) - sidepanel: Inspector tab with box model viz (gstack palette), matched rules with specificity badges, computed styles, click-to-edit quick edit, Send to Agent/Code button, empty/loading/error states Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -697,6 +697,496 @@ footer {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ─── Inspector Tab ──────────────────────────────────── */
|
||||
|
||||
.inspector-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 6px 10px;
|
||||
background: var(--bg-surface);
|
||||
border-bottom: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.inspector-pick-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
height: 28px;
|
||||
padding: 0 10px;
|
||||
background: none;
|
||||
border: 1px solid var(--amber-500);
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--amber-500);
|
||||
font-family: var(--font-system);
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: all 150ms;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.inspector-pick-btn:hover {
|
||||
background: rgba(245, 158, 11, 0.1);
|
||||
color: var(--amber-400);
|
||||
}
|
||||
|
||||
.inspector-pick-btn.active {
|
||||
background: var(--amber-500);
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.inspector-pick-icon {
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.inspector-selected {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
color: var(--text-body);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.inspector-mode-badge {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 10px;
|
||||
padding: 1px 6px;
|
||||
border-radius: var(--radius-sm);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.inspector-mode-badge.basic {
|
||||
background: var(--zinc-800);
|
||||
color: var(--zinc-400);
|
||||
}
|
||||
|
||||
.inspector-mode-badge.cdp {
|
||||
background: rgba(34, 197, 94, 0.15);
|
||||
color: var(--success);
|
||||
}
|
||||
|
||||
/* Inspector content area */
|
||||
.inspector-content {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* Empty state */
|
||||
.inspector-empty {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 40px 24px;
|
||||
text-align: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.inspector-empty-icon {
|
||||
font-size: 24px;
|
||||
color: var(--zinc-600);
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.inspector-empty p {
|
||||
color: var(--zinc-400);
|
||||
font-size: 13px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.inspector-empty .muted {
|
||||
color: var(--zinc-600);
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
/* Loading state */
|
||||
.inspector-loading {
|
||||
padding: 16px 12px;
|
||||
}
|
||||
|
||||
.inspector-loading-text {
|
||||
font-size: 12px;
|
||||
color: var(--amber-500);
|
||||
margin-bottom: 12px;
|
||||
animation: pulse 2s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.inspector-skeleton {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.inspector-skeleton-bar {
|
||||
height: 12px;
|
||||
background: var(--zinc-800);
|
||||
border-radius: var(--radius-sm);
|
||||
animation: shimmer 1.5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.inspector-skeleton-bar:nth-child(1) { width: 80%; }
|
||||
.inspector-skeleton-bar:nth-child(2) { width: 60%; }
|
||||
.inspector-skeleton-bar:nth-child(3) { width: 70%; }
|
||||
|
||||
@keyframes shimmer {
|
||||
0%, 100% { opacity: 0.3; }
|
||||
50% { opacity: 0.7; }
|
||||
}
|
||||
|
||||
/* Error state */
|
||||
.inspector-error {
|
||||
padding: 16px 12px;
|
||||
color: var(--error);
|
||||
font-size: 12px;
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
/* Inspector sections */
|
||||
.inspector-section {
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.inspector-section-header {
|
||||
font-family: var(--font-system);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--zinc-400);
|
||||
padding: 8px 12px 4px;
|
||||
}
|
||||
|
||||
.inspector-section-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
width: 100%;
|
||||
padding: 8px 12px;
|
||||
background: none;
|
||||
border: none;
|
||||
font-family: var(--font-system);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--zinc-400);
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
transition: color 150ms;
|
||||
}
|
||||
|
||||
.inspector-section-toggle:hover {
|
||||
color: var(--text-body);
|
||||
}
|
||||
|
||||
.inspector-toggle-arrow {
|
||||
font-size: 10px;
|
||||
color: var(--zinc-400);
|
||||
flex-shrink: 0;
|
||||
width: 12px;
|
||||
}
|
||||
|
||||
.inspector-section-body {
|
||||
padding: 4px 12px 8px;
|
||||
}
|
||||
|
||||
.inspector-section-body.collapsed {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.inspector-rule-count {
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
color: var(--zinc-600);
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.inspector-no-data {
|
||||
color: var(--zinc-600);
|
||||
font-size: 11px;
|
||||
font-style: italic;
|
||||
padding: 4px 0;
|
||||
}
|
||||
|
||||
/* ─── Box Model ──────────────────────────────────────── */
|
||||
|
||||
.inspector-boxmodel {
|
||||
padding: 8px 12px 12px;
|
||||
}
|
||||
|
||||
.boxmodel-margin,
|
||||
.boxmodel-border,
|
||||
.boxmodel-padding,
|
||||
.boxmodel-content {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px dashed;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.boxmodel-margin {
|
||||
background: rgba(245, 158, 11, 0.08);
|
||||
border-color: rgba(245, 158, 11, 0.3);
|
||||
padding: 14px 20px;
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.boxmodel-border {
|
||||
background: rgba(161, 161, 170, 0.08);
|
||||
border-color: rgba(161, 161, 170, 0.3);
|
||||
padding: 14px 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.boxmodel-padding {
|
||||
background: rgba(34, 197, 94, 0.08);
|
||||
border-color: rgba(34, 197, 94, 0.3);
|
||||
padding: 14px 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.boxmodel-content {
|
||||
background: rgba(59, 130, 246, 0.08);
|
||||
border-color: rgba(59, 130, 246, 0.3);
|
||||
padding: 8px 12px;
|
||||
width: 100%;
|
||||
min-height: 28px;
|
||||
}
|
||||
|
||||
.boxmodel-content span {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
color: var(--text-body);
|
||||
}
|
||||
|
||||
.boxmodel-label {
|
||||
position: absolute;
|
||||
top: 1px;
|
||||
left: 4px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 10px;
|
||||
color: var(--zinc-400);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.boxmodel-value {
|
||||
position: absolute;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
color: var(--text-body);
|
||||
}
|
||||
|
||||
.boxmodel-value.boxmodel-top { top: 1px; left: 50%; transform: translateX(-50%); }
|
||||
.boxmodel-value.boxmodel-right { right: 4px; top: 50%; transform: translateY(-50%); }
|
||||
.boxmodel-value.boxmodel-bottom { bottom: 1px; left: 50%; transform: translateX(-50%); }
|
||||
.boxmodel-value.boxmodel-left { left: 4px; top: 50%; transform: translateY(-50%); }
|
||||
|
||||
/* ─── Matched Rules ──────────────────────────────────── */
|
||||
|
||||
.inspector-rule {
|
||||
padding: 6px 0;
|
||||
border-bottom: 1px solid var(--border-subtle);
|
||||
}
|
||||
|
||||
.inspector-rule:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.inspector-rule-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.inspector-selector {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
color: var(--amber-400);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
max-width: 35ch;
|
||||
}
|
||||
|
||||
.inspector-specificity {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 10px;
|
||||
background: var(--zinc-600);
|
||||
color: var(--zinc-400);
|
||||
padding: 0 4px;
|
||||
border-radius: var(--radius-sm);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.inspector-rule-props {
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
.inspector-prop {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.inspector-prop.overridden {
|
||||
text-decoration: line-through;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.inspector-prop-name {
|
||||
color: var(--zinc-400);
|
||||
}
|
||||
|
||||
.inspector-prop-value {
|
||||
color: var(--text-body);
|
||||
}
|
||||
|
||||
.inspector-important {
|
||||
color: var(--error);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
.inspector-rule-source {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
color: var(--zinc-600);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* UA rules */
|
||||
.inspector-ua-rules {
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.inspector-ua-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
background: none;
|
||||
border: none;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
color: var(--zinc-600);
|
||||
cursor: pointer;
|
||||
padding: 4px 0;
|
||||
transition: color 150ms;
|
||||
}
|
||||
|
||||
.inspector-ua-toggle:hover {
|
||||
color: var(--zinc-400);
|
||||
}
|
||||
|
||||
.inspector-ua-body.collapsed {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* ─── Computed Styles ────────────────────────────────── */
|
||||
|
||||
.inspector-computed-row {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
padding: 0 0 0 4px;
|
||||
}
|
||||
|
||||
.inspector-computed-row .inspector-prop-name {
|
||||
color: var(--zinc-400);
|
||||
}
|
||||
|
||||
.inspector-computed-row .inspector-prop-value {
|
||||
color: var(--text-body);
|
||||
}
|
||||
|
||||
/* ─── Quick Edit ─────────────────────────────────────── */
|
||||
|
||||
.inspector-quickedit-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.inspector-quickedit-row {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.inspector-quickedit-row .inspector-prop-name {
|
||||
color: var(--zinc-400);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.inspector-quickedit-value {
|
||||
color: var(--text-body);
|
||||
cursor: pointer;
|
||||
padding: 1px 4px;
|
||||
border-radius: 2px;
|
||||
transition: background 150ms;
|
||||
min-width: 40px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.inspector-quickedit-value:hover {
|
||||
background: var(--bg-hover);
|
||||
}
|
||||
|
||||
.inspector-quickedit-input {
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
background: var(--bg-base);
|
||||
border: 1px solid var(--amber-500);
|
||||
border-radius: 2px;
|
||||
color: var(--text-heading);
|
||||
padding: 1px 4px;
|
||||
outline: none;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* ─── Send to Agent ──────────────────────────────────── */
|
||||
|
||||
.inspector-send {
|
||||
padding: 8px 12px;
|
||||
background: var(--bg-surface);
|
||||
border-top: 1px solid var(--border);
|
||||
flex-shrink: 0;
|
||||
position: sticky;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
.inspector-send-btn {
|
||||
width: 100%;
|
||||
height: 32px;
|
||||
background: var(--amber-500);
|
||||
border: none;
|
||||
border-radius: var(--radius-md);
|
||||
color: #000;
|
||||
font-family: var(--font-system);
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: all 150ms;
|
||||
}
|
||||
|
||||
.inspector-send-btn:hover {
|
||||
background: var(--amber-400);
|
||||
}
|
||||
|
||||
.inspector-send-btn:active {
|
||||
transform: scale(0.98);
|
||||
}
|
||||
|
||||
/* ─── Accessibility ───────────────────────────────────── */
|
||||
:focus-visible {
|
||||
outline: 2px solid var(--amber-500);
|
||||
|
||||
Reference in New Issue
Block a user