Skip to content

Commit 2c7335b

Browse files
authored
Merge pull request #126 from Lemoncode/feature/#125-to-do-collapse-items
added collapse items
2 parents fbd84b1 + 32f354b commit 2c7335b

2 files changed

Lines changed: 62 additions & 18 deletions

File tree

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

Lines changed: 40 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,47 @@ 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}>
45-
{labelName}
46-
</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)}
53+
<div className={innerClasses.labelContainer}>
54+
<label
55+
className={innerClasses.label}
56+
htmlFor={inputId}
57+
onClick={handleClick}
6058
>
61-
<FileCopyOutlinedIcon className={innerClasses.icon} />
62-
</button>
59+
{labelName}
60+
{open ? (
61+
<ExpandLessIcon className={innerClasses.collapseIcon} />
62+
) : (
63+
<ExpandMoreIcon className={innerClasses.collapseIcon} />
64+
)}
65+
</label>
6366
</div>
67+
<Collapse in={open} timeout="auto" unmountOnExit>
68+
<div className={innerClasses.inputContainer}>
69+
<input
70+
id={inputId}
71+
type="text"
72+
className={innerClasses.input}
73+
value={urlLink}
74+
readOnly
75+
aria-readonly
76+
/>
77+
<button
78+
aria-label={`copy ${labelName}`}
79+
className={innerClasses.button}
80+
onClick={() => navigator.clipboard.writeText(urlLink)}
81+
>
82+
<FileCopyOutlinedIcon className={innerClasses.icon} />
83+
</button>
84+
</div>
85+
</Collapse>
6486
</>
6587
);
6688
};

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,33 @@ export const root = css`
99
grid-row-gap: 1rem;
1010
grid-column-gap: 1rem;
1111
`;
12+
export const labelContainer = css`
13+
border-bottom: 1px solid rgba(0, 0, 0, 0.12);
14+
`;
1215

1316
export const label = css`
1417
font-family: ${typography.fontFamily};
1518
font-size: 1.125rem;
1619
color: ${palette.text.primary};
20+
display: flex;
21+
justify-content: space-between;
22+
width: 50%;
23+
cursor: pointer;
24+
& :hover {
25+
background-color: rgba(0, 0, 0, 0.12);
26+
}
27+
28+
@media (min-width: ${theme.breakpoints.values.sm}px) {
29+
width: 30%;
30+
}
31+
@media (min-width: ${theme.breakpoints.values.lg}px) {
32+
width: 25%;
33+
}
34+
`;
35+
36+
export const collapseIcon = css`
37+
font-size: 1.7rem;
38+
margin: 0 1%;
1739
`;
1840

1941
export const inputContainer = css`

0 commit comments

Comments
 (0)