//! File previews: browser-native media (image/PDF/video/audio), full page,
//! or a download prompt for kinds with no viewer. Text files open in the
//! editor instead.
use api_types::FileKind;
use leptos::prelude::*;
use crate::api;
use crate::components::icon::icon_svg;
use crate::i18n;
use crate::icons::{IconName, icon_for};
use crate::views::file_view::FileView;
/// Whether this kind opens in the media preview. Text goes to the editor,
/// archives and binaries get the "no preview" view.
pub fn is_media(kind: FileKind) -> bool {
matches!(
kind,
FileKind::Image | FileKind::Pdf | FileKind::Video | FileKind::Audio
)
}
/// The full-page preview (closing lives in the top bar).
#[component]
pub fn Preview(target: FileView) -> impl IntoView {
let url = api::preview_url(target.root_id, &target.path);
let name = target.name.clone();
let media = match target.kind {
FileKind::Image => view! { }.into_any(),
FileKind::Pdf => view! {