Skip to content

Commit 460c009

Browse files
committed
added collapse items
1 parent 823f2d5 commit 460c009

2 files changed

Lines changed: 49 additions & 18 deletions

File tree

‎front/src/pods/trainer/components/header.component.tsx‎

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import React from 'react';
22
import { cx } from 'emotion';
3+
import Collapse from '@material-ui/core/Collapse';
34
import FileCopyOutlinedIcon from '@material-ui/icons/FileCopyOutlined';
5+
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
6+
import ExpandLessIcon from '@material-ui/icons/ExpandLess';
47
import * as innerClasses from './header.styles';
58

69
interface Props {
@@ -39,28 +42,45 @@ interface CopyFieldProps {
3942
export const CopyFieldComponent: React.FC<CopyFieldProps> = props => {
4043
const { labelName, inputId, urlLink } = props;
4144

45+
const [open, setOpen] = React.useState(true);
46+
47+
const handleClick = () => {
48+
setOpen(!open);
49+
};
50+
4251
return (
4352
<>
44-
<label className={innerClasses.label} htmlFor={inputId}>
53+
<label
54+
className={innerClasses.label}
55+
htmlFor={inputId}
56+
onClick={handleClick}
57+
>
4558
{labelName}
59+
{open ? (
60+
<ExpandLessIcon className={innerClasses.collapseIcon} />
61+
) : (
62+
<ExpandMoreIcon className={innerClasses.collapseIcon} />
63+
)}
4664
</label>
47-
<div className={innerClasses.inputContainer}>
48-
<input
49-
id={inputId}
50-
type="text"
51-
className={innerClasses.input}
52-
value={urlLink}
53-
readOnly
54-
aria-readonly
55-
/>
56-
<button
57-
aria-label={`copy ${labelName}`}
58-
className={innerClasses.button}
59-
onClick={() => navigator.clipboard.writeText(urlLink)}
60-
>
61-
<FileCopyOutlinedIcon className={innerClasses.icon} />
62-
</button>
63-
</div>
65+
<Collapse in={open} timeout="auto" unmountOnExit>
66+
<div className={innerClasses.inputContainer}>
67+
<input
68+
id={inputId}
69+
type="text"
70+
className={innerClasses.input}
71+
value={urlLink}
72+
readOnly
73+
aria-readonly
74+
/>
75+
<button
76+
aria-label={`copy ${labelName}`}
77+
className={innerClasses.button}
78+
onClick={() => navigator.clipboard.writeText(urlLink)}
79+
>
80+
<FileCopyOutlinedIcon className={innerClasses.icon} />
81+
</button>
82+
</div>
83+
</Collapse>
6484
</>
6585
);
6686
};

‎front/src/pods/trainer/components/header.styles.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ export const label = css`
1414
font-family: ${typography.fontFamily};
1515
font-size: 1.125rem;
1616
color: ${palette.text.primary};
17+
display: flex;
18+
cursor: pointer;
19+
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
20+
& :hover {
21+
background-color: rgba(0, 0, 0, 0.12);
22+
}
23+
`;
24+
25+
export const collapseIcon = css`
26+
font-size: 1.7rem;
27+
margin: 0 1%;
1728
`;
1829

1930
export const inputContainer = css`

0 commit comments

Comments
 (0)