UNPKG

react-advanced-gallery

Version:

A customizable React image gallery component with Bootstrap styling, fullscreen mode, animations, and support for various media types

632 lines (541 loc) 11.5 kB
/* Bootstrap-inspired styling for React Advanced Gallery */ /* Gallery container */ .rag-container { width: 100%; padding: 1rem; margin-bottom: 1.5rem; } /* Gallery items grid */ .rag-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; } /* Masonry layout */ .rag-masonry { display: grid; grid-template-columns: repeat(1, 1fr); gap: 1rem; } @media (min-width: 576px) { .rag-masonry { grid-template-columns: repeat(2, 1fr); } } @media (min-width: 992px) { .rag-masonry { grid-template-columns: repeat(3, 1fr); } } /* Carousel layout */ .rag-carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 1rem; padding: 0.5rem; scroll-behavior: smooth; } .rag-carousel-item { scroll-snap-align: start; flex: 0 0 auto; width: 300px; } /* Gallery item */ .rag-item { position: relative; overflow: hidden; border-radius: 0.375rem; box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075); transition: all 0.3s ease; cursor: pointer; background-color: #fff; border: 1px solid rgba(0, 0, 0, 0.125); } .rag-item:hover { box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15); transform: translateY(-2px); } .rag-item-image { width: 100%; height: 200px; object-fit: cover; transition: transform 0.3s ease; } .rag-item:hover .rag-item-image { transform: scale(1.05); } .rag-item-badge { position: absolute; top: 0.5rem; left: 0.5rem; padding: 0.25rem 0.5rem; border-radius: 0.25rem; font-size: 0.75rem; font-weight: 600; color: #fff; } .rag-item-badge-video { background-color: #0d6efd; /* Bootstrap primary */ } .rag-item-badge-external { background-color: #6610f2; /* Bootstrap purple */ } .rag-item-caption { position: absolute; bottom: 0; left: 0; right: 0; padding: 0.75rem; background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent); color: #fff; } .rag-item-title { margin: 0; font-size: 1rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .rag-item-description { margin-top: 0.25rem; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: 0.8; } .rag-item-actions { position: absolute; top: 0.5rem; right: 0.5rem; display: flex; gap: 0.25rem; } .rag-btn { border: none; border-radius: 50%; width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s ease; color: #fff; background-color: rgba(0, 0, 0, 0.4); } .rag-btn:hover { background-color: rgba(0, 0, 0, 0.6); } .rag-btn-favorite { color: #fff; } .rag-btn-favorite.active { color: #ffc107; /* Bootstrap warning/yellow */ } .rag-btn-remove:hover { background-color: rgba(220, 53, 69, 0.7); /* Bootstrap danger/red */ } /* Config panel */ .rag-config { background-color: #f8f9fa; /* Bootstrap light */ border-radius: 0.375rem; padding: 1rem; margin-bottom: 1.5rem; border: 1px solid rgba(0, 0, 0, 0.125); } .rag-config-header { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; } @media (min-width: 768px) { .rag-config-header { flex-direction: row; justify-content: space-between; align-items: center; } } .rag-config-title { font-size: 1.25rem; font-weight: 500; margin: 0; } .rag-config-subtitle { font-size: 0.875rem; color: #6c757d; /* Bootstrap secondary */ margin: 0; } .rag-config-controls { display: flex; flex-wrap: wrap; gap: 1rem; } .rag-config-group { display: flex; align-items: center; gap: 0.5rem; } .rag-config-label { font-size: 0.875rem; font-weight: 500; margin: 0; } .rag-config-select { padding: 0.375rem 0.75rem; font-size: 0.875rem; border-radius: 0.25rem; border: 1px solid #ced4da; /* Bootstrap border */ background-color: #fff; min-width: 120px; } /* Toggle switch */ .rag-toggle { position: relative; display: inline-block; width: 40px; height: 24px; } .rag-toggle-input { opacity: 0; width: 0; height: 0; } .rag-toggle-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 24px; } .rag-toggle-slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; } .rag-toggle-input:checked + .rag-toggle-slider { background-color: #0d6efd; /* Bootstrap primary */ } .rag-toggle-input:checked + .rag-toggle-slider:before { transform: translateX(16px); } /* Uploader */ .rag-uploader { background-color: #f8f9fa; /* Bootstrap light */ border-radius: 0.375rem; padding: 1.5rem; margin-bottom: 1.5rem; border: 1px solid rgba(0, 0, 0, 0.125); } .rag-uploader-title { font-size: 1.25rem; font-weight: 500; margin-bottom: 1rem; } .rag-dropzone { border: 2px dashed #ced4da; /* Bootstrap border */ border-radius: 0.375rem; padding: 2rem; text-align: center; transition: all 0.3s ease; cursor: pointer; } .rag-dropzone.active { border-color: #0d6efd; /* Bootstrap primary */ background-color: rgba(13, 110, 253, 0.05); } .rag-dropzone-icon { font-size: 2.5rem; color: #6c757d; /* Bootstrap secondary */ margin-bottom: 1rem; } .rag-dropzone-text { color: #495057; /* Bootstrap dark */ margin-bottom: 1rem; } .rag-upload-btn { display: inline-block; font-weight: 500; padding: 0.375rem 0.75rem; font-size: 0.875rem; line-height: 1.5; border-radius: 0.25rem; color: #fff; background-color: #0d6efd; /* Bootstrap primary */ border: 1px solid #0d6efd; transition: all 0.15s ease; cursor: pointer; } .rag-upload-btn:hover { background-color: #0b5ed7; border-color: #0a58ca; } .rag-upload-hint { font-size: 0.75rem; color: #6c757d; /* Bootstrap secondary */ margin-top: 0.5rem; } /* Fullscreen viewer */ .rag-fullscreen { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.95); z-index: 1050; /* Bootstrap modal z-index */ display: flex; flex-direction: column; } .rag-fullscreen-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem; background-color: rgba(0, 0, 0, 0.5); } .rag-fullscreen-title { display: flex; align-items: center; gap: 0.5rem; color: #fff; } .rag-fullscreen-actions { display: flex; gap: 0.5rem; } .rag-fullscreen-btn { background-color: rgba(255, 255, 255, 0.1); color: #fff; width: 2.5rem; height: 2.5rem; border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s ease; } .rag-fullscreen-btn:hover { background-color: rgba(255, 255, 255, 0.2); } .rag-fullscreen-content { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; } .rag-fullscreen-image { max-height: 100%; max-width: 100%; object-fit: contain; transition: transform 0.3s ease; } .rag-fullscreen-image.zoomed { cursor: grab; } .rag-fullscreen-image.zoomed:active { cursor: grabbing; } .rag-fullscreen-nav-prev, .rag-fullscreen-nav-next { position: absolute; top: 50%; transform: translateY(-50%); background-color: rgba(0, 0, 0, 0.3); color: #fff; width: 3rem; height: 3rem; border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: all 0.2s ease; z-index: 10; } .rag-fullscreen-nav-prev { left: 1rem; } .rag-fullscreen-nav-next { right: 1rem; } .rag-fullscreen-nav-prev:hover, .rag-fullscreen-nav-next:hover { background-color: rgba(0, 0, 0, 0.5); } .rag-fullscreen-zoom-controls { position: absolute; bottom: 1rem; right: 1rem; display: flex; gap: 0.5rem; } .rag-fullscreen-footer { background-color: rgba(0, 0, 0, 0.5); padding: 1rem; } .rag-fullscreen-thumbnails { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.5rem; } .rag-fullscreen-thumbnail { width: 64px; height: 48px; border-radius: 0.25rem; overflow: hidden; cursor: pointer; border: 2px solid transparent; transition: all 0.2s ease; } .rag-fullscreen-thumbnail.active { border-color: #0d6efd; /* Bootstrap primary */ } .rag-fullscreen-thumbnail img { width: 100%; height: 100%; object-fit: cover; } .rag-fullscreen-metadata { margin-top: 0.5rem; color: rgba(255, 255, 255, 0.7); font-size: 0.875rem; } .rag-fullscreen-metadata p { margin: 0.25rem 0; } /* Animations */ .rag-fade-enter { opacity: 0; } .rag-fade-enter-active { opacity: 1; transition: opacity 500ms; } .rag-fade-exit { opacity: 1; } .rag-fade-exit-active { opacity: 0; transition: opacity 500ms; } .rag-slide-enter { transform: translateX(50px); opacity: 0; } .rag-slide-enter-active { transform: translateX(0); opacity: 1; transition: transform 500ms, opacity 500ms; } .rag-slide-exit { transform: translateX(0); opacity: 1; } .rag-slide-exit-active { transform: translateX(-50px); opacity: 0; transition: transform 500ms, opacity 500ms; } .rag-zoom-enter { transform: scale(0.8); opacity: 0; } .rag-zoom-enter-active { transform: scale(1); opacity: 1; transition: transform 500ms, opacity 500ms; } .rag-zoom-exit { transform: scale(1); opacity: 1; } .rag-zoom-exit-active { transform: scale(0.8); opacity: 0; transition: transform 500ms, opacity 500ms; } /* Dark mode */ .dark .rag-config, .dark .rag-uploader { background-color: #343a40; border-color: rgba(255, 255, 255, 0.125); } .dark .rag-config-subtitle { color: #adb5bd; } .dark .rag-config-select { background-color: #212529; border-color: #495057; color: #fff; } .dark .rag-item { background-color: #212529; border-color: rgba(255, 255, 255, 0.125); } .dark .rag-dropzone { border-color: #495057; } .dark .rag-dropzone.active { background-color: rgba(13, 110, 253, 0.15); } .dark .rag-dropzone-icon, .dark .rag-dropzone-text, .dark .rag-upload-hint { color: #adb5bd; } /* Bootstrap utility classes */ .rag-mt-0 { margin-top: 0 !important; } .rag-mb-0 { margin-bottom: 0 !important; } .rag-my-1 { margin-top: 0.25rem !important; margin-bottom: 0.25rem !important; } .rag-mb-2 { margin-bottom: 0.5rem !important; } .rag-mb-3 { margin-bottom: 1rem !important; } .rag-mb-4 { margin-bottom: 1.5rem !important; } .rag-d-flex { display: flex !important; } .rag-justify-content-between { justify-content: space-between !important; } .rag-align-items-center { align-items: center !important; } .rag-flex-column { flex-direction: column !important; } .rag-flex-row { flex-direction: row !important; } .rag-gap-1 { gap: 0.25rem !important; } .rag-gap-2 { gap: 0.5rem !important; } .rag-gap-3 { gap: 1rem !important; } /* For Bootstrap icons compatibility */ .rag-bi { display: inline-block; vertical-align: -0.125em; } /* Material icons fallback */ .rag-material-icons { font-family: 'Material Icons', 'Material Symbols Outlined', sans-serif; font-weight: normal; font-style: normal; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; word-wrap: normal; direction: ltr; -webkit-font-feature-settings: 'liga'; -webkit-font-smoothing: antialiased; }