1
1
import { IconButton } from '@chakra-ui/react' ;
2
+ import { RmgFields , RmgFieldsField } from '@railmapgen/rmg-components' ;
2
3
import { MonoColour } from '@railmapgen/rmg-palette-resources' ;
3
4
import React from 'react' ;
4
5
import { useTranslation } from 'react-i18next' ;
5
6
import { MdOutlineSwapVert } from 'react-icons/md' ;
6
- import { CityCode , Theme } from '../../../../constants/constants' ;
7
+ import { AttrsProps , CityCode , Theme } from '../../../../constants/constants' ;
7
8
import {
8
9
LinePathAttributes ,
9
10
LinePathType ,
@@ -15,10 +16,6 @@ import { useRootDispatch, useRootSelector } from '../../../../redux';
15
16
import { saveGraph } from '../../../../redux/param/param-slice' ;
16
17
import { refreshEdgesThunk } from '../../../../redux/runtime/runtime-slice' ;
17
18
import { makeShortPathParallel } from '../../../../util/bezier-parallel' ;
18
- import {
19
- RmgFieldsFieldDetail ,
20
- RmgFieldsFieldSpecificAttributes ,
21
- } from '../../../panels/details/rmg-field-specific-attrs' ;
22
19
import { ColorField } from '../../../panels/details/color-field' ;
23
20
24
21
const DualColor = ( props : LineStyleComponentProps < DualColorAttributes > ) => {
@@ -90,47 +87,44 @@ const DualColorSwitch = () => {
90
87
) ;
91
88
} ;
92
89
93
- const dualColorFields = [
94
- {
95
- type : 'custom' ,
96
- label : 'panel.details.lines.dualColor.swap' ,
97
- component : < DualColorSwitch /> ,
98
- } ,
99
- {
100
- type : 'custom' ,
101
- label : 'panel.details.lines.dualColor.colorA' ,
102
- component : (
103
- < ColorField
104
- type = { LineStyleType . DualColor }
105
- colorKey = "colorA"
106
- defaultTheme = { defaultDualColorAttributes . colorA }
107
- />
108
- ) ,
109
- } ,
110
- {
111
- type : 'custom' ,
112
- label : 'panel.details.lines.dualColor.colorB' ,
113
- component : (
114
- < ColorField
115
- type = { LineStyleType . DualColor }
116
- colorKey = "colorB"
117
- defaultTheme = { defaultDualColorAttributes . colorB }
118
- />
119
- ) ,
120
- } ,
121
- ] ;
90
+ const dualColorAttrsComponent = ( props : AttrsProps < DualColorAttributes > ) => {
91
+ const fields : RmgFieldsField [ ] = [
92
+ {
93
+ type : 'custom' ,
94
+ label : 'panel.details.lines.dualColor.swap' ,
95
+ component : < DualColorSwitch /> ,
96
+ } ,
97
+ {
98
+ type : 'custom' ,
99
+ label : 'panel.details.lines.dualColor.colorA' ,
100
+ component : (
101
+ < ColorField
102
+ type = { LineStyleType . DualColor }
103
+ colorKey = "colorA"
104
+ defaultTheme = { defaultDualColorAttributes . colorA }
105
+ />
106
+ ) ,
107
+ } ,
108
+ {
109
+ type : 'custom' ,
110
+ label : 'panel.details.lines.dualColor.colorB' ,
111
+ component : (
112
+ < ColorField
113
+ type = { LineStyleType . DualColor }
114
+ colorKey = "colorB"
115
+ defaultTheme = { defaultDualColorAttributes . colorB }
116
+ />
117
+ ) ,
118
+ } ,
119
+ ] ;
122
120
123
- const attrsComponent = ( ) => (
124
- < RmgFieldsFieldSpecificAttributes
125
- fields = { dualColorFields as RmgFieldsFieldDetail < DualColorAttributes > }
126
- type = "style"
127
- />
128
- ) ;
121
+ return < RmgFields fields = { fields } /> ;
122
+ } ;
129
123
130
124
const dualColor : LineStyle < DualColorAttributes > = {
131
125
component : DualColor ,
132
126
defaultAttrs : defaultDualColorAttributes ,
133
- attrsComponent,
127
+ attrsComponent : dualColorAttrsComponent ,
134
128
metadata : {
135
129
displayName : 'panel.details.lines.dualColor.displayName' ,
136
130
supportLinePathType : [ LinePathType . Diagonal , LinePathType . Perpendicular , LinePathType . RotatePerpendicular ] ,
0 commit comments