Skip to content

Commit 219b2cf

Browse files
committed
chore: fix problems in pr
1 parent bc2a5b4 commit 219b2cf

10 files changed

+117
-129
lines changed

src/components/svgs/lines/styles/chengdumetro-outside-fare-gates.tsx

+1-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@ const ChengduMetroOutsideFareGates = (props: LineStyleComponentProps<ChengduMetr
3232
*/
3333
export interface ChengduMetroOutsideFareGatesAttributes extends LinePathAttributes {}
3434

35-
const chengduMetroOutsideFareGatesAttrsComponent = (props: AttrsProps<ChengduMetroOutsideFareGatesAttributes>) => {
36-
const { t } = useTranslation();
37-
38-
const fields: RmgFieldsField[] = [];
39-
40-
return <RmgFields fields={fields} />;
41-
};
35+
const chengduMetroOutsideFareGatesAttrsComponent = () => undefined;
4236

4337
const chengduMetroOutsideFareGates: LineStyle<ChengduMetroOutsideFareGatesAttributes> = {
4438
component: ChengduMetroOutsideFareGates,

src/components/svgs/nodes/chengdumetro-line-badge.tsx

+70-68
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import { MultilineText } from '../common/multiline-text';
1010
const ChengduMetroLineBadge = (props: NodeComponentProps<ChengduMetroLineBadgeAttributes>) => {
1111
const { id, x, y, attrs, handlePointerDown, handlePointerMove, handlePointerUp } = props;
1212
const {
13-
num = defaultChengduMetroLineBadgeAttributes.num,
13+
content = defaultChengduMetroLineBadgeAttributes.content,
1414
color = defaultChengduMetroLineBadgeAttributes.color,
15-
type = defaultChengduMetroLineBadgeAttributes.type,
15+
badgeType = defaultChengduMetroLineBadgeAttributes.badgeType,
1616
} = attrs ?? defaultChengduMetroLineBadgeAttributes;
1717

1818
const onPointerDown = React.useCallback(
@@ -34,63 +34,65 @@ const ChengduMetroLineBadge = (props: NodeComponentProps<ChengduMetroLineBadgeAt
3434
return (
3535
<g
3636
id={id}
37-
transform={`translate(${x - 12.5}, ${y - 12.5})`}
37+
transform={`translate(${x}, ${y})`}
3838
onPointerDown={onPointerDown}
3939
onPointerMove={onPointerMove}
4040
onPointerUp={onPointerUp}
4141
style={{ cursor: 'move' }}
4242
>
43-
{type == 'normal' ? (
44-
<>
45-
<rect fill={color[2]} x="0" width="25" height="25" rx="12.5" ry="12.5" />
46-
<text
47-
className="rmp-name__zh"
48-
textAnchor="middle"
49-
x="12.5"
50-
y="12.5"
51-
fill={fgColor}
52-
fontSize={fontSize}
53-
dominantBaseline="central"
54-
>
55-
{num}
56-
</text>
57-
</>
58-
) : type == 'suburban' ? (
59-
<>
60-
<rect fill={color[2]} x="0" y="0" width="20" height="25" rx="0" ry="0" />
61-
<rect fill={color[2]} x="19" y="0" width="6" height="5" rx="0" ry="0" />
62-
<rect fill={color[2]} x="19" y="10" width="6" height="5" rx="0" ry="0" />
63-
<rect fill={color[2]} x="19" y="20" width="6" height="5" rx="0" ry="0" />
64-
<text
65-
className="rmp-name__zh"
66-
textAnchor="left"
67-
x="0"
68-
y="12.5"
69-
fill={fgColor}
70-
fontSize={fontSize}
71-
dominantBaseline="central"
72-
style={{ fontFamily: '"Microsoft YaHei","Sogoe UI",Arial,sans-serif' }}
73-
>
74-
{num}
75-
</text>
76-
</>
77-
) : (
78-
<>
79-
<rect fill={color[2]} x="-1.25" y="0" width="27.5" height="7.5" rx="0" ry="0" />
80-
<rect fill={color[2]} x="7.5" y="0" width="10" height="25" rx="0" ry="0" />
81-
<MultilineText
82-
text={num.toString().split('')}
83-
lineHeight={10.5}
84-
x={12.5}
85-
y={6.5}
86-
fill="white"
87-
fontSize={10}
88-
textAnchor="middle"
89-
grow="down"
90-
dominantBaseline="middle"
91-
/>
92-
</>
93-
)}
43+
<g transform={`translate(${-12.5}, ${-12.5})`}>
44+
{badgeType == 'normal' ? (
45+
<>
46+
<rect fill={color[2]} x="0" width="25" height="25" rx="12.5" ry="12.5" />
47+
<text
48+
className="rmp-name__zh"
49+
textAnchor="middle"
50+
x="12.5"
51+
y="12.5"
52+
fill={fgColor}
53+
fontSize={fontSize}
54+
dominantBaseline="central"
55+
>
56+
{content}
57+
</text>
58+
</>
59+
) : badgeType == 'suburban' ? (
60+
<>
61+
<rect fill={color[2]} x="0" y="0" width="20" height="25" rx="0" ry="0" />
62+
<rect fill={color[2]} x="19" y="0" width="6" height="5" rx="0" ry="0" />
63+
<rect fill={color[2]} x="19" y="10" width="6" height="5" rx="0" ry="0" />
64+
<rect fill={color[2]} x="19" y="20" width="6" height="5" rx="0" ry="0" />
65+
<text
66+
className="rmp-name__zh"
67+
textAnchor="left"
68+
x="0"
69+
y="12.5"
70+
fill={fgColor}
71+
fontSize={fontSize}
72+
dominantBaseline="central"
73+
style={{ fontFamily: '"Microsoft YaHei","Sogoe UI",Arial,sans-serif' }}
74+
>
75+
{content}
76+
</text>
77+
</>
78+
) : (
79+
<>
80+
<rect fill={color[2]} x="-1.25" y="0" width="27.5" height="7.5" rx="0" ry="0" />
81+
<rect fill={color[2]} x="7.5" y="0" width="10" height="25" rx="0" ry="0" />
82+
<MultilineText
83+
text={content.toString().split('')}
84+
lineHeight={10.5}
85+
x={12.5}
86+
y={6.5}
87+
fill="white"
88+
fontSize={10}
89+
textAnchor="middle"
90+
grow="down"
91+
dominantBaseline="middle"
92+
/>
93+
</>
94+
)}
95+
</g>
9496
</g>
9597
);
9698
};
@@ -99,14 +101,14 @@ const ChengduMetroLineBadge = (props: NodeComponentProps<ChengduMetroLineBadgeAt
99101
* ChengduMetroLineBadge specific props.
100102
*/
101103
export interface ChengduMetroLineBadgeAttributes extends AttributesWithColor {
102-
num: number | string;
103-
type: 'normal' | 'suburban' | 'tram';
104+
content: number | string;
105+
badgeType: 'normal' | 'suburban' | 'tram';
104106
}
105107

106108
const defaultChengduMetroLineBadgeAttributes: ChengduMetroLineBadgeAttributes = {
107-
num: 1,
109+
content: 1,
108110
color: [CityCode.Chengdu, 'cd1', '#222a8c', MonoColour.white],
109-
type: 'normal',
111+
badgeType: 'normal',
110112
};
111113

112114
const ChengduMetroLineBadgeAttrsComponent = (props: AttrsProps<ChengduMetroLineBadgeAttributes>) => {
@@ -115,14 +117,14 @@ const ChengduMetroLineBadgeAttrsComponent = (props: AttrsProps<ChengduMetroLineB
115117
const fields: RmgFieldsField[] = [
116118
{
117119
type: 'input',
118-
label: t('panel.details.nodes.common.num'),
119-
value: (attrs ?? defaultChengduMetroLineBadgeAttributes).num as string,
120+
label: t('panel.details.nodes.text.content'),
121+
value: (attrs ?? defaultChengduMetroLineBadgeAttributes).content as string,
120122
validator: (val: string) => !Number.isNaN(val),
121123
onChange: (val: string | number) => {
122124
if (Number.isNaN(Number(val))) {
123-
attrs.num = val;
125+
attrs.content = val;
124126
} else {
125-
attrs.num = Number(val);
127+
attrs.content = Number(val);
126128
}
127129
handleAttrsUpdate(id, attrs);
128130
},
@@ -141,15 +143,15 @@ const ChengduMetroLineBadgeAttrsComponent = (props: AttrsProps<ChengduMetroLineB
141143
},
142144
{
143145
type: 'select',
144-
label: t('panel.details.nodes.chengduMetroLineBadge.type.displayName'),
145-
value: (attrs ?? defaultChengduMetroLineBadgeAttributes).type,
146+
label: t('panel.details.nodes.chengduMetroLineBadge.badgeType.displayName'),
147+
value: (attrs ?? defaultChengduMetroLineBadgeAttributes).badgeType,
146148
options: {
147-
normal: t('panel.details.nodes.chengduMetroLineBadge.type.normal'),
148-
suburban: t('panel.details.nodes.chengduMetroLineBadge.type.suburban'),
149-
tram: t('panel.details.nodes.chengduMetroLineBadge.type.tram'),
149+
normal: t('panel.details.nodes.chengduMetroLineBadge.badgeType.normal'),
150+
suburban: t('panel.details.nodes.chengduMetroLineBadge.badgeType.suburban'),
151+
tram: t('panel.details.nodes.chengduMetroLineBadge.badgeType.tram'),
150152
},
151153
onChange: val => {
152-
attrs.type = val as 'normal' | 'suburban' | 'tram';
154+
attrs.badgeType = val as 'normal' | 'suburban' | 'tram';
153155
handleAttrsUpdate(id, attrs);
154156
},
155157
minW: 'full',

src/components/svgs/nodes/misc-nodes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import jrEastLineBadge from './jr-east-line-badge';
1919
import qingdaoMetroNumLineBadge from './qingdao-metro-num-line-badge';
2020
import guangdongIntercityRailwayLineBadge from './guangdong-intercity-railway-line-badge';
2121
import londonArrow from './london-arrow';
22+
import chengduMetroLineBadge from './chengdumetro-line-badge';
2223
import facilities from './facilities';
2324
import text from './text';
2425
import i18nText from './i18n-text';
2526
import Master from './master';
26-
import chengduMetroLineBadge from './chengdumetro-line-badge';
2727

2828
const miscNodes = {
2929
[MiscNodeType.Virtual]: virtual,

src/components/svgs/stations/chengdumetro-basic.tsx

+32-35
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const ChengduMetroBasicStation = (props: StationComponentProps) => {
3232
nameOffsetY = defaultChengduMetroBasicStationAttributes.nameOffsetY,
3333
color = defaultChengduMetroBasicStationAttributes.color,
3434
direction = defaultChengduMetroBasicStationAttributes.direction,
35-
type = defaultChengduMetroBasicStationAttributes.type,
35+
stationType = defaultChengduMetroBasicStationAttributes.stationType,
3636
} = attrs[StationType.ChengduMetroBasic] ?? defaultChengduMetroBasicStationAttributes;
3737

3838
const onPointerDown = React.useCallback(
@@ -48,48 +48,53 @@ const ChengduMetroBasicStation = (props: StationComponentProps) => {
4848
[id, handlePointerUp]
4949
);
5050

51-
const getTextOffset = (oX: NameOffsetX, oY: NameOffsetY) => {
51+
const getTextOffset = () => {
52+
const [oX, oY] = [nameOffsetX, nameOffsetY];
5253
if (direction === 'horizontal') {
5354
if (oX === 'left' && oY === 'top') {
5455
return [
55-
-5 - (type == 'tram' ? 4 : type == 'joint' ? 2 : 0),
56+
-5 - (stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0),
5657
-names[1].split('\n').length * LINE_HEIGHT[oY] - 3,
5758
];
5859
} else if (oX === 'middle' && oY === 'top') {
5960
return [
6061
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),
6265
];
6366
} else if (oX === 'right' && oY === 'top') {
6467
return [
65-
5 + (type == 'tram' ? 4 : type == 'joint' ? 2 : 0),
68+
5 + (stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0),
6669
-names[1].split('\n').length * LINE_HEIGHT[oY] - 3,
6770
];
6871
} else if (oX === 'left' && oY === 'bottom') {
6972
return [
70-
-5 - (type == 'tram' ? 4 : type == 'joint' ? 2 : 0),
73+
-5 - (stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0),
7174
names[0].split('\n').length * LINE_HEIGHT[oY] + 3,
7275
];
7376
} else if (oX === 'middle' && oY === 'bottom') {
7477
return [
7578
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),
7782
];
7883
} else if (oX === 'right' && oY === 'bottom') {
7984
return [
80-
5 + (type == 'tram' ? 4 : type == 'joint' ? 2 : 0),
85+
5 + (stationType == 'tram' ? 4 : stationType == 'joint' ? 2 : 0),
8186
names[0].split('\n').length * LINE_HEIGHT[oY] + 3,
8287
];
8388
} 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];
8590
} 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];
8792
} else return [0, 0];
8893
} else {
8994
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)];
9196
} 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)];
9398
} else return [0, 0];
9499
}
95100
};
@@ -114,7 +119,7 @@ const ChengduMetroBasicStation = (props: StationComponentProps) => {
114119
} else return [0, 0, 0, 0];
115120
};
116121

