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';
|
2024-02-24 19:59:26 +01:00
|
|
|
import {Composable} from "./IComposable"
|
2024-02-21 17:19:29 +01:00
|
|
|
|
|
|
|
import "./Nugget.css";
|
2024-02-26 17:56:46 +01:00
|
|
|
import { Nugget as NuggetType, decreaseNuggetScore, increaseNuggetScore } from '../lib/prompt';
|
2024-02-21 17:19:29 +01:00
|
|
|
|
2024-02-26 17:56:46 +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'>
|
2024-02-26 17:56:46 +01:00
|
|
|
<span className='text'>{nugget.item.name || nugget.item.prompt}</span>
|
2024-02-21 17:19:29 +01:00
|
|
|
<Divider orientation="vertical" variant="middle" flexItem />
|
2024-02-26 17:56:46 +01:00
|
|
|
<span className='score'>{scoreDisp}</span>
|
2024-02-21 17:19:29 +01:00
|
|
|
<span className='buttons'>
|
|
|
|
<ButtonGroup size="small" orientation='vertical'>
|
2024-02-26 17:56:46 +01:00
|
|
|
<Button onClick={() => increaseNuggetScore(nugget.id)} className='incScore'>
|
2024-02-21 17:19:29 +01:00
|
|
|
<KeyboardArrowUpIcon />
|
|
|
|
</Button>
|
2024-02-26 17:56:46 +01:00
|
|
|
<Button onClick={() => decreaseNuggetScore(nugget.id)} className='decScore'>
|
2024-02-21 17:19:29 +01:00
|
|
|
<KeyboardArrowDownIcon />
|
|
|
|
</Button>
|
|
|
|
</ButtonGroup>
|
|
|
|
</span>
|
|
|
|
</div>
|
2024-02-24 19:59:26 +01:00
|
|
|
) as Composable;
|
2024-02-21 17:19:29 +01:00
|
|
|
}
|