forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTitleButton.tsx
More file actions
61 lines (57 loc) · 1.36 KB
/
TitleButton.tsx
File metadata and controls
61 lines (57 loc) · 1.36 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
56
57
58
59
60
61
import { useIntl } from '@edx/frontend-platform/i18n';
import {
Button,
OverlayTrigger,
Tooltip,
} from '@openedx/paragon';
import {
ArrowDropDown as ArrowDownIcon,
ArrowRight as ArrowRightIcon,
} from '@openedx/paragon/icons';
import messages from './messages';
interface TitleButtonProps {
title: string;
prefixIcon?: React.ReactNode;
isExpanded: boolean;
onTitleClick: () => void;
namePrefix: string;
}
const TitleButton = ({
title,
prefixIcon,
isExpanded,
onTitleClick,
namePrefix,
}: TitleButtonProps) => {
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}
title={title}
>
<div className="mr-2">
{prefixIcon}
</div>
<span className={`${namePrefix}-card-title mb-0 truncate-1-line`}>
{title}
</span>
</Button>
</OverlayTrigger>
);
};
export default TitleButton;