Skip to content

Commit a8734f6

Browse files
authored
Activable chip (#739)
Signed-off-by: LE SAULNIER Kevin <[email protected]>
1 parent 4f317c0 commit a8734f6

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
import { Chip, Tooltip } from '@mui/material';
9+
import { CheckCircleOutline, Cancel } from '@mui/icons-material';
10+
11+
export interface ActivableChipProps {
12+
isActivated: boolean;
13+
label: string;
14+
tooltipMessage: string;
15+
onClick: () => void;
16+
isDisabled?: boolean;
17+
}
18+
19+
export function ActivableChip(props: Readonly<ActivableChipProps>) {
20+
const { isActivated, label, tooltipMessage, onClick, isDisabled } = props;
21+
22+
return (
23+
<Tooltip title={tooltipMessage} arrow>
24+
<Chip
25+
label={label}
26+
deleteIcon={isActivated ? <CheckCircleOutline /> : <Cancel />}
27+
color="primary"
28+
size="small"
29+
variant={isActivated ? 'filled' : 'outlined'}
30+
onDelete={onClick}
31+
onClick={onClick}
32+
disabled={isDisabled}
33+
/>
34+
</Tooltip>
35+
);
36+
}

src/components/inputs/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
export * from './SelectClearable';
88
export * from './reactHookForm';
99
export * from './reactQueryBuilder';
10+
export * from './ActivableChip';

0 commit comments

Comments
 (0)