@@ -32,7 +32,7 @@ const ChengduMetroBasicStation = (props: StationComponentProps) => {
32
32
nameOffsetY = defaultChengduMetroBasicStationAttributes . nameOffsetY ,
33
33
color = defaultChengduMetroBasicStationAttributes . color ,
34
34
direction = defaultChengduMetroBasicStationAttributes . direction ,
35
- type = defaultChengduMetroBasicStationAttributes . type ,
35
+ stationType = defaultChengduMetroBasicStationAttributes . stationType ,
36
36
} = attrs [ StationType . ChengduMetroBasic ] ?? defaultChengduMetroBasicStationAttributes ;
37
37
38
38
const onPointerDown = React . useCallback (
@@ -48,48 +48,53 @@ const ChengduMetroBasicStation = (props: StationComponentProps) => {
48
48
[ id , handlePointerUp ]
49
49
) ;
50
50
51
- const getTextOffset = ( oX : NameOffsetX , oY : NameOffsetY ) => {
51
+ const getTextOffset = ( ) => {
52
+ const [ oX , oY ] = [ nameOffsetX , nameOffsetY ] ;
52
53
if ( direction === 'horizontal' ) {
53
54
if ( oX === 'left' && oY === 'top' ) {
54
55
return [
55
- - 5 - ( type == 'tram' ? 4 : type == 'joint' ? 2 : 0 ) ,
56
+ - 5 - ( stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0 ) ,
56
57
- names [ 1 ] . split ( '\n' ) . length * LINE_HEIGHT [ oY ] - 3 ,
57
58
] ;
58
59
} else if ( oX === 'middle' && oY === 'top' ) {
59
60
return [
60
61
0 ,
61
- - names [ 1 ] . split ( '\n' ) . length * LINE_HEIGHT [ oY ] - 5 - ( type == 'tram' ? 4 : type == 'joint' ? 2 : 0 ) ,
62
+ - names [ 1 ] . split ( '\n' ) . length * LINE_HEIGHT [ oY ] -
63
+ 5 -
64
+ ( stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0 ) ,
62
65
] ;
63
66
} else if ( oX === 'right' && oY === 'top' ) {
64
67
return [
65
- 5 + ( type == 'tram' ? 4 : type == 'joint' ? 2 : 0 ) ,
68
+ 5 + ( stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0 ) ,
66
69
- names [ 1 ] . split ( '\n' ) . length * LINE_HEIGHT [ oY ] - 3 ,
67
70
] ;
68
71
} else if ( oX === 'left' && oY === 'bottom' ) {
69
72
return [
70
- - 5 - ( type == 'tram' ? 4 : type == 'joint' ? 2 : 0 ) ,
73
+ - 5 - ( stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0 ) ,
71
74
names [ 0 ] . split ( '\n' ) . length * LINE_HEIGHT [ oY ] + 3 ,
72
75
] ;
73
76
} else if ( oX === 'middle' && oY === 'bottom' ) {
74
77
return [
75
78
0 ,
76
- names [ 0 ] . split ( '\n' ) . length * LINE_HEIGHT [ oY ] + 5 + ( type == 'tram' ? 4 : type == 'joint' ? 2 : 0 ) ,
79
+ names [ 0 ] . split ( '\n' ) . length * LINE_HEIGHT [ oY ] +
80
+ 5 +
81
+ ( stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0 ) ,
77
82
] ;
78
83
} else if ( oX === 'right' && oY === 'bottom' ) {
79
84
return [
80
- 5 + ( type == 'tram' ? 4 : type == 'joint' ? 2 : 0 ) ,
85
+ 5 + ( stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0 ) ,
81
86
names [ 0 ] . split ( '\n' ) . length * LINE_HEIGHT [ oY ] + 3 ,
82
87
] ;
83
88
} else if ( oX === 'left' && oY === 'middle' ) {
84
- return [ - 5 - ( type == 'tram' ? 4 : type == 'joint' ? 2 : 0 ) , 2 ] ;
89
+ return [ - 5 - ( stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0 ) , 2 ] ;
85
90
} else if ( oX === 'right' && oY === 'middle' ) {
86
- return [ 5 + ( type == 'tram' ? 4 : type == 'joint' ? 2 : 0 ) , 2 ] ;
91
+ return [ 5 + ( stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0 ) , 2 ] ;
87
92
} else return [ 0 , 0 ] ;
88
93
} else {
89
94
if ( oX === 'middle' && oY === 'top' ) {
90
- return [ - LINE_HEIGHT . zh / 2 , - 5 - ( type == 'tram' ? 4 : type == 'joint' ? 2 : 0 ) ] ;
95
+ return [ - LINE_HEIGHT . zh / 2 , - 5 - ( stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0 ) ] ;
91
96
} else if ( oX === 'middle' && oY === 'bottom' ) {
92
- return [ - LINE_HEIGHT . zh / 2 , 5 + ( type == 'tram' ? 4 : type == 'joint' ? 2 : 0 ) ] ;
97
+ return [ - LINE_HEIGHT . zh / 2 , 5 + ( stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0 ) ] ;
93
98
} else return [ 0 , 0 ] ;
94
99
}
95
100
} ;
@@ -114,7 +119,7 @@ const ChengduMetroBasicStation = (props: StationComponentProps) => {
114
119
} else return [ 0 , 0 , 0 , 0 ] ;
115
120
} ;
116
121
117
- const [ textX , textY ] = getTextOffset ( nameOffsetX , nameOffsetY ) ;
122
+ const [ textX , textY ] = getTextOffset ( ) ;
118
123
const [ tramX1 , tramX2 , tramY1 , tramY2 ] = getTramPos ( nameOffsetX , nameOffsetY ) ;
119
124
const textAnchor =
120
125
direction == 'vertical'
@@ -131,19 +136,19 @@ const ChengduMetroBasicStation = (props: StationComponentProps) => {
131
136
132
137
return (
133
138
< g id = { id } transform = { `translate(${ x } , ${ y } )` } >
134
- { type == 'normal' || type == 'branchTerminal' ? (
139
+ { stationType == 'normal' || stationType == 'branchTerminal' ? (
135
140
< circle
136
141
id = { `stn_core_${ id } ` }
137
- r = { type == 'normal' ? 1.75 : 5 }
142
+ r = { stationType == 'normal' ? 1.75 : 5 }
138
143
stroke = { color [ 2 ] }
139
- strokeWidth = { type == 'normal' ? 1 : 0.5 }
144
+ strokeWidth = { stationType == 'normal' ? 1 : 0.5 }
140
145
fill = "white"
141
146
onPointerDown = { onPointerDown }
142
147
onPointerMove = { onPointerMove }
143
148
onPointerUp = { onPointerUp }
144
149
style = { { cursor : 'move' } }
145
150
/>
146
- ) : type == 'joint' ? (
151
+ ) : stationType == 'joint' ? (
147
152
< g
148
153
transform = { direction == 'vertical' ? 'rotate(90)' : '' }
149
154
id = { `stn_core_${ id } ` }
@@ -223,14 +228,6 @@ const ChengduMetroBasicStation = (props: StationComponentProps) => {
223
228
className = "rmp-name__en"
224
229
dominantBaseline = "central"
225
230
/>
226
- < MultilineText
227
- text = { names [ 1 ] . split ( '\n' ) }
228
- fontSize = { LINE_HEIGHT . en }
229
- lineHeight = { LINE_HEIGHT . en }
230
- grow = "up"
231
- className = "rmp-name__en"
232
- dominantBaseline = "central"
233
- />
234
231
</ g >
235
232
</ >
236
233
) }
@@ -245,7 +242,7 @@ export interface ChengduMetroBasicStationAttributes extends StationAttributes, A
245
242
nameOffsetX : NameOffsetX ;
246
243
nameOffsetY : NameOffsetY ;
247
244
direction : 'vertical' | 'horizontal' ;
248
- type : 'normal' | 'joint' | 'branchTerminal' | 'tram' ;
245
+ stationType : 'normal' | 'joint' | 'branchTerminal' | 'tram' ;
249
246
}
250
247
251
248
const defaultChengduMetroBasicStationAttributes : ChengduMetroBasicStationAttributes = {
@@ -254,7 +251,7 @@ const defaultChengduMetroBasicStationAttributes: ChengduMetroBasicStationAttribu
254
251
nameOffsetX : 'right' ,
255
252
nameOffsetY : 'top' ,
256
253
direction : 'horizontal' ,
257
- type : 'normal' ,
254
+ stationType : 'normal' ,
258
255
} ;
259
256
260
257
const ChengduMetroBasicAttrsComponent = ( props : AttrsProps < ChengduMetroBasicStationAttributes > ) => {
@@ -264,7 +261,7 @@ const ChengduMetroBasicAttrsComponent = (props: AttrsProps<ChengduMetroBasicStat
264
261
{
265
262
type : 'textarea' ,
266
263
label : t ( 'panel.details.stations.common.nameZh' ) ,
267
- value : ( attrs ?? defaultChengduMetroBasicStationAttributes ) . names [ 0 ] ,
264
+ value : ( attrs . names ?? defaultChengduMetroBasicStationAttributes . names ) [ 0 ] ,
268
265
onChange : val => {
269
266
attrs . names [ 0 ] = val . toString ( ) ;
270
267
handleAttrsUpdate ( id , attrs ) ;
@@ -336,16 +333,16 @@ const ChengduMetroBasicAttrsComponent = (props: AttrsProps<ChengduMetroBasicStat
336
333
} ,
337
334
{
338
335
type : 'select' ,
339
- label : t ( 'panel.details.stations.chengduMetroBasic.type .displayName' ) ,
340
- value : ( attrs ?? defaultChengduMetroBasicStationAttributes ) . type ,
336
+ label : t ( 'panel.details.stations.chengduMetroBasic.stationType .displayName' ) ,
337
+ value : ( attrs ?? defaultChengduMetroBasicStationAttributes ) . stationType ,
341
338
options : {
342
- normal : t ( 'panel.details.stations.chengduMetroBasic.type .normal' ) ,
343
- joint : t ( 'panel.details.stations.chengduMetroBasic.type .joint' ) ,
344
- branchTerminal : t ( 'panel.details.stations.chengduMetroBasic.type .branchTerminal' ) ,
345
- tram : t ( 'panel.details.stations.chengduMetroBasic.type .tram' ) ,
339
+ normal : t ( 'panel.details.stations.chengduMetroBasic.stationType .normal' ) ,
340
+ joint : t ( 'panel.details.stations.chengduMetroBasic.stationType .joint' ) ,
341
+ branchTerminal : t ( 'panel.details.stations.chengduMetroBasic.stationType .branchTerminal' ) ,
342
+ tram : t ( 'panel.details.stations.chengduMetroBasic.stationType .tram' ) ,
346
343
} ,
347
344
onChange : val => {
348
- attrs . type = val as 'normal' | 'joint' | 'branchTerminal' ;
345
+ attrs . stationType = val as 'normal' | 'joint' | 'branchTerminal' ;
349
346
handleAttrsUpdate ( id , attrs ) ;
350
347
} ,
351
348
minW : 'full' ,
0 commit comments