alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
75 lines (71 loc) • 3 kB
JavaScript
import {
prettyBytes
} from "../../../chunks/chunk-VRNNS7VT.js";
import "../../../chunks/chunk-U5RRZUYZ.js";
// src/dashboard/view/media/FileEntry.tsx
import { Media } from "alinea/backend/Media";
import { Typo, fromModule } from "alinea/ui";
import { Main } from "alinea/ui/Main";
import { Property } from "alinea/ui/Property";
import { useNav } from "../../hook/UseNav.js";
import { EntryHeader } from "../entry/EntryHeader.js";
import { EntryTitle } from "../entry/EntryTitle.js";
// src/dashboard/view/media/FileEntry.module.scss
var FileEntry_module_default = {
"root": "alinea-FileEntry"
};
// src/dashboard/view/media/FileEntry.tsx
import { jsx, jsxs } from "react/jsx-runtime";
var styles = fromModule(FileEntry_module_default);
function ImageView({ editor }) {
const image = editor.activeVersion;
return /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx("img", { src: image.data.preview }),
/* @__PURE__ */ jsx(Property, { label: "Extension", children: image.data.extension }),
/* @__PURE__ */ jsx(Property, { label: "File size", children: prettyBytes(image.data.size) }),
/* @__PURE__ */ jsxs(Property, { label: "Dimensions", children: [
image.data.width,
" x ",
image.data.height,
" pixels"
] }),
/* @__PURE__ */ jsx(Property, { label: "URL", children: /* @__PURE__ */ jsx(Typo.Monospace, { children: Media.ORIGINAL_LOCATION in image.data ? image.data[Media.ORIGINAL_LOCATION] : image.data.location }) }),
image.data.focus && /* @__PURE__ */ jsxs(Property, { label: "Focus", children: [
"(",
image.data.focus.x.toFixed(2),
", ",
image.data.focus.y.toFixed(2),
")"
] })
] });
}
function FileView({ editor }) {
const file = editor.activeVersion;
return /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx(Property, { label: "Extension", children: file.data.extension }),
/* @__PURE__ */ jsx(Property, { label: "File size", children: prettyBytes(file.data.size) }),
/* @__PURE__ */ jsx(Property, { label: "URL", children: /* @__PURE__ */ jsx(Typo.Monospace, { children: Media.ORIGINAL_LOCATION in file.data ? file.data[Media.ORIGINAL_LOCATION] : file.data.location }) })
] });
}
function FileEntry(props) {
const nav = useNav();
const { editor } = props;
const isImage = Media.isImage(editor.activeVersion.data.extension);
return /* @__PURE__ */ jsxs(Main, { className: styles.root(), children: [
/* @__PURE__ */ jsx(EntryHeader, { editable: false, editor }),
/* @__PURE__ */ jsx(
EntryTitle,
{
editor,
backLink: editor.activeVersion.parent ? nav.entry({
entryId: editor.activeVersion.parent,
workspace: editor.activeVersion.workspace
}) : nav.entry({ entryId: void 0 })
}
),
/* @__PURE__ */ jsx(Main.Container, { children: isImage ? /* @__PURE__ */ jsx(ImageView, { ...props }) : /* @__PURE__ */ jsx(FileView, { ...props }) })
] });
}
export {
FileEntry
};