From 0f728dab344a5b0a9c991a784fe72f00f4deb5d0 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Wed, 20 Jul 2022 17:10:54 -0500 Subject: [PATCH] complement page and analytics for edit events --- package.json | 2 +- .../phrase-diagram/EditableEPEx.tsx | 19 ++- .../phrase-diagram/EditableVPEx.tsx | 18 ++- src/components/terms-links.tsx | 8 ++ src/content/compound-verbs/helper-verbs.mdx | 42 +++---- .../phrase-structure/blocks-and-kids.mdx | 1 + src/content/phrase-structure/complement.mdx | 112 ++++++++++++++++-- src/content/phrase-structure/np.mdx | 4 + yarn.lock | 8 +- 9 files changed, 176 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index 02e36f1..57fcbd9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "@formkit/auto-animate": "^1.0.0-beta.1", "@fortawesome/fontawesome-free": "^5.15.4", "@lingdocs/lingdocs-main": "^0.3.1", - "@lingdocs/pashto-inflector": "^3.4.5", + "@lingdocs/pashto-inflector": "^3.4.7", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", diff --git a/src/components/phrase-diagram/EditableEPEx.tsx b/src/components/phrase-diagram/EditableEPEx.tsx index 9447eb7..7f9b4ad 100644 --- a/src/components/phrase-diagram/EditableEPEx.tsx +++ b/src/components/phrase-diagram/EditableEPEx.tsx @@ -5,7 +5,9 @@ import { } from "@lingdocs/pashto-inflector"; import entryFeeder from "../../lib/entry-feeder"; import { useState } from "react"; - +import ReactGA from "react-ga"; +import { isProd } from "../../lib/isProd"; +import { useUser } from "../../user-context"; export function EditIcon() { return ; @@ -14,15 +16,28 @@ export function EditIcon() { function EditableEPEx({ children, opts, hideOmitSubject, noEdit }: { children: T.EPSelectionState, opts: T.TextOptions, hideOmitSubject?: boolean, noEdit?: boolean }) { const [editing, setEditing] = useState(false); const [eps, setEps] = useState(children); + const { user } = useUser(); function handleReset() { setEditing(false); setEps(children); } + function logEdit() { + if (isProd && !(user?.admin)) { + ReactGA.event({ + category: "Example", + action: "edit EPex", + label: "edit EPex" + }); + } + } return
{!noEdit &&
setEditing(true)} + onClick={editing ? handleReset : () => { + setEditing(true); + logEdit(); + }} > {!editing ? : }
} diff --git a/src/components/phrase-diagram/EditableVPEx.tsx b/src/components/phrase-diagram/EditableVPEx.tsx index a4fc366..33c60b2 100644 --- a/src/components/phrase-diagram/EditableVPEx.tsx +++ b/src/components/phrase-diagram/EditableVPEx.tsx @@ -6,6 +6,9 @@ import { } from "@lingdocs/pashto-inflector"; import entryFeeder from "../../lib/entry-feeder"; import { useState } from "react"; +import ReactGA from "react-ga"; +import { isProd } from "../../lib/isProd"; +import { useUser } from "../../user-context"; export function EditIcon() { return ; @@ -22,6 +25,16 @@ function EditableVPEx({ children, opts, formChoice, noEdit, length, mode }: { const [editing, setEditing] = useState(false); const [selectedLength, setSelectedLength] = useState<"long" | "short">(length || "short"); const [vps, setVps] = useState({ ...children }); + const { user } = useUser(); + function logEdit() { + if (isProd && !(user?.admin)) { + ReactGA.event({ + category: "Example", + action: "edit EPex", + label: "edit EPex" + }); + } + } function handleReset() { // TODO: this is crazy, how does children get changed after calling setVps ??? setVps(children); @@ -34,7 +47,10 @@ function EditableVPEx({ children, opts, formChoice, noEdit, length, mode }: { {!noEdit &&
setEditing(true)} + onClick={editing ? handleReset : () => { + setEditing(true); + logEdit(); + }} > {!editing ? : }
} diff --git a/src/components/terms-links.tsx b/src/components/terms-links.tsx index 4b90c80..5bc5357 100644 --- a/src/components/terms-links.tsx +++ b/src/components/terms-links.tsx @@ -20,6 +20,10 @@ export function EP({ text }: { text: string }) { return {text || "EP"}; } +export function Sandwich({ text }: { text: string}) { + return {text || "sandwich"}; +} + export function KidsSection({ text }: { text: string }) { return {text || "kids' section"}; } @@ -44,6 +48,10 @@ export function Video() { return ; } +export function BlocksIcon() { + return ; +} + export function KingIcon() { return ; } diff --git a/src/content/compound-verbs/helper-verbs.mdx b/src/content/compound-verbs/helper-verbs.mdx index 05973d3..00fce07 100644 --- a/src/content/compound-verbs/helper-verbs.mdx +++ b/src/content/compound-verbs/helper-verbs.mdx @@ -9,7 +9,7 @@ import { RootsAndStems, getVerbInfo, } from "@lingdocs/pashto-inflector"; -import { KidsSection, VP, KingIcon, ServantIcon, PerfectiveHead, Camera, Video } from "../../components/terms-links"; +import { KidsSection, VP, KingIcon, ServantIcon, PerfectiveHead, Camera, Video, Complement } from "../../components/terms-links"; import psmd from "../../lib/psmd"; import Link from "../../components/Link"; import Formula from "../../components/formula/Formula"; @@ -115,7 +115,7 @@ We have: - A **subject**: - A **complement**: -So with this verb we add a complement - something that the subject is *becoming*. +So with this verb we add a - something that the subject is *becoming*. { {"blocks":[{"key":0.8034429811171007,"block":{"type":"subjectSelection","selection":{"type":"NP","selection":{"type":"pronoun","person":5,"distance":"far"}}}},{"key":0.19673719282869384,"block":{"type":"objectSelection","selection":"none"}}],"verb":{"type":"verb","verb":{"entry":{"ts":1581086654898,"i":10697,"p":"کېدل","f":"kedul","g":"kedul","e":"to become _____","c":"v. intrans. irreg.","ssp":"ش","ssf":"sh","prp":"شول","prf":"shwul","pprtp":"شوی","pprtf":"shúwey","noOo":true,"ec":"become","ep":"_____"}},"verbTense":"presentVerb","perfectTense":"presentPerfect","imperativeTense":"imperfectiveImperative","tenseCategory":"basic","transitivity":"intransitive","isCompound":false,"voice":"active","negative":false,"canChangeTransitivity":false,"canChangeVoice":false,"canChangeStatDyn":false},"externalComplement":{"type":"complement","selection":{"type":"adjective","entry":{"ts":1527812792,"i":5826,"p":"خوشاله","f":"khoshaala","g":"khoshaala","e":"happy, glad","c":"adj."}}},"form":{"removeKing":false,"shrinkServant":false}} @@ -125,7 +125,7 @@ So with this verb we add a complement - something that the subject is *becoming* {"blocks":[{"key":0.8034429811171007,"block":{"type":"subjectSelection","selection":{"type":"NP","selection":{"type":"pronoun","person":0,"distance":"far"}}}},{"key":0.19673719282869384,"block":{"type":"objectSelection","selection":"none"}}],"verb":{"type":"verb","verb":{"entry":{"ts":1581086654898,"i":10697,"p":"کېدل","f":"kedul","g":"kedul","e":"to become _____","c":"v. intrans. irreg.","ssp":"ش","ssf":"sh","prp":"شول","prf":"shwul","pprtp":"شوی","pprtf":"shúwey","noOo":true,"ec":"become","ep":"_____"}},"verbTense":"presentVerb","perfectTense":"presentPerfect","imperativeTense":"imperfectiveImperative","tenseCategory":"basic","transitivity":"intransitive","isCompound":false,"voice":"active","negative":false,"canChangeTransitivity":false,"canChangeVoice":false,"canChangeStatDyn":false},"externalComplement":{"type":"complement","selection":{"type":"adjective","entry":{"ts":1527815306,"i":7598,"p":"ستړی","f":"stúRey","g":"stuRey","e":"tired","c":"adj."}}},"form":{"removeKing":false,"shrinkServant":false}} } -Notice how the **if the complement is an adjective in will inflect according to the subject**. +Notice how the **if the is an adjective in will inflect according to the subject**. { {"blocks":[{"key":0.8034429811171007,"block":{"type":"subjectSelection","selection":{"type":"NP","selection":{"type":"pronoun","person":1,"distance":"far"}}}},{"key":0.19673719282869384,"block":{"type":"objectSelection","selection":"none"}}],"verb":{"type":"verb","verb":{"entry":{"ts":1581086654898,"i":10697,"p":"کېدل","f":"kedul","g":"kedul","e":"to become _____","c":"v. intrans. irreg.","ssp":"ش","ssf":"sh","prp":"شول","prf":"shwul","pprtp":"شوی","pprtf":"shúwey","noOo":true,"ec":"become","ep":"_____"}},"verbTense":"presentVerb","perfectTense":"presentPerfect","imperativeTense":"imperfectiveImperative","tenseCategory":"basic","transitivity":"intransitive","isCompound":false,"voice":"active","negative":false,"canChangeTransitivity":false,"canChangeVoice":false,"canChangeStatDyn":false},"externalComplement":{"type":"complement","selection":{"type":"adjective","entry":{"ts":1527815306,"i":7598,"p":"ستړی","f":"stúRey","g":"stuRey","e":"tired","c":"adj."}}},"form":{"removeKing":false,"shrinkServant":false}} @@ -139,23 +139,23 @@ But that's not all... Here's something **suuuuuper interesting and important** a #### Welding / splitting the complement 👨🏻‍🏭 ⛏️ -Depending on which part of the verb tree we're using (imperfective