|
@@ -1,23 +1,29 @@
|
|
|
import { Tag } from "antd";
|
|
import { Tag } from "antd";
|
|
|
|
|
+import { ITagData } from "../corpus/ChapterTagList";
|
|
|
|
|
|
|
|
-export interface TagNode {
|
|
|
|
|
- id: string;
|
|
|
|
|
- name: string;
|
|
|
|
|
- description?: string;
|
|
|
|
|
|
|
+interface IWidget {
|
|
|
|
|
+ data: ITagData[];
|
|
|
|
|
+ onTagClick?: Function;
|
|
|
}
|
|
}
|
|
|
-interface IWidgetTagArea {
|
|
|
|
|
- data: TagNode[];
|
|
|
|
|
-}
|
|
|
|
|
-const Widget = (prop: IWidgetTagArea) => {
|
|
|
|
|
- // TODO
|
|
|
|
|
- const tags = prop.data.map((item, id) => {
|
|
|
|
|
- return (
|
|
|
|
|
- <Tag color="green" key={id}>
|
|
|
|
|
- {item.name}
|
|
|
|
|
- </Tag>
|
|
|
|
|
- );
|
|
|
|
|
- });
|
|
|
|
|
- return <>{tags}</>;
|
|
|
|
|
|
|
+const Widget = ({ data, onTagClick }: IWidget) => {
|
|
|
|
|
+ // TODO
|
|
|
|
|
+ const tags = data.map((item, id) => {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Tag
|
|
|
|
|
+ color="green"
|
|
|
|
|
+ key={id}
|
|
|
|
|
+ style={{ cursor: "pointer" }}
|
|
|
|
|
+ onClick={() => {
|
|
|
|
|
+ if (typeof onTagClick !== "undefined") {
|
|
|
|
|
+ onTagClick(item.key);
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ >
|
|
|
|
|
+ {item.title}
|
|
|
|
|
+ </Tag>
|
|
|
|
|
+ );
|
|
|
|
|
+ });
|
|
|
|
|
+ return <>{tags}</>;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
export default Widget;
|
|
export default Widget;
|