11import React , { useRef , useState } from "react" ;
2- import type { Meta , StoryObj } from "@storybook/react" ;
3- import ReactSkinview3d from ".." ;
2+ import type { Meta , StoryObj } from "@storybook/react-vite " ;
3+ import { ReactSkinview3d } from ".." ;
44import type { SkinViewer } from "skinview3d" ;
55import { WalkingAnimation } from "skinview3d" ;
66
77const meta : Meta < typeof ReactSkinview3d > = {
88 title : "Examples" ,
99 component : ReactSkinview3d ,
1010 tags : [ "autodocs" ] ,
11+ argTypes : {
12+ width : {
13+ control : { type : "number" } ,
14+ description : "Width of the canvas in pixels" ,
15+ defaultValue : 150 ,
16+ } ,
17+ height : {
18+ control : { type : "number" } ,
19+ description : "Height of the canvas in pixels" ,
20+ defaultValue : 300 ,
21+ } ,
22+ skinUrl : {
23+ control : { type : "select" } ,
24+ options : [
25+ "textures/skin-legacyhat-default-no_hd.png" ,
26+ "textures/skin-1.8-default-no_hd.png" ,
27+ "textures/skin-1.8-slim-no_hd.png" ,
28+ "textures/skin-old-default-no_hd.png" ,
29+ ] ,
30+ description : "Select a skin texture to display" ,
31+ } ,
32+ capeUrl : {
33+ control : { type : "text" } ,
34+ description : "Optional URL of the Minecraft cape texture" ,
35+ } ,
36+ className : {
37+ control : { type : "text" } ,
38+ description : "CSS class names to apply to the canvas element" ,
39+ } ,
40+ onReady : {
41+ control : false ,
42+ description : "Callback function when the skin viewer is ready" ,
43+ } ,
44+ options : {
45+ control : false ,
46+ description : "Additional configuration options for skinview3d" ,
47+ } ,
48+ } ,
49+ args : {
50+ width : 150 ,
51+ height : 300 ,
52+ skinUrl : "textures/skin-legacyhat-default-no_hd.png" ,
53+ } ,
1154} satisfies Meta < typeof ReactSkinview3d > ;
1255
1356export default meta ;
1457type Story = StoryObj < typeof meta > ;
1558
1659export const Basic : Story = {
17- render : ( ) => {
18- return (
19- < ReactSkinview3d
20- skinUrl = "textures/skin-legacyhat-default-no_hd.png"
21- height = { 300 }
22- width = { 150 }
23- />
24- ) ;
60+ args : {
61+ skinUrl : "textures/skin-legacyhat-default-no_hd.png" ,
62+ height : 300 ,
63+ width : 150 ,
2564 } ,
2665} ;
2766
@@ -50,12 +89,15 @@ export const Multiple: Story = {
5089} ;
5190
5291export const Animation : Story = {
53- render : ( ) => (
92+ args : {
93+ className : "viewer" ,
94+ skinUrl : "textures/skin-legacyhat-default-no_hd.png" ,
95+ height : 300 ,
96+ width : 150 ,
97+ } ,
98+ render : ( args ) => (
5499 < ReactSkinview3d
55- className = "viewer"
56- skinUrl = "textures/skin-legacyhat-default-no_hd.png"
57- height = { 300 }
58- width = { 150 }
100+ { ...args }
59101 onReady = { ( { viewer } ) => {
60102 // Add an animation
61103 viewer . animation = new WalkingAnimation ( ) ;
@@ -66,6 +108,33 @@ export const Animation: Story = {
66108 ) ,
67109} ;
68110
111+ export const Interactive : Story = {
112+ args : {
113+ skinUrl : "textures/skin-legacyhat-default-no_hd.png" ,
114+ height : 300 ,
115+ width : 150 ,
116+ className : "viewer" ,
117+ } ,
118+ argTypes : {
119+ ...meta . argTypes ,
120+ skinUrl : {
121+ control : { type : "select" } ,
122+ options : [
123+ "textures/skin-legacyhat-default-no_hd.png" ,
124+ "textures/skin-1.8-default-no_hd.png" ,
125+ "textures/skin-1.8-slim-no_hd.png" ,
126+ "textures/skin-old-default-no_hd.png" ,
127+ ] ,
128+ description : "Select a skin texture to display" ,
129+ } ,
130+ capeUrl : {
131+ control : { type : "select" } ,
132+ options : [ "" , "textures/mojang-classic-cape.png" ] ,
133+ description : "Select a cape texture to display" ,
134+ } ,
135+ } ,
136+ } ;
137+
69138export const Screenshot : Story = {
70139 render : ( ) => {
71140 const [ url , setUrl ] = useState ( "" ) ;
0 commit comments