web: Added clickAction property to GroupButton component
This commit is contained in:
parent
369825607e
commit
f05abd2d84
@ -27,3 +27,4 @@ Base Button is used for a group action on a page.
|
||||
| `isDropdown` | `bool` | - | - | `false` | Tells when the button should present a dropdown state |
|
||||
| `splitted` | `bool` | - | - | `false` | Tells when the button should present a dropdown state with button |
|
||||
| `opened` | `bool` | - | - | `false` | Tells when the button should be opened by default |
|
||||
| `clickAction` | `func` | - | - | - | What the button will trigger when clicked |
|
@ -174,10 +174,6 @@ const Caret = styled(Icons.ExpanderDownIcon)`
|
||||
}
|
||||
`;
|
||||
|
||||
const clickAction = (e) => {
|
||||
console.log('Button "' + e.target.innerText + '" clicked!');
|
||||
}
|
||||
|
||||
const useOuterClickNotifier = (onOuterClick, ref) => {
|
||||
useEffect(() => {
|
||||
const handleClick = (e) => !ref.current.contains(e.target) && onOuterClick(e);
|
||||
@ -193,7 +189,7 @@ const useOuterClickNotifier = (onOuterClick, ref) => {
|
||||
}
|
||||
|
||||
const GroupButton = (props) => {
|
||||
const { text, children, splitted, isDropdown, isCheckbox, opened, disabled, primary } = props;
|
||||
const { text, children, splitted, isDropdown, isCheckbox, opened, disabled, primary, clickAction } = props;
|
||||
const [isOpen, toggle] = useState(opened);
|
||||
const ref = useRef(null);
|
||||
|
||||
@ -261,7 +257,8 @@ GroupButton.propTypes = {
|
||||
splitted: PropTypes.bool,
|
||||
isCheckbox: PropTypes.bool,
|
||||
isDropdown: PropTypes.bool,
|
||||
tabIndex: PropTypes.number
|
||||
tabIndex: PropTypes.number,
|
||||
clickAction: PropTypes.func
|
||||
};
|
||||
|
||||
GroupButton.defaultProps = {
|
||||
@ -274,7 +271,8 @@ GroupButton.defaultProps = {
|
||||
splitted: false,
|
||||
isCheckbox: false,
|
||||
isDropdown: false,
|
||||
tabIndex: -1
|
||||
tabIndex: -1,
|
||||
clickAction: (e) => console.log('Button "' + e.target.innerText + '" clicked!')
|
||||
};
|
||||
|
||||
export default GroupButton
|
Loading…
Reference in New Issue
Block a user