@@ -17,12 +17,10 @@ pub struct Props {
17
17
18
18
pub struct ImageComponent {
19
19
width : usize ,
20
- height : usize ,
21
20
}
22
21
23
22
pub enum Msg {
24
23
Width ( Event ) ,
25
- Height ( Event ) ,
26
24
}
27
25
28
26
impl ImageComponent {
@@ -36,7 +34,7 @@ impl ImageComponent {
36
34
let palette = palette_from_abbr ( "cga0" ) ;
37
35
let mut bytes: Vec < u8 > = Vec :: new ( ) ;
38
36
39
- let _ = png:: write_to ( & mut bytes, tile ( image. data ( ) , self . height ) , palette. clone ( ) ) ;
37
+ let _ = png:: write_to ( & mut bytes, image. data ( ) , palette. clone ( ) ) ;
40
38
bytes
41
39
} ;
42
40
format ! ( "data:application/png;base64,{}" , STANDARD . encode( data) )
@@ -54,13 +52,13 @@ impl ImageComponent {
54
52
let palette = palette_from_abbr ( "cga0" ) ;
55
53
let mut bytes: Vec < u8 > = Vec :: new ( ) ;
56
54
57
- let _ = png:: write_to ( & mut bytes, tile ( p. data ( ) , self . height ) , palette. clone ( ) ) ;
55
+ let _ = png:: write_to ( & mut bytes, p. data ( ) , palette. clone ( ) ) ;
58
56
let src = format ! ( "data:application/png;base64,{}" , STANDARD . encode( bytes) ) ;
59
57
html ! {
60
- <span >
61
- { p. width( ) }
58
+ <div class= "preview-tile" >
59
+ <h3> { p. width( ) } </h3>
62
60
<img src={ src } />
63
- </span >
61
+ </div >
64
62
}
65
63
} )
66
64
. collect ( )
@@ -75,7 +73,6 @@ impl Component for ImageComponent {
75
73
fn create ( _ctx : & Context < Self > ) -> Self {
76
74
Self {
77
75
width : 320 ,
78
- height : 200 ,
79
76
}
80
77
}
81
78
@@ -85,10 +82,6 @@ impl Component for ImageComponent {
85
82
let input: HtmlInputElement = e. target_unchecked_into ( ) ;
86
83
self . width = input. value ( ) . parse ( ) . expect ( "fail to parse width" ) ;
87
84
}
88
- Msg :: Height ( e) => {
89
- let input: HtmlInputElement = e. target_unchecked_into ( ) ;
90
- self . height = input. value ( ) . parse ( ) . expect ( "fail to parse width" ) ;
91
- }
92
85
}
93
86
true
94
87
}
@@ -101,19 +94,19 @@ impl Component for ImageComponent {
101
94
102
95
html ! {
103
96
<>
104
- <div class="preview-tile " >
97
+ <div class="preview-tile" >
105
98
<div class=".preview-media" >
106
99
<p class="preview-name" >{ file. name. to_string( ) } </p>
107
100
<img src={ self . src( file) } />
108
101
</div>
109
102
<form onsubmit={ noop} >
110
- <label for ="width" >{ "[Tile] Width" } </label>
103
+ <label for ="width" >{ "Width" } </label>
111
104
<input name="width" type ="number" value={ self . width. to_string( ) } onchange={ ctx. link( ) . callback( Msg :: Width ) } />
112
- <label for ="height" >{ "[Tile] Height" } </label>
113
- <input name="height" type ="number" value={ self . height. to_string( ) } onchange={ ctx. link( ) . callback( Msg :: Height ) } />
114
105
</form>
115
106
</div>
116
- { self . previews( file) }
107
+ <div class="preview-row" >
108
+ { self . previews( file) }
109
+ </div>
117
110
</>
118
111
}
119
112
}
0 commit comments