Skip to content

Commit

Permalink
Fix: The video aspect ratio (maybe)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fantasy-programming committed May 19, 2024
1 parent e8c33d0 commit b4f4797
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "only-refs",
"version": "0.0.5",
"version": "0.0.6",
"description": "",
"type": "module",
"scripts": {
Expand Down Expand Up @@ -84,3 +84,4 @@
"vitest": "^1.6.0"
}
}

2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "only-refs"
version = "0.0.5"
version = "0.0.6"
description = "All your references in a single place"
authors = ["Ngobo Ridy"]
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"package": {
"productName": "only-refs",
"version": "0.0.5"
"version": "0.0.6"
},
"tauri": {
"allowlist": {
Expand Down
22 changes: 22 additions & 0 deletions src/components/ViewBox/ViewBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ import { ViewBoxZoom } from './ViewBoxZoom';
import { isMediaRef } from '~/lib/helper';

export const ViewBox: Component<ParentProps & { source: Ref }> = (props) => {
let videoRef: HTMLVideoElement | undefined;

const [videoDimensions, setVideoDimensions] = createSignal({
width: 0,
height: 0,
});

const handleVideoLoadedMetadata = () => {
if (videoRef) {
setVideoDimensions({
width: videoRef.videoWidth,
height: videoRef.videoHeight,
});
}
};

return (
<DialogContent
class={
Expand All @@ -33,12 +49,18 @@ export const ViewBox: Component<ParentProps & { source: Ref }> = (props) => {
<Switch>
<Match when={props.source.metadata.ref_type === 'video'}>
<video
ref={(el) => (videoRef = el)}
class="aspect-video h-auto w-auto rounded-xl"
src={(props.source as VideoRef).video_path}
preload="auto"
autoplay
controls
loop
onLoadedMetadata={handleVideoLoadedMetadata}
style={{
'max-width': `min(100%, ${videoDimensions().width}px)`,
'max-height': `min(100%, ${videoDimensions().height}px)`,
}}
></video>
</Match>
<Match when={props.source.metadata.ref_type === 'image'}>
Expand Down
10 changes: 7 additions & 3 deletions src/components/ViewBox/ViewBoxInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ export const ViewBoxInfo = (props: ViewBoxInfoProps) => {
/>
<span class="text-sm">{elapsedTime(props.metadata.created_at)}</span>
</header>
<div class="p-4">
<div
class="overflow-y-scroll p-4"
style={{
height: 'calc(100% - 148px - 64px)',
}}
>
<h4 class="text-lg uppercase">Tags</h4>
<div class="my-3 transition-all">
<Presence>
Expand Down Expand Up @@ -153,8 +158,7 @@ export const ViewBoxInfo = (props: ViewBoxInfoProps) => {
</div>
<Show
when={
(props.metadata.ref_type === 'image' ||
props.metadata.ref_type === 'video') &&
props.metadata.ref_type === 'image' &&
settings.appearance.show_media_info
}
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ViewBox/ViewNoteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const ViewNoteEditor = (props: {
}));

return (
<div class="onlyrefNoise flex h-full w-full flex-col items-center overflow-x-hidden overscroll-y-contain bg-foreground/5">
<div class="onlyrefNoise flex h-full w-full flex-col items-center overflow-x-hidden overscroll-y-contain rounded-lg bg-foreground/5">
<div
ref={setContainer}
class="m-auto w-full hyphens-auto break-words p-2"
Expand Down

0 comments on commit b4f4797

Please sign in to comment.