1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-17 06:27:28 +00:00
seahub/frontend/src/components/common/group-select/option.js
Michael An fc139a83fd
Change select group UI (#7201)
* 01 share repo to group UI

* 02 ADD_SHARED_REPO_INTO_GROUP

* 03 share folder to groups

* 04 system admin share repo to group

* 05 remove old NoGroupMessage

* 06 change API

* change API

* change select icons indents
2024-12-19 09:53:32 +08:00

47 lines
1.0 KiB
JavaScript

import React, { Component } from 'react';
import PropTypes from 'prop-types';
class Option extends Component {
onSelectOption = (e) => {
e.stopPropagation();
this.props.onSelectOption(this.props.option);
};
onMouseEnter = () => {
if (!this.props.disableHover) {
this.props.changeIndex(this.props.index);
}
};
onMouseLeave = () => {
if (!this.props.disableHover) {
this.props.changeIndex(-1);
}
};
render() {
return (
<div
className={this.props.isActive ? 'option option-active' : 'option'}
onClick={this.onSelectOption}
onMouseEnter={this.onMouseEnter}
onMouseLeave={this.onMouseLeave}
>{this.props.children}
</div>
);
}
}
Option.propTypes = {
index: PropTypes.number,
isActive: PropTypes.bool,
changeIndex: PropTypes.func,
option: PropTypes.object,
children: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
onSelectOption: PropTypes.func,
disableHover: PropTypes.bool,
};
export default Option;