@@ -11,22 +11,27 @@ function Display({roomLabel, onSave}) {
11
11
const printRef = useRef ( null )
12
12
const blue = "#08467b"
13
13
const [ size , setSize ] = useState ( roomLabel ?. size || 0 )
14
- const [ lastId , setLastId ] = useState ( null )
14
+ const [ format , setFormat ] = useState ( 'square' )
15
+ const [ lastId , setLastId ] = useState ( null )
15
16
16
17
if ( lastId !== roomLabel . _id ) {
17
18
setLastId ( roomLabel . _id )
18
19
setSize ( roomLabel ?. size || 0 )
19
20
}
20
21
22
+ const dimensions = format === 'square'
23
+ ? { width : "15cm" , height : "15cm" }
24
+ : { width : "16cm" , height : "9cm" }
25
+
21
26
function sanitize ( str ) {
22
27
return str . replace ( / & / g, '&' ) . replace ( / < / g, '<' ) . replace ( / > / g, '>' ) . replace ( / " / g, '"' )
23
28
}
24
29
25
30
return < >
26
31
< div ref = { printRef }
27
32
style = { {
28
- height : "15cm" ,
29
- width : "15cm" ,
33
+ height : dimensions . height ,
34
+ width : dimensions . width ,
30
35
borderStyle : "solid" ,
31
36
borderColor : "#eee" ,
32
37
borderWidth : "1px" ,
@@ -35,30 +40,30 @@ function Display({roomLabel, onSave}) {
35
40
printColorAdjust : "exact"
36
41
} } >
37
42
< img alt = "" style = { {
38
- height : "3cm" ,
43
+ height : format === 'square' ? "3cm" : "2.5cm ",
39
44
opacity : "0.8" ,
40
45
marginTop : "0.2cm" ,
41
46
marginLeft : "0.2cm" ,
42
47
marginBottom : "-0.2cm"
43
48
} } src = "/img/matematica_dx.svg" />
44
49
< div style = { {
45
- height :"13cm" ,
46
- marginTop :"-2cm"
50
+ height : format === 'square' ? "13cm" : "7cm ",
51
+ marginTop : "-2cm"
47
52
} } >
48
53
< div ref = { namesRef }
49
54
contentEditable = "true" style = { {
50
55
color : blue ,
51
56
textAlign : "center" ,
52
57
fontSize : `${ Math . round ( 100 * Math . pow ( 2 , size / 2 ) ) / 100 } cm` ,
53
58
position : "relative" ,
54
- top : "50%" ,
59
+ top : format === 'square' ? "50%" : "55 %",
55
60
transform : "translateY(-50%)" ,
56
61
} }
57
62
dangerouslySetInnerHTML = { { __html : roomLabel . names . map (
58
63
name => `<div>${ sanitize ( name ) } </div>` ) . join ( '' ) } } />
59
64
</ div >
60
65
< div style = { {
61
- marginTop : "-4cm" ,
66
+ marginTop : format === 'square' ? "-4cm" : "-3cm ",
62
67
marginRight : "0.5cm"
63
68
} } >
64
69
< div ref = { numberRef }
@@ -72,17 +77,17 @@ function Display({roomLabel, onSave}) {
72
77
textAlign : "right" ,
73
78
paddingTop : ".5cm" ,
74
79
paddingRight : "0.1cm" ,
75
- marginTop : "2cm" ,
80
+ marginTop : format === 'square' ? "2cm" : "1.5cm ",
76
81
float : "left"
77
82
} }
78
83
dangerouslySetInnerHTML = { { __html : sanitize ( roomLabel . number ) } }
79
84
/>
80
85
< img alt = "" style = { {
81
- height : "8cm" ,
86
+ height : format === 'square' ? "8cm" : "6cm ",
82
87
position : "relative" ,
83
88
float : "right" ,
84
89
opacity : "0.12" ,
85
- marginTop : "-3.2cm" ,
90
+ marginTop : format === 'square' ? "-3.2cm" : "-1.7cm ",
86
91
marginRight : "-0.4cm" ,
87
92
pointerEvents : "none"
88
93
} } src = "/img/cherubino_pant541.png" />
@@ -97,15 +102,19 @@ function Display({roomLabel, onSave}) {
97
102
< Button onClick = { ( ) => {
98
103
const names = [ ...namesRef . current . children ] . map ( child => child . textContent )
99
104
const number = numberRef . current . textContent
100
- onSave ( { names, number, size} )
105
+ onSave ( { names, number, size, format } )
101
106
} } > aggiungi ai cartellini da fare</ Button > }
102
- < select value = { size } onChange = { e => setSize ( e . target . value ) } >
107
+ < select value = { size } onChange = { e => setSize ( e . target . value ) } >
103
108
< option value = "2" > scritta molto grande</ option >
104
109
< option value = "1" > scritta grande</ option >
105
110
< option value = "0" > scritta di dimensione normale</ option >
106
111
< option value = "-1" > scritta piccola</ option >
107
112
< option value = "-2" > scritta molto piccola</ option >
108
113
</ select >
114
+ < select value = { format } onChange = { e => setFormat ( e . target . value ) } >
115
+ < option value = "square" > formato quadrato</ option >
116
+ < option value = "rectangular" > formato rettangolare</ option >
117
+ </ select >
109
118
</ ButtonGroup >
110
119
</ >
111
120
}
0 commit comments