Skip to content

Commit a335e67

Browse files
authored
Merge pull request #6 from lopentu/feature/adjust-frontend-display
feat:手勢細節加 subheader 分組, Chip 點擊移除
2 parents 0bcabed + c58c830 commit a335e67

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

components/corpus-table.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,13 @@ export default function CorpusTable({ annotationSpans, searchType, onSelectedSpa
220220
variant={cosp.includes(g.replace(/^SP[12]_/, '')) ? 'filled' : 'outlined'}
221221
color={g.startsWith('SP1') ? 'primary' : 'secondary'}
222222
onClick={() => {
223-
const label = g.replace(/^SP[12]_/, '');
224-
if (!cosp.includes(label)) {
225-
setCosp([...cosp, label]);
226-
}
227-
}}
223+
const label = g.replace(/^SP[12]_/, '');
224+
if (cosp.includes(label)) {
225+
setCosp(cosp.filter(c => c !== label));
226+
} else {
227+
setCosp([...cosp, label]);
228+
}
229+
}}
228230
sx={{ cursor: 'pointer' }}
229231
/>
230232
))}

components/cospeech-select.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Checkbox from '@mui/material/Checkbox';
99
import { CospeechGesture } from '../types/corpus';
1010
import Grid2 from '@mui/material/Unstable_Grid2/Grid2';
1111
import { Stack } from '@mui/material';
12+
import ListSubheader from '@mui/material/ListSubheader';
1213

1314
const ITEM_HEIGHT = 200;
1415
const ITEM_PADDING_TOP = 100;
@@ -62,12 +63,21 @@ export default function CospGestureMultipleSelectCheckmarks(props) {
6263
name="gestureSelect"
6364
autoWidth
6465
>
65-
{(Object.keys(CospeechGesture).filter(key => isNaN(Number(key)))).map((ges) => (
66-
<MenuItem key={ges} value={ges}>
67-
<Checkbox checked={props.cosp.indexOf(ges) > -1} />
68-
<ListItemText primary={ges} />
69-
</MenuItem>
70-
))}
66+
{[
67+
{ header: 'Line of Sight', keys: ['LOS_DOWN','LOS_LEFT','LOS_RIGHT'] },
68+
{ header: 'Gaze', keys: ['GAZE_FORWARD','GAZE_LEFT','GAZE_RIGHT','GAZE_UP','GAZE_DOWN'] },
69+
{ header: 'Hands', keys: ['HANDS_NONE','HAND_LEFT','HAND_RIGHT','HANDS_BOTH'] },
70+
{ header: 'Left Hand', keys: ['HAND_L_OPEN','HAND_L_CLOSED','HAND_L_POINTING','LEFT_PALM_IN','LEFT_PALM_OUT','LEFT_PALM_UP','LEFT_PALM_DOWN','LEFT_PALM_MEDIAL','LEFT_THUMB_UP','LEFT_INDEX_UP'] },
71+
{ header: 'Right Hand', keys: ['HAND_R_OPEN','HAND_R_CLOSED','HAND_R_POINTING','RIGHT_PALM_IN','RIGHT_PALM_OUT','RIGHT_PALM_UP','RIGHT_PALM_DOWN','RIGHT_PALM_MEDIAL','RIGHT_THUMB_UP','RIGHT_INDEX_UP'] },
72+
].map(({ header, keys }) => [
73+
<ListSubheader key={header}>{header}</ListSubheader>,
74+
...keys.map((ges) => (
75+
<MenuItem key={ges} value={ges}>
76+
<Checkbox checked={props.cosp.indexOf(ges) > -1} />
77+
<ListItemText primary={ges} />
78+
</MenuItem>
79+
))
80+
])}
7181
</Select>
7282
</FormControl>
7383
{/* </Grid2> */}

0 commit comments

Comments
 (0)