forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTitleButton.jsx
More file actions
55 lines (51 loc) · 1.33 KB
/
TitleButton.jsx
File metadata and controls
55 lines (51 loc) · 1.33 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import PropTypes from 'prop-types';
import { useIntl } from '@edx/frontend-platform/i18n';
import {
Button,
OverlayTrigger,
Tooltip,
Truncate,
} from '@openedx/paragon';
import {
ArrowDropDown as ArrowDownIcon,
ArrowRight as ArrowRightIcon,
} from '@openedx/paragon/icons';
import messages from './messages';
const TitleButton = ({
title,
isExpanded,
onTitleClick,
namePrefix,
}) => {
const intl = useIntl();
const titleTooltipMessage = intl.formatMessage(messages.expandTooltip);
return (
<OverlayTrigger
placement="bottom"
overlay={(
<Tooltip
id={`${title}-${titleTooltipMessage}`}
>
{titleTooltipMessage}
</Tooltip>
)}
>
<Button
iconBefore={isExpanded ? ArrowDownIcon : ArrowRightIcon}
variant="tertiary"
data-testid={`${namePrefix}-card-header__expanded-btn`}
className="item-card-header__title-btn"
onClick={onTitleClick}
>
<Truncate.Deprecated lines={1} className={`${namePrefix}-card-title mb-0`}>{title}</Truncate.Deprecated>
</Button>
</OverlayTrigger>
);
};
TitleButton.propTypes = {
title: PropTypes.string.isRequired,
isExpanded: PropTypes.bool.isRequired,
onTitleClick: PropTypes.func.isRequired,
namePrefix: PropTypes.string.isRequired,
};
export default TitleButton;