2
0
visuddhinanda 2 жил өмнө
parent
commit
08d3f54a05

+ 22 - 0
dashboard/src/components/dict/GrammarLookup.tsx

@@ -0,0 +1,22 @@
+import { grammar } from "../../reducers/command";
+import { openPanel } from "../../reducers/right-panel";
+import store from "../../store";
+
+interface IWidget {
+  word?: string;
+  children?: React.ReactNode;
+}
+const GrammarLookup = ({ word, children }: IWidget) => {
+  return (
+    <span
+      onClick={() => {
+        store.dispatch(grammar(word));
+        store.dispatch(openPanel("grammar"));
+      }}
+    >
+      {children}
+    </span>
+  );
+};
+
+export default GrammarLookup;

+ 29 - 0
dashboard/src/components/template/GrammarTermLookup.tsx

@@ -0,0 +1,29 @@
+import { IWidgetTermCtl, TermCtl } from "./Term";
+import GrammarLookup from "../dict/GrammarLookup";
+
+interface IGrammarTermLookupCtl {
+  word?: string;
+  term?: IWidgetTermCtl;
+}
+const GrammarTermLookupCtl = ({ word, term }: IGrammarTermLookupCtl) => {
+  return (
+    <GrammarLookup word={word}>
+      <TermCtl {...term} compact={true} />
+    </GrammarLookup>
+  );
+};
+
+interface IWidget {
+  props: string;
+}
+const Widget = ({ props }: IWidget) => {
+  const prop = JSON.parse(atob(props)) as IGrammarTermLookupCtl;
+  console.debug("QuoteLink", prop);
+  return (
+    <>
+      <GrammarTermLookupCtl {...prop} />
+    </>
+  );
+};
+
+export default Widget;