@vvelediaz/react-pdf-viewer
Version:
A modern, lightweight React PDF viewer component featuring zoom controls, page navigation, and responsive design
650 lines (591 loc) • 14.1 kB
CSS
/* Classic Mac OS X Aqua PDF Viewer Styles */
:root {
--aqua-blue: #4A90E2;
--aqua-blue-light: #6BA3E8;
--aqua-blue-dark: #3570B8;
--aqua-gray: #E8E8E8;
--aqua-gray-dark: #C0C0C0;
--aqua-gray-light: #F5F5F5;
--aqua-metal: #D4D4D4;
--aqua-metal-dark: #B8B8B8;
--aqua-text: #000000;
--aqua-text-shadow: rgba(255, 255, 255, 0.8);
--aqua-border-radius: 12px;
--aqua-pill-radius: 20px;
}
/* Container with classic Mac window styling */
.pdf-viewer-container {
display: flex;
flex-direction: column;
height: 100%;
width: 100%;
background: linear-gradient(to bottom, #f0f0f0 0%, #e8e8e8 100%);
border: 1px solid #999999;
border-radius: var(--aqua-border-radius);
box-shadow:
0 0 0 1px rgba(255, 255, 255, 0.8) inset,
0 4px 12px rgba(0, 0, 0, 0.3);
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
overflow: hidden;
}
/* Classic Aqua toolbar with brushed metal effect */
.pdf-controls,
.pdf-controls-single-line {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8px 16px;
background:
linear-gradient(to bottom,
#f8f8f8 0%,
#e8e8e8 50%,
#d8d8d8 51%,
#c8c8c8 100%);
border-bottom: 1px solid #999999;
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.8) inset,
0 -1px 0 rgba(0, 0, 0, 0.1) inset;
gap: 12px;
white-space: nowrap;
overflow: hidden;
position: relative;
}
/* Add subtle striped pattern for authentic Aqua look */
.pdf-controls::before,
.pdf-controls-single-line::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image:
linear-gradient(90deg,
transparent 0px,
rgba(255, 255, 255, 0.1) 1px,
transparent 2px);
background-size: 3px 100%;
pointer-events: none;
}
.pdf-controls-group {
display: flex;
align-items: center;
gap: 6px;
}
/* Classic Aqua square buttons with rounded corners */
.pdf-control-btn,
button {
background: linear-gradient(to bottom,
#ffffff 0%,
#f0f0f0 50%,
#e0e0e0 51%,
#d0d0d0 100%);
border: 1px solid #999999;
border-radius: 6px;
padding: 6px 14px;
cursor: pointer;
font-size: 13px;
font-weight: normal;
color: var(--aqua-text);
text-shadow: 0 1px 0 var(--aqua-text-shadow);
transition: all 0.1s ease;
display: inline-flex;
align-items: center;
justify-content: center;
min-height: 24px;
min-width: 32px;
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.8) inset,
0 -1px 0 rgba(0, 0, 0, 0.1) inset,
0 1px 2px rgba(0, 0, 0, 0.2);
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
/* Aqua button hover state */
.pdf-control-btn:hover:not(:disabled),
button:hover:not(:disabled) {
background: linear-gradient(to bottom,
#ffffff 0%,
#f8f8f8 50%,
#e8e8e8 51%,
#d8d8d8 100%);
border-color: #777777;
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.9) inset,
0 -1px 0 rgba(0, 0, 0, 0.15) inset,
0 2px 4px rgba(0, 0, 0, 0.25);
}
/* Aqua button active/pressed state */
.pdf-control-btn:active,
button:active {
background: linear-gradient(to bottom,
#d0d0d0 0%,
#e0e0e0 50%,
#f0f0f0 51%,
#ffffff 100%);
box-shadow:
0 -1px 0 rgba(255, 255, 255, 0.8) inset,
0 1px 0 rgba(0, 0, 0, 0.2) inset,
0 1px 1px rgba(0, 0, 0, 0.1);
transform: translateY(1px);
}
/* Disabled button state */
.pdf-control-btn:disabled,
button:disabled {
background: linear-gradient(to bottom,
#f5f5f5 0%,
#e5e5e5 50%,
#d5d5d5 51%,
#c5c5c5 100%);
color: #999999;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
cursor: not-allowed;
border-color: #bbbbbb;
opacity: 0.6;
}
/* Primary button (blue Aqua style) */
.pdf-control-btn.primary {
background: linear-gradient(to bottom,
#6BA3E8 0%,
#4A90E2 50%,
#3570B8 51%,
#2A5A94 100%);
border-color: #2A5A94;
color: white;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.3);
}
.pdf-control-btn.primary:hover:not(:disabled) {
background: linear-gradient(to bottom,
#7BB0EA 0%,
#5A9DE4 50%,
#457DC0 51%,
#35689C 100%);
}
/* Aqua default button (blue navigation buttons) */
.pdf-control-btn.aqua-default {
background: linear-gradient(to bottom,
#92C7FF 0%,
#6BA3E8 25%,
#4A90E2 50%,
#3570B8 75%,
#2A5A94 100%);
border: 1px solid #1E4A7A;
color: white;
text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.4);
font-weight: bold;
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.3) inset,
0 -1px 0 rgba(0, 0, 0, 0.3) inset,
0 1px 3px rgba(0, 0, 0, 0.3),
0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}
.pdf-control-btn.aqua-default:hover:not(:disabled) {
background: linear-gradient(to bottom,
#A3D1FF 0%,
#7BB0EA 25%,
#5A9DE4 50%,
#457DC0 75%,
#35689C 100%);
border-color: #2A5A94;
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.4) inset,
0 -1px 0 rgba(0, 0, 0, 0.2) inset,
0 2px 5px rgba(0, 0, 0, 0.4),
0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}
.pdf-control-btn.aqua-default:active {
background: linear-gradient(to bottom,
#2A5A94 0%,
#3570B8 25%,
#4A90E2 50%,
#6BA3E8 75%,
#92C7FF 100%);
box-shadow:
0 -1px 0 rgba(255, 255, 255, 0.2) inset,
0 1px 0 rgba(0, 0, 0, 0.4) inset,
0 1px 2px rgba(0, 0, 0, 0.2),
0 0 0 1px rgba(0, 0, 0, 0.1) inset;
}
.pdf-control-btn.aqua-default:disabled {
background: linear-gradient(to bottom,
#B8B8B8 0%,
#A8A8A8 50%,
#989898 51%,
#888888 100%);
border-color: #666666;
color: #CCCCCC;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.5) inset,
0 -1px 0 rgba(0, 0, 0, 0.1) inset,
0 1px 2px rgba(0, 0, 0, 0.1);
}
/* Classic Aqua info displays */
.page-info,
.zoom-info,
.page-info-compact,
.zoom-info-compact {
margin: 0 8px;
font-weight: bold;
min-width: 60px;
text-align: center;
color: var(--aqua-text);
font-size: 11px;
text-shadow: 0 1px 0 var(--aqua-text-shadow);
flex-shrink: 0;
background: linear-gradient(to bottom,
rgba(255, 255, 255, 0.8) 0%,
rgba(240, 240, 240, 0.8) 100%);
padding: 4px 10px;
border-radius: 6px;
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.8) inset,
0 -1px 0 rgba(0, 0, 0, 0.1) inset;
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.page-input-compact {
display: flex;
align-items: center;
flex-shrink: 0;
}
/* Classic Aqua input fields with inset appearance */
.pdf-page-input,
.page-number-input,
input[type="number"] {
width: 50px;
text-align: center;
padding: 4px 6px;
border: 1px solid #999999;
border-radius: 4px;
font-size: 11px;
font-weight: normal;
background: linear-gradient(to bottom,
#f8f8f8 0%,
#ffffff 100%);
color: var(--aqua-text);
box-shadow:
0 1px 2px rgba(0, 0, 0, 0.2) inset,
0 1px 0 rgba(255, 255, 255, 0.8);
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.pdf-page-input:focus,
.page-number-input:focus,
input[type="number"]:focus {
outline: none;
border-color: var(--aqua-blue);
box-shadow:
0 1px 2px rgba(0, 0, 0, 0.2) inset,
0 0 0 2px rgba(74, 144, 226, 0.3),
0 1px 0 rgba(255, 255, 255, 0.8);
}
/* Content areas with classic Mac styling */
.pdf-content-ionic,
.pdf-content-continuous {
flex: 1;
overflow: auto;
background: linear-gradient(45deg,
#f0f0f0 0%,
#e8e8e8 25%,
#f0f0f0 50%,
#e8e8e8 75%,
#f0f0f0 100%);
background-size: 20px 20px;
padding: 16px;
min-height: 0;
display: flex;
justify-content: center;
align-items: flex-start;
border: 1px solid #999999 inset;
}
.pdf-content-continuous {
scroll-behavior: smooth;
}
.pdf-content-ionic>div,
.pdf-content-continuous>div {
min-width: min-content;
}
/* Page containers with Aqua styling */
.pdf-pages-container {
display: flex;
flex-direction: column;
align-items: center;
gap: 16px;
}
.pdf-page-wrapper {
display: flex;
justify-content: center;
margin-bottom: 8px;
}
.pdf-page-continuous {
box-shadow:
0 2px 8px rgba(0, 0, 0, 0.3),
0 0 0 1px rgba(255, 255, 255, 0.8) inset;
border-radius: 8px;
overflow: visible;
background-color: #ffffff;
transition: all 0.2s ease;
flex-shrink: 0;
}
.pdf-page-continuous.current-page {
box-shadow:
0 4px 16px rgba(74, 144, 226, 0.4),
0 0 0 2px var(--aqua-blue),
0 0 0 3px rgba(255, 255, 255, 0.8) inset;
}
/* Classic Mac loading state */
.pdf-loading-ionic {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 200px;
gap: 16px;
padding: 20px;
text-align: center;
}
.loading-details {
font-size: 11px;
color: #666666;
font-style: italic;
text-shadow: 0 1px 0 var(--aqua-text-shadow);
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
/* Aqua-style loading spinner */
.loading-spinner {
width: 32px;
height: 32px;
border: 3px solid rgba(74, 144, 226, 0.3);
border-top: 3px solid var(--aqua-blue);
border-radius: 50%;
animation: aqua-spin 1s linear infinite;
background: radial-gradient(circle, rgba(255, 255, 255, 0.8) 0%, transparent 70%);
}
@keyframes aqua-spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
/* Classic Mac error styling */
.pdf-viewer-error {
margin: 16px;
max-width: 100%;
}
.error-content {
text-align: center;
padding: 24px;
background: linear-gradient(to bottom,
#ffffff 0%,
#f8f8f8 100%);
border-radius: var(--aqua-border-radius);
border: 1px solid #cccccc;
box-shadow:
0 2px 8px rgba(0, 0, 0, 0.2),
0 1px 0 rgba(255, 255, 255, 0.8) inset;
}
.error-content h3 {
color: #cc0000;
margin: 0 0 16px 0;
font-size: 14px;
font-weight: bold;
text-shadow: 0 1px 0 var(--aqua-text-shadow);
font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.error-message {
margin: 16px 0;
padding: 12px;
background: linear-gradient(to bottom,
#ffe6e6 0%,
#ffcccc 100%);
border: 1px solid #cc9999;
border-radius: 6px;
color: #990000;
font-size: 12px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) inset;
}
.error-suggestions {
text-align: left;
margin: 20px 0;
padding: 16px;
background: linear-gradient(to bottom,
#fffff0 0%,
#fff8dc 100%);
border-radius: 6px;
border: 1px solid #ddd4aa;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1) inset;
}
.error-suggestions ul {
margin: 8px 0 0 0;
padding-left: 20px;
}
.error-suggestions li {
margin: 6px 0;
line-height: 1.4;
color: #666600;
font-size: 11px;
text-shadow: 0 1px 0 var(--aqua-text-shadow);
}
/* PDF.js overrides for Aqua styling */
.react-pdf__Page {
margin: 0 auto;
box-shadow:
0 2px 8px rgba(0, 0, 0, 0.3),
0 0 0 1px rgba(255, 255, 255, 0.8) inset;
border-radius: 8px;
overflow: visible;
background-color: #ffffff;
flex-shrink: 0;
}
.react-pdf__Page__canvas {
display: block;
height: auto;
border-radius: 8px;
}
/* Classic Mac Aqua Blue scrollbars */
.pdf-content-ionic::-webkit-scrollbar,
.pdf-content-continuous::-webkit-scrollbar {
width: 15px;
height: 15px;
}
.pdf-content-ionic::-webkit-scrollbar-track,
.pdf-content-continuous::-webkit-scrollbar-track {
background: linear-gradient(to right,
#DCDCDC 0%,
#EBEBEB 25%,
#F5F5F5 50%,
#EBEBEB 75%,
#DCDCDC 100%);
border: 1px solid #A0A0A0;
border-radius: 0;
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.5) inset,
0 -1px 0 rgba(0, 0, 0, 0.1) inset;
}
.pdf-content-ionic::-webkit-scrollbar-thumb,
.pdf-content-continuous::-webkit-scrollbar-thumb {
background: linear-gradient(to bottom,
#B8D4FF 0%,
#92C7FF 20%,
#6BA3E8 40%,
#4A90E2 60%,
#3570B8 80%,
#2A5A94 100%);
border: 1px solid #1E4A7A;
border-radius: 6px;
min-height: 20px;
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.4) inset,
0 -1px 0 rgba(0, 0, 0, 0.3) inset,
0 1px 3px rgba(0, 0, 0, 0.3),
0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}
.pdf-content-ionic::-webkit-scrollbar-thumb:hover,
.pdf-content-continuous::-webkit-scrollbar-thumb:hover {
background: linear-gradient(to bottom,
#C9DDFF 0%,
#A3D1FF 20%,
#7BB0EA 40%,
#5A9DE4 60%,
#457DC0 80%,
#35689C 100%);
border-color: #2A5A94;
box-shadow:
0 1px 0 rgba(255, 255, 255, 0.5) inset,
0 -1px 0 rgba(0, 0, 0, 0.2) inset,
0 2px 5px rgba(0, 0, 0, 0.4),
0 0 0 1px rgba(255, 255, 255, 0.2) inset;
}
.pdf-content-ionic::-webkit-scrollbar-thumb:active,
.pdf-content-continuous::-webkit-scrollbar-thumb:active {
background: linear-gradient(to bottom,
#2A5A94 0%,
#3570B8 20%,
#4A90E2 40%,
#6BA3E8 60%,
#92C7FF 80%,
#B8D4FF 100%);
box-shadow:
0 -1px 0 rgba(255, 255, 255, 0.3) inset,
0 1px 0 rgba(0, 0, 0, 0.4) inset,
0 1px 2px rgba(0, 0, 0, 0.2),
0 0 0 1px rgba(0, 0, 0, 0.1) inset;
}
/* Scrollbar corner */
.pdf-content-ionic::-webkit-scrollbar-corner,
.pdf-content-continuous::-webkit-scrollbar-corner {
background: linear-gradient(45deg,
#DCDCDC 0%,
#EBEBEB 25%,
#F5F5F5 50%,
#EBEBEB 75%,
#DCDCDC 100%);
border: 1px solid #A0A0A0;
}
/* Horizontal scrollbar specific styling */
.pdf-content-ionic::-webkit-scrollbar-track:horizontal,
.pdf-content-continuous::-webkit-scrollbar-track:horizontal {
background: linear-gradient(to bottom,
#DCDCDC 0%,
#EBEBEB 25%,
#F5F5F5 50%,
#EBEBEB 75%,
#DCDCDC 100%);
}
.pdf-content-ionic::-webkit-scrollbar-thumb:horizontal,
.pdf-content-continuous::-webkit-scrollbar-thumb:horizontal {
background: linear-gradient(to right,
#F8F8F8 0%,
#E8E8E8 25%,
#D0D0D0 50%,
#C0C0C0 75%,
#A8A8A8 100%);
}
/* Responsive adjustments maintaining Aqua style */
@media (max-width: 768px) {
.pdf-content-ionic,
.pdf-content-continuous {
padding: 8px;
}
.pdf-controls-single-line {
flex-wrap: wrap;
gap: 6px;
padding: 6px 8px;
}
.page-info-compact,
.zoom-info-compact {
font-size: 10px;
min-width: 50px;
padding: 3px 8px;
}
.page-number-input {
width: 45px;
font-size: 10px;
}
.pdf-control-btn {
min-width: 28px;
min-height: 20px;
padding: 4px 10px;
font-size: 11px;
}
}
/* Print styles */
@media print {
.pdf-controls,
.pdf-controls-single-line {
display: none;
}
.pdf-viewer-container {
height: auto;
box-shadow: none;
border: none;
}
.pdf-content-ionic,
.pdf-content-continuous {
overflow: visible;
height: auto;
background: white;
}
}