ext-apps/examples/pdf-server/src/mcp-app.css
Olivier Chafik 219b4b1605
fix(pdf-server): remove page-loading overlay (#493)
* fix(pdf-server): remove page-loading overlay

The overlay had multiple issues:
- Hardcoded white background broke dark mode
- Could get stuck visible, breaking sizing/layout
- Added little value since previous page stays visible during render
  and the 150ms delay meant most renders completed before it showed

* prettier:fix
2026-02-23 21:25:25 +00:00

470 lines
8.8 KiB
CSS

:root {
color-scheme: light dark;
/* Background colors */
--bg000: light-dark(#ffffff, #1a1a1a);
--bg100: light-dark(#f5f5f5, #252525);
--bg200: light-dark(#e0e0e0, #333333);
--bg300: light-dark(#cccccc, #444444);
/* Text colors */
--text000: light-dark(#1a1a1a, #f0f0f0);
--text100: light-dark(#666666, #aaaaaa);
--text200: light-dark(#999999, #888888);
/* Shadows */
--shadow-page: light-dark(
0 2px 8px rgba(0, 0, 0, 0.15),
0 2px 8px rgba(0, 0, 0, 0.4)
);
--selection-bg: light-dark(rgba(0, 0, 255, 0.3), rgba(100, 150, 255, 0.4));
}
body {
overscroll-behavior-x: none;
display: flex;
}
.main {
display: flex;
flex-direction: column;
flex: 1;
width: 100%;
background: var(--bg100);
color: var(--text000);
overflow: hidden; /* Prevent scrollbars in inline mode - we request exact size */
border-radius: 0.75rem;
border: 1px solid var(--bg200);
}
/* Loading State */
.loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex: 1;
gap: 0.75rem;
padding: 2rem;
}
.spinner {
width: 24px;
height: 24px;
border: 2px solid var(--bg200);
border-top-color: var(--text100);
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
#loading-text {
font-size: 0.8rem;
color: var(--text100);
}
/* Error State */
.error {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
gap: 1rem;
padding: 2rem;
text-align: center;
}
.error-icon {
font-size: 3rem;
}
#error-message {
color: var(--text200);
max-width: 400px;
}
/* Viewer Container */
.viewer {
display: flex;
flex-direction: column;
flex: 1;
overflow: visible;
position: relative;
}
/* Toolbar */
.toolbar {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.5rem 1rem;
background: var(--bg000);
border-bottom: 1px solid var(--bg200);
flex-shrink: 0;
gap: 0.5rem;
height: 48px;
box-sizing: border-box;
}
.toolbar-left {
flex: 1;
min-width: 0;
overflow: hidden;
display: flex;
align-items: center;
}
.pdf-title {
font-weight: 500;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
font-size: 0.9rem;
display: block;
max-width: 100%;
}
.toolbar-center {
display: flex;
align-items: center;
gap: 0.5rem;
flex-shrink: 0;
}
.toolbar-right {
display: flex;
align-items: center;
gap: 0.25rem;
flex-shrink: 0;
}
/* Page Navigation */
.page-nav {
display: flex;
align-items: center;
gap: 0.25rem;
}
.page-input {
width: 50px;
padding: 0.25rem 0.5rem;
border: 1px solid var(--bg200);
border-radius: 4px;
font-size: 0.85rem;
text-align: center;
background: var(--bg000);
color: var(--text000);
}
.page-input:focus {
outline: none;
border-color: var(--text100);
}
.page-input::-webkit-outer-spin-button,
.page-input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
.page-input[type="number"] {
-moz-appearance: textfield;
}
.total-pages {
font-size: 0.85rem;
color: var(--text100);
white-space: nowrap;
}
.nav-btn,
.zoom-btn,
.fullscreen-btn {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border: 1px solid var(--bg200);
border-radius: 4px;
background: var(--bg000);
color: var(--text000);
cursor: pointer;
font-size: 1rem;
transition: all 0.15s ease;
}
.nav-btn:hover:not(:disabled),
.zoom-btn:hover:not(:disabled),
.fullscreen-btn:hover {
background: var(--bg100);
border-color: var(--bg300);
}
.nav-btn:disabled,
.zoom-btn:disabled {
opacity: 0.4;
cursor: not-allowed;
}
.zoom-level {
font-size: 0.8rem;
color: var(--text100);
min-width: 50px;
text-align: center;
}
/* Single Page Canvas Container */
.canvas-container {
flex: 1;
overflow: visible;
display: flex;
justify-content: center;
align-items: flex-start;
padding: 1rem;
background: var(--bg200);
}
.page-wrapper {
position: relative;
box-shadow: var(--shadow-page);
background: white;
}
#pdf-canvas {
display: block;
}
/* Text Layer for Selection
* Critical: must include font-size and transform rules that PDF.js TextLayer
* relies on via CSS custom properties (--font-height, --scale-x, --rotate).
* Without these, text layer spans won't align with the canvas rendering. */
.text-layer {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
overflow: hidden;
opacity: 0.2;
line-height: 1;
text-size-adjust: none;
forced-color-adjust: none;
transform-origin: 0 0;
z-index: 2;
/* PDF.js TextLayer sets --min-font-size on container */
--min-font-size-inv: calc(1 / var(--min-font-size, 1));
}
.text-layer :is(span, br) {
color: transparent;
position: absolute;
white-space: pre;
cursor: text;
transform-origin: 0% 0%;
}
/* PDF.js sets --font-height, --scale-x, --rotate as inline styles on each span.
* These rules apply proper font size and transforms to match the canvas. */
.text-layer > :not(.markedContent),
.text-layer .markedContent span:not(.markedContent) {
z-index: 1;
--font-height: 0;
font-size: calc(var(--scale-factor, 1) * var(--font-height));
--scale-x: 1;
--rotate: 0deg;
transform: rotate(var(--rotate)) scaleX(var(--scale-x))
scale(var(--min-font-size-inv, 1));
}
.text-layer .markedContent {
display: contents;
}
.text-layer ::selection {
background: var(--selection-bg);
}
.text-layer > span {
pointer-events: all;
}
/* Fullscreen mode */
.main.fullscreen {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 1000;
overflow: hidden; /* No scrolling on main - only canvas-container scrolls */
border-radius: 0;
border: none;
padding: 0 !important; /* Ignore safe area insets in fullscreen */
}
.main.fullscreen .viewer {
min-height: 0; /* Allow flex item to shrink below content size */
}
.main.fullscreen .canvas-container {
min-height: 0; /* Allow flex item to shrink below content size */
overflow: auto; /* Scroll within the document area only */
}
/* Search Button */
.search-btn,
.nav-btn,
.zoom-btn,
.fullscreen-btn {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border: 1px solid var(--bg200);
border-radius: 4px;
background: var(--bg000);
color: var(--text000);
cursor: pointer;
font-size: 1rem;
transition: all 0.15s ease;
}
.search-btn:hover,
.nav-btn:hover:not(:disabled),
.zoom-btn:hover:not(:disabled),
.fullscreen-btn:hover {
background: var(--bg100);
border-color: var(--bg300);
}
/* Search Bar */
.search-bar {
display: flex;
align-items: center;
position: absolute;
top: 47px; /* below toolbar (48px - 1px border overlap) */
right: -1px; /* align with outer border */
padding: 0.375rem 0.5rem;
background: var(--bg000);
border: 1px solid var(--bg200);
border-top: none;
border-radius: 0 0 6px 6px;
gap: 0.5rem;
z-index: 10;
}
.search-input {
width: 200px;
padding: 0.25rem 0.5rem;
border: 1px solid var(--bg200);
border-radius: 4px;
font-size: 0.85rem;
background: var(--bg000);
color: var(--text000);
}
.search-input:focus {
outline: none;
border-color: var(--text100);
}
.search-match-count {
font-size: 0.8rem;
color: var(--text100);
white-space: nowrap;
min-width: 60px;
}
.search-nav-btn {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border: 1px solid var(--bg200);
border-radius: 4px;
background: var(--bg000);
color: var(--text000);
cursor: pointer;
font-size: 0.8rem;
transition: all 0.15s ease;
}
.search-nav-btn:hover:not(:disabled) {
background: var(--bg100);
border-color: var(--bg300);
}
.search-nav-btn:disabled {
opacity: 0.4;
cursor: not-allowed;
}
/* Highlight Layer */
.highlight-layer {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
pointer-events: none;
z-index: 1;
}
.search-highlight {
background: rgba(255, 255, 0, 0.4);
mix-blend-mode: multiply;
border-radius: 2px;
pointer-events: none;
}
.search-highlight.current {
background: rgba(255, 165, 0, 0.6);
}
@media (prefers-color-scheme: dark) {
.search-highlight {
background: rgba(255, 255, 0, 0.3);
mix-blend-mode: screen;
}
.search-highlight.current {
background: rgba(255, 165, 0, 0.5);
mix-blend-mode: screen;
}
}
/* Loading Indicator (pie) */
.loading-indicator {
display: inline-flex;
align-items: center;
margin-left: 0.5rem;
flex-shrink: 0;
transition: opacity 0.3s;
}
.loading-indicator-bg {
fill: none;
stroke: var(--bg200);
stroke-width: 3;
}
.loading-indicator-arc {
fill: none;
stroke: var(--text100);
stroke-width: 3;
stroke-dasharray: 50.27; /* 2*pi*8 */
stroke-dashoffset: 50.27;
transform: rotate(-90deg);
transform-origin: center;
transition: stroke-dashoffset 0.3s;
}
.loading-indicator.error .loading-indicator-arc {
stroke: #e74c3c;
}