117-
const [textX, textY] = getTextOffset(nameOffsetX, nameOffsetY);
122+
const [textX, textY] = getTextOffset();
118123
const [tramX1, tramX2, tramY1, tramY2] = getTramPos(nameOffsetX, nameOffsetY);
119124
const textAnchor =
120125
direction == 'vertical'
@@ -131,19 +136,19 @@ const ChengduMetroBasicStation = (props: StationComponentProps) => {
131136

132137
return (
133138
<g id={id} transform={`translate(${x}, ${y})`}>
134-
{type == 'normal' || type == 'branchTerminal' ? (
139+
{stationType == 'normal' || stationType == 'branchTerminal' ? (
135140
<circle
136141
id={`stn_core_${id}`}
137-
r={type == 'normal' ? 1.75 : 5}
142+
r={stationType == 'normal' ? 1.75 : 5}
138143
stroke={color[2]}
139-
strokeWidth={type == 'normal' ? 1 : 0.5}
144+
strokeWidth={stationType == 'normal' ? 1 : 0.5}
140145
fill="white"
141146
onPointerDown={onPointerDown}
142147
onPointerMove={onPointerMove}
143148
onPointerUp={onPointerUp}
144149
style={{ cursor: 'move' }}
145150
/>
146-
) : type == 'joint' ? (
151+
) : stationType == 'joint' ? (
147152
<g
148153
transform={direction == 'vertical' ? 'rotate(90)' : ''}
149154
id={`stn_core_${id}`}
@@ -223,14 +228,6 @@ const ChengduMetroBasicStation = (props: StationComponentProps) => {
223228
className="rmp-name__en"
224229
dominantBaseline="central"
225230
/>
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-
/>
234231
</g>
235232
</>
236233
)}
@@ -245,7 +242,7 @@ export interface ChengduMetroBasicStationAttributes extends StationAttributes, A
245242
nameOffsetX: NameOffsetX;
246243
nameOffsetY: NameOffsetY;
247244
direction: 'vertical' | 'horizontal';
248-
type: 'normal' | 'joint' | 'branchTerminal' | 'tram';
245+
stationType: 'normal' | 'joint' | 'branchTerminal' | 'tram';
249246
}
250247

251248
const defaultChengduMetroBasicStationAttributes: ChengduMetroBasicStationAttributes = {
@@ -254,7 +251,7 @@ const defaultChengduMetroBasicStationAttributes: ChengduMetroBasicStationAttribu
254251
nameOffsetX: 'right',
255252
nameOffsetY: 'top',
256253
direction: 'horizontal',
257-
type: 'normal',
254+
stationType: 'normal',
258255
};
259256

260257
const ChengduMetroBasicAttrsComponent = (props: AttrsProps<ChengduMetroBasicStationAttributes>) => {
@@ -264,7 +261,7 @@ const ChengduMetroBasicAttrsComponent = (props: AttrsProps<ChengduMetroBasicStat
264261
{
265262
type: 'textarea',
266263
label: t('panel.details.stations.common.nameZh'),
267-
value: (attrs ?? defaultChengduMetroBasicStationAttributes).names[0],
264+
value: (attrs.names ?? defaultChengduMetroBasicStationAttributes.names)[0],
268265
onChange: val => {
269266
attrs.names[0] = val.toString();
270267
handleAttrsUpdate(id, attrs);
@@ -336,16 +333,16 @@ const ChengduMetroBasicAttrsComponent = (props: AttrsProps<ChengduMetroBasicStat
336333
},
337334
{
338335
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,
341338
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'),
346343
},
347344
onChange: val => {
348-
attrs.type = val as 'normal' | 'joint' | 'branchTerminal';
345+
attrs.stationType = val as 'normal' | 'joint' | 'branchTerminal';
349346
handleAttrsUpdate(id, attrs);
350347
},
351348
minW: 'full',

0 commit comments

Comments
 (0)