Skip to content

Commit

Permalink
Nothing to see here
Browse files Browse the repository at this point in the history
  • Loading branch information
eyeseast committed Feb 13, 2024
1 parent 33cdbbd commit b284901
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/pages/viewer/ThumbnailBody.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,23 @@
let containerHeight = null;
let container = null;
let containerScrollTop = 0;
const itemWidth = 144;
const itemHeight = 179;
const MAX_THUMB_WIDTH = 84;
const MAX_THUMB_HEIGHT = 119;
$: itemsPerRow =
containerWidth == null
? null
: Math.max(Math.floor((containerWidth - 60) / itemWidth), 1);
$: paddingLeft =
containerWidth == null || itemsPerRow == null
? 0
: (containerWidth - itemsPerRow * itemWidth) / 2 + (modify ? -5 : -15);
$: paddingTop =
startPage == null || itemsPerRow == null
? 0
Expand All @@ -48,13 +55,15 @@
);
}
}
$: startPage =
itemsPerRow == null
? null
: Math.min(
Math.floor(containerScrollTop / itemHeight) * itemsPerRow,
$modification.pageCount,
);
$: endPage =
itemsPerRow == null || containerHeight == null
? null
Expand All @@ -63,14 +72,17 @@
itemsPerRow,
$modification.pageCount,
);
$: overallHeight =
itemsPerRow == null
? null
: Math.ceil($modification.pageCount / itemsPerRow) * itemHeight;
$: paddingBottom =
overallHeight == null || endPage == null || itemsPerRow == null
? 0
: overallHeight - Math.ceil(endPage / itemsPerRow) * itemHeight;
$: pages =
startPage == null ||
endPage == null ||
Expand Down Expand Up @@ -130,9 +142,6 @@
[page]: selectState,
};
}
const MAX_THUMB_WIDTH = 84;
const MAX_THUMB_HEIGHT = 119;
</script>

<ActionPane bind:actionHeight />
Expand Down
35 changes: 35 additions & 0 deletions src/pages/viewer/stories/ModifyImage.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script context="module">
import { Story, Template } from "@storybook/addon-svelte-csf";
import ModifyImage from "../ModifyImage.svelte";
import { Document } from "@/structure/document.js";
import { viewer } from "@/viewer/viewer.js";
import { ModificationDescriptor } from "@/viewer/modification/modifySpec.js";
import document from "../fixtures/document.json";
viewer.doc = new Document(document);
export const meta = {
title: "Viewer / Modify Image",
component: ModifyImage,
tags: ["autodocs"],
parameters: { layout: "centered" },
};
const MAX_THUMB_WIDTH = 84;
const MAX_THUMB_HEIGHT = 119;
const args = {
id: document.id,
size: 140,
maxThumb: [MAX_THUMB_WIDTH, MAX_THUMB_HEIGHT],
descriptor: new ModificationDescriptor(),
};
</script>

<Template let:args>
<ModifyImage {...args} />
</Template>

<Story name="default" {args} />
15 changes: 15 additions & 0 deletions src/pages/viewer/stories/ThumbnailBody.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script context="module">
import { Story } from "@storybook/addon-svelte-csf";
import ThumbnailBody from "../ThumbnailBody.svelte";
export const meta = {
title: "Viewer / Thumbnail Body",
component: ThumbnailBody,
tags: ["autodocs"],
parameters: { layout: "centered" },
};
</script>

<Story name="default">
<ThumbnailBody />
</Story>
2 changes: 1 addition & 1 deletion src/viewer/modification/modifySpec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
CLOCKWISE,
COUNTER_CLOCKWISE,
HALFWAY,
} from "./modifySpec";
} from "./modifySpec.js";

function runspec(pgNumbers) {
return runify(pgNumbers).spec();
Expand Down

0 comments on commit b284901

Please sign in to comment.