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
51 lines (47 loc) · 1.21 KB
/
TitleButton.tsx
File metadata and controls
51 lines (47 loc) · 1.21 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
import { useIntl } from '@edx/frontend-platform/i18n';
import {
IconButtonWithTooltip,
Stack,
} 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 (
<Stack direction="horizontal">
<IconButtonWithTooltip
src={isExpanded ? ArrowDownIcon : ArrowRightIcon}
data-testid={`${namePrefix}-card-header__expanded-btn`}
alt={title}
tooltipContent={<div>{titleTooltipMessage}</div>}
className="item-card-header__title-btn"
onClick={onTitleClick}
size="inline"
/>
<div className="mr-2">
{prefixIcon}
</div>
<span className={`${namePrefix}-card-title mb-0 truncate-1-line`}>
{title}
</span>
</Stack>
);
};
export default TitleButton;