invoke-prompt-editor-demo/src/components/Nugget.tsx

35 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-02-21 17:19:29 +01:00
import { Button, ButtonGroup, Chip, Divider } from '@material-ui/core';
import React, { Component, useState } from 'react';
import KeyboardArrowUpIcon from '@mui/icons-material/KeyboardArrowUp';
import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowUp';
import "./Nugget.css";
import { Nugget as NuggetType, decreaseNuggetScore, increaseNuggetScore } from '../lib/prompt';
2024-02-21 17:19:29 +01:00
export interface NuggetProps {
nugget : NuggetType,
}
export default function Nugget(props : NuggetProps) {
const {nugget} = props;
const scoreDisp = nugget.score > 0 ? "+" + nugget.score : nugget.score;
2024-02-21 17:19:29 +01:00
return (
<div className='nugget'>
<span className='text'>{nugget.item.name || nugget.item.prompt}</span>
2024-02-21 17:19:29 +01:00
<Divider orientation="vertical" variant="middle" flexItem />
<span className='score'>{scoreDisp}</span>
2024-02-21 17:19:29 +01:00
<span className='buttons'>
<ButtonGroup size="small" orientation='vertical'>
<Button onClick={() => increaseNuggetScore(nugget.id)} className='incScore' aria-label="incScore">
2024-02-21 17:19:29 +01:00
<KeyboardArrowUpIcon />
</Button>
<Button onClick={() => decreaseNuggetScore(nugget.id)} className='decScore' aria-label='decScore'>
2024-02-21 17:19:29 +01:00
<KeyboardArrowDownIcon />
</Button>
</ButtonGroup>
</span>
</div>
);
2024-02-21 17:19:29 +01:00
}