Skip to content

Commit 5a31c8a

Browse files
committed
chore: 🎨 storybook objkt display
1 parent d650c30 commit 5a31c8a

File tree

3 files changed

+111
-11
lines changed

3 files changed

+111
-11
lines changed

‎.storybook/main.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ const config: StorybookConfig = {
1111
name: '@storybook/react-vite',
1212
options: {},
1313
},
14+
1415
core: {
1516
disableTelemetry: true,
1617
enableCrashReports: true,
1718
},
18-
19+
typescript: {
20+
reactDocgen: 'react-docgen-typescript',
21+
reactDocgenTypescriptOptions: {
22+
shouldExtractLiteralValuesFromEnum: true,
23+
propFilter: (prop) =>
24+
prop.parent ? !/node_modules/.test(prop.parent.fileName) : true,
25+
},
26+
},
1927
docs: {
2028
defaultName: 'Documentation',
2129
autodocs: true,

‎src/components/media-types/index.tsx

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,29 @@ import { MD } from './md'
1515
import { useMemo } from 'react'
1616
import { NFT } from '@types'
1717

18+
interface RenderMediaTypeProps {
19+
/**The nft with the core fragments*/
20+
nft: NFT
21+
/**When minting this is a base64 (or ObjectURL) representation of the image/video */
22+
previewUri?: string
23+
/**When minting this is a base64 (or ObjectURL) representation of the cover image/video */
24+
previewDisplayUri?: string
25+
/**false on feeds, true on objkt detail view. */
26+
displayView?: boolean
27+
/**hacky way to pass the details hover for now... */
28+
details?: JSX.Element | JSX.Element[]
29+
}
30+
1831
/**
19-
* Method that handles the rendering of any of the supported
20-
* media types.
32+
* Method that handles the rendering of any of the supported media types.
2133
*/
22-
2334
export const RenderMediaType = ({
2435
nft,
2536
previewUri,
2637
previewDisplayUri,
2738
displayView,
2839
details,
29-
}: {
30-
nft: NFT
31-
previewUri?: string
32-
previewDisplayUri?: string
33-
displayView?: boolean
34-
details?: JSX.Element | JSX.Element[]
35-
}) => {
40+
}: RenderMediaTypeProps) => {
3641
const [forceArtifact, setForceArtifact] = useState(false)
3742
const parsedArtifactUri = useMemo(
3843
() =>
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { FeedItem } from '@components/feed-item/index'
2+
import { ItemInfo } from '@components/item-info'
3+
import { RenderMediaType } from '@components/media-types'
4+
import { fetchObjktDetails } from '@data/api'
5+
import type { Meta, StoryObj } from '@storybook/react'
6+
7+
const meta: Meta<typeof RenderMediaType> = {
8+
title: 'Components/RenderMediaType',
9+
component: RenderMediaType,
10+
11+
tags: ['autodocs'],
12+
13+
argTypes: {},
14+
}
15+
16+
const Decorator = (Story, context) => {
17+
const nft = context.loaded.data
18+
19+
return (
20+
<>
21+
<div>
22+
<Story />
23+
</div>
24+
{/* {nft && <ItemInfo nft={nft} />} */}
25+
</>
26+
)
27+
}
28+
29+
export default meta
30+
type Story = StoryObj<typeof RenderMediaType>
31+
32+
export const Image: Story = {
33+
render: (args, { loaded: { data } }) => (
34+
<RenderMediaType nft={data} displayView />
35+
),
36+
decorators: [Decorator],
37+
loaders: [
38+
async () => ({
39+
data: await fetchObjktDetails('683366'),
40+
}),
41+
],
42+
}
43+
44+
export const Glb: Story = {
45+
render: (args, { loaded: { data } }) => (
46+
<RenderMediaType nft={data} displayView />
47+
),
48+
decorators: [Decorator],
49+
loaders: [
50+
async () => ({
51+
data: await fetchObjktDetails('809877'),
52+
}),
53+
],
54+
}
55+
export const Video: Story = {
56+
render: (args, { loaded: { data } }) => (
57+
<RenderMediaType nft={data} displayView />
58+
),
59+
decorators: [Decorator],
60+
loaders: [
61+
async () => ({
62+
data: await fetchObjktDetails('812969'),
63+
}),
64+
],
65+
}
66+
export const Interactive: Story = {
67+
render: (args, { loaded: { data } }) => (
68+
<RenderMediaType nft={data} displayView />
69+
),
70+
decorators: [Decorator],
71+
loaders: [
72+
async () => ({
73+
data: await fetchObjktDetails('808428'),
74+
}),
75+
],
76+
}
77+
export const Smol: Story = {
78+
render: (args, { loaded: { data } }) => (
79+
<RenderMediaType nft={data} displayView />
80+
),
81+
decorators: [Decorator],
82+
loaders: [
83+
async () => ({
84+
data: await fetchObjktDetails('378074'),
85+
}),
86+
],
87+
}

0 commit comments

Comments
 (0)