import { makeStyles } from '@mui/styles'; import classNames from 'classnames'; import React from 'react'; import { Link } from 'react-router'; import type { InterfaceReferenceNode } from '../reference/index.js'; import { defaultNodeSort } from '../tools/NodeTools.js'; import { getChildren } from '../tools/ReferenceTools.js'; import Type from './codeBuilders/Type.js'; interface InterfaceRepresentationProps { symbol: InterfaceReferenceNode; className?: string; } const useStyles = makeStyles( theme => ({ root: { fontFamily: theme.fonts.code }, prop: { display: 'block', marginLeft: '2em', '& + $prop': { marginTop: '.5em' } }, comment: { color: '#808080', fontSize: '.8em', '&:before': { content: '"// "', display: 'inline' } }, name: { color: '#9876AA', textDecoration: 'none' } }), { name: 'InterfaceRepresentation' } ); const InterfaceRepresentation: React.FC = ({ symbol, className }) => { const classes = useStyles(); return (
{'{'} {getChildren(symbol) .sort(defaultNodeSort) .map(member => { if (member.kind === 'property') { return (
{member.comment?.shortText ? (
{member.comment.shortText}
) : null}
{member.name} {member.flags?.isOptional ? '?' : ''} :
); } if (member.kind === 'method') { const sig = member.signatures![0]; return (
{sig.comment?.shortText ? (
{sig.comment.shortText}
) : null}
{member.name} {member.flags?.isOptional ? '?' : ''} ():
); } return null; })} {'}'}
); }; export default InterfaceRepresentation;