Skip to content

Commit 10a9855

Browse files
style:
add reproducable example of bug to VGrid.stories.tsx
1 parent c8ff71b commit 10a9855

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

.storybook/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default process.env.STORYBOOK_VUE
5151
}
5252
: {
5353
stories: ["../stories/react/**/*.stories.@(js|jsx|ts|tsx)"],
54-
addons: ["@storybook/addon-storysource"],
54+
addons: ["@storybook/addon-storysource", "@storybook/addon-viewport"],
5555
framework: {
5656
name: "@storybook/react-vite",
5757
options: {},

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
"@rollup/plugin-typescript": "^11.1.6",
8484
"@size-limit/preset-small-lib": "^11.1.6",
8585
"@storybook/addon-storysource": "^8.6.2",
86+
"@storybook/addon-viewport": "^8.6.4",
8687
"@storybook/docs-tools": "^8.6.2",
8788
"@storybook/react": "^8.6.2",
8889
"@storybook/react-vite": "^8.6.2",

stories/react/basics/VGrid.stories.tsx

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Meta, StoryObj } from "@storybook/react";
2-
import React, { useRef, useState } from "react";
2+
import React, {forwardRef, useRef, useState} from "react";
33
import { experimental_VGrid as VGrid, VGridHandle } from "../../../src";
4+
import {CustomCellComponent} from "../../../lib";
45

56
export default {
67
component: VGrid,
@@ -48,6 +49,59 @@ export const Fixed: StoryObj = {
4849
},
4950
};
5051

52+
export const FitToViewport: StoryObj = {
53+
render: () => {
54+
return (
55+
<VGrid style={{ height: "100vh" }} row={50} col={3}>
56+
{({ rowIndex, colIndex }) => (
57+
<div
58+
style={{
59+
border: "solid 1px gray",
60+
background: "white",
61+
padding: 4,
62+
width: '33vw',
63+
}}
64+
>
65+
{rowIndex} / {colIndex}
66+
</div>
67+
)}
68+
</VGrid>
69+
);
70+
},
71+
};
72+
73+
const Item: CustomCellComponent = forwardRef(({style: {minWidth: _minWidthUnused, minHeight: _minHeightUnused, ...style}, ...props}, ref) => {
74+
return <div {...props} style={style} ref={ref} />
75+
})
76+
77+
export const FitToViewportAdjusted: StoryObj = {
78+
render: () => {
79+
return (
80+
<VGrid
81+
style={{ height: "100vh" }}
82+
row={50}
83+
col={3}
84+
item={Item}
85+
>
86+
{({ rowIndex, colIndex }) => (
87+
<div
88+
style={{
89+
border: "solid 1px gray",
90+
background: "white",
91+
padding: 4,
92+
width: '33vw',
93+
}}
94+
>
95+
{rowIndex} / {colIndex}
96+
</div>
97+
)}
98+
</VGrid>
99+
);
100+
},
101+
};
102+
103+
104+
51105
export const DynamicHeight: StoryObj = {
52106
render: () => {
53107
return (

0 commit comments

Comments
 (0)