Add behavior picker component

This commit is contained in:
2022-04-01 17:28:36 +08:00
parent f020e44f47
commit 5176a1f672
5 changed files with 84 additions and 0 deletions
@@ -0,0 +1,26 @@
div.behavior-picker-list {
width: 100%;
max-width: 400px;
div.behavior-picker-line {
width: 100%;
padding: 0 !important;
display: flex !important;
justify-content: flex-start !important;
div.behavior-picker-line-color-view {
width: 0;
max-width: 0;
height: 100%;
div {
width: 0;
height: 0;
border-bottom: 10px solid transparent;
position: relative;
z-index: 2;
}
}
}
}
@@ -0,0 +1,49 @@
import { DetailsList } from "@Component/DetailsList/DetailsList";
import { Component, ReactNode } from "react";
import { Behavior } from "@Model/Behavior";
import "./BehaviorPicker.scss";
interface IBehaviorPickerProps {
behavior: Behavior[]
}
class BehaviorPicker extends Component<IBehaviorPickerProps> {
private getData() {
let data: Array<{key: string, behavior: Behavior}> = [];
for (let i = 0; i < this.props.behavior.length; i++) {
data.push({
key: this.props.behavior[i].id,
behavior: this.props.behavior[i]
})
}
return data;
}
private renderColor(color: string): ReactNode {
return <div className="behavior-picker-line-color-view">
<div style={{ borderLeft: `10px solid ${color}` }}/>
</div>
}
private renderLine = (behavior: Behavior): ReactNode => {
return <>
{this.renderColor(behavior.color)}
</>;
}
public render(): ReactNode {
return <DetailsList
hideCheckBox
className="behavior-picker-list"
items={this.getData()}
columns={[{
className: "behavior-picker-line",
key: "behavior",
render: this.renderLine
}]}
/>
}
}
export { BehaviorPicker };