Skip to content

Instantly share code, notes, and snippets.

@kenmori
Created July 2, 2019 05:27
Show Gist options
  • Save kenmori/b79fba9a9b002fc858c8d337b0b50650 to your computer and use it in GitHub Desktop.
Save kenmori/b79fba9a9b002fc858c8d337b0b50650 to your computer and use it in GitHub Desktop.
React and
```js
import * as React from "react";
import {
ExpansionPanel,
ExpansionPanelSummary,
ExpansionPanelDetails,
Typography,
} from "@material-ui/core";
import { ExpandMore as ExpandMoreIcon } from "@material-ui/icons";
import classes from "./classes.css";
export interface StateProps {
description: string;
}
interface LocalState {
expanded: boolean;
}
type Props = StateProps;
const OwnAppDescriptionViewer:React.FC<Props> = ({description}) => {
const [state, setExpands] = React.useState<LocalState>({expanded: false});
const handleChange = React.useCallback(() => {
setExpands((prevState) => ({ expanded: !prevState.expanded }));
},[setExpands]);
return (
<>
<ExpansionPanel
expanded={state.expanded}
onChange={handleChange}
classes={{
root: classes.ExpansionPanel,
expanded: classes.DescriptionBarExpanded,
}}
elevation={0}
square={true}
>
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />} />
<ExpansionPanelDetails>
<Typography>{description}</Typography>
</ExpansionPanelDetails>
</ExpansionPanel>
</>
);
};
export default OwnAppDescriptionViewer;
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment