Spaces:
Runtime error
Runtime error
File size: 924 Bytes
6c2bcb4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import { Button, Typography } from "@mui/material";
import { MouseEventHandler } from "react";
interface ExampleButtonProps {
text: string;
title?: string;
displayLength?: number;
onClick?: (text: string) => void;
}
/**
*
* A button that hosts an example "text" that can be used as the input
* to anything to get an inspiration on how to get started.
*
* @param props ExampleButtonProps
* @returns
*/
export default function ExampleButton(props: ExampleButtonProps) {
const { title, text, displayLength = 50, onClick } = props;
const displayText = text.slice(0, displayLength) + (text.length > displayLength ? "..." : "");
const handleClick: MouseEventHandler = event => {
event.preventDefault();
if (onClick) {
onClick(text);
}
};
return (
<Button onClick={handleClick} sx={{ textTransform: "none" }} variant="outlined">
<Typography>{title ?? displayText}</Typography>
</Button>
);
}
|