From 972eba8afcb464863cb6cab32996ea1df67f7d38 Mon Sep 17 00:00:00 2001 From: Alex-At-Home Date: Fri, 17 Jul 2020 17:08:00 -0400 Subject: [PATCH] [#100] Add docs for luck (and other menu items at the same time) --- src/components/LineupStatsTable.tsx | 9 +++++++++ src/components/RosterStatsTable.tsx | 1 + src/components/TeamReportStatsTable.tsx | 2 ++ src/components/TeamStatsTable.tsx | 11 +++++++++++ .../__snapshots__/LineupStatsTable.test.tsx.snap | 9 +++++++++ .../__snapshots__/RosterStatsTable.test.tsx.snap | 4 ++++ .../__snapshots__/TeamReportStatsTable.test.tsx.snap | 8 ++++++++ src/components/diags/LuckAdjDiagView.tsx | 4 +++- .../diags/__tests__/LuckAdjDiagView.test.tsx | 2 ++ .../__snapshots__/LuckAdjDiagView.test.tsx.snap | 9 +++++++++ src/components/shared/GenericTogglingMenuItem.tsx | 8 +++++--- src/components/shared/LuckConfigModal.tsx | 9 ++++++--- .../shared/__tests__/GenericTogglingMenu.test.tsx | 1 + .../shared/__tests__/LuckConfigModal.test.tsx | 1 + .../__snapshots__/GenericTogglingMenu.test.tsx.snap | 9 +++++++++ .../__snapshots__/LuckConfigModal.test.tsx.snap | 1 + 16 files changed, 81 insertions(+), 7 deletions(-) diff --git a/src/components/LineupStatsTable.tsx b/src/components/LineupStatsTable.tsx index afda139a..e5189a37 100644 --- a/src/components/LineupStatsTable.tsx +++ b/src/components/LineupStatsTable.tsx @@ -55,6 +55,12 @@ type Props = { const LineupStatsTable: React.FunctionComponent = ({lineupStats, teamStats, rosterStats, startingState, onChangeState}) => { + const server = (typeof window === `undefined`) ? //(ensures SSR code still compiles) + "server" : window.location.hostname + + /** Only show help for diagnstic on/off on main page */ + const showHelp = !_.startsWith(server, "cbb-on-off-analyzer"); + // 1] Data Model // 2] State @@ -270,6 +276,7 @@ const LineupStatsTable: React.FunctionComponent = ({lineupStats, teamStat offLuck={luckAdj[0]} defLuck={luckAdj[1]} baseline={luckConfig.base} + showHelp={showHelp} />, "small pt-2" ) ] : [] , [ GenericTableOps.buildRowSeparator() ] @@ -382,6 +389,7 @@ const LineupStatsTable: React.FunctionComponent = ({lineupStats, teamStat onHide={() => setShowLuckConfig(false)} onSave={(l: LuckParams) => setLuckConfig(l)} luck={luckConfig} + showHelp={showHelp} /> @@ -414,6 +422,7 @@ const LineupStatsTable: React.FunctionComponent = ({lineupStats, teamStat text="Adjust for Luck" truthVal={adjustForLuck} onSelect={() => setAdjustForLuck(!adjustForLuck)} + helpLink={showHelp ? "https://hoop-explorer.blogspot.com/2020/07/luck-adjustment-details.html" : undefined} /> = ({gameFilterParams, tea text="Show Positional diagnostics" truthVal={showPositionDiags} onSelect={() => setShowPositionDiags(!showPositionDiags)} + helpLink={showHelp ? "https://hoop-explorer.blogspot.com/2020/05/classifying-college-basketball.html" : undefined} /> diff --git a/src/components/TeamReportStatsTable.tsx b/src/components/TeamReportStatsTable.tsx index c41b2026..15736a42 100644 --- a/src/components/TeamReportStatsTable.tsx +++ b/src/components/TeamReportStatsTable.tsx @@ -560,11 +560,13 @@ const TeamReportStatsTable: React.FunctionComponent = ({lineupReport, sta text={Show replacement On-Off alpha!} truthVal={incReplacementOnOff} onSelect={() => setIncReplacementOnOff(!incReplacementOnOff)} + helpLink={showHelp ? "https://hoop-explorer.blogspot.com/2020/04/replacement-on-off-heres-elevator-pitch.html" : undefined} /> Show RAPM experimental!} truthVal={incRapm} onSelect={() => setIncRapm(!incRapm)} + helpLink={showHelp ? "https://hoop-explorer.blogspot.com/2020/03/understanding-team-report-onoff-page.html#RAPM" : undefined} /> = ({gameFilterParams, teamStats, rosterStats, onChangeState}) => { + const server = (typeof window === `undefined`) ? //(ensures SSR code still compiles) + "server" : window.location.hostname + + /** Only show help for diagnstic on/off on main page */ + const showHelp = !_.startsWith(server, "cbb-on-off-analyzer"); + // 1] Data Model const [ adjustForLuck, setAdjustForLuck ] = useState(_.isNil(gameFilterParams.onOffLuck) ? @@ -145,6 +151,7 @@ const TeamStatsTable: React.FunctionComponent = ({gameFilterParams, teamS offLuck={luckAdjustment.on[0]} defLuck={luckAdjustment.on[1]} baseline={luckConfig.base} + showHelp={showHelp} />, "small pt-2" ) ] : [] , [ GenericTableOps.buildRowSeparator() ] @@ -158,6 +165,7 @@ const TeamStatsTable: React.FunctionComponent = ({gameFilterParams, teamS offLuck={luckAdjustment.off[0]} defLuck={luckAdjustment.off[1]} baseline={luckConfig.base} + showHelp={showHelp} />, "small pt-2" ) ] : [] , [ GenericTableOps.buildRowSeparator() ] @@ -171,6 +179,7 @@ const TeamStatsTable: React.FunctionComponent = ({gameFilterParams, teamS offLuck={luckAdjustment.baseline[0]} defLuck={luckAdjustment.baseline[1]} baseline={luckConfig.base} + showHelp={showHelp} />, "small pt-2" ) ] : [] , [ GenericTableOps.buildRowSeparator() ] @@ -200,6 +209,7 @@ const TeamStatsTable: React.FunctionComponent = ({gameFilterParams, teamS onHide={() => setShowLuckConfig(false)} onSave={(l: LuckParams) => setLuckConfig(l)} luck={luckConfig} + showHelp={showHelp} /> @@ -209,6 +219,7 @@ const TeamStatsTable: React.FunctionComponent = ({gameFilterParams, teamS text="Adjust for Luck" truthVal={adjustForLuck} onSelect={() => setAdjustForLuck(!adjustForLuck)} + helpLink={showHelp ? "https://hoop-explorer.blogspot.com/2020/07/luck-adjustment-details.html" : undefined} /> , }, GenericTableSeparator { @@ -7562,6 +7567,7 @@ exports[`LineupStatsTable LineupStatsTable - should create snapshot (with indivi "samplePoss": 111, } } + showHelp={true} />, }, GenericTableSeparator { @@ -8274,6 +8280,7 @@ exports[`LineupStatsTable LineupStatsTable - should create snapshot (with indivi "samplePoss": 102, } } + showHelp={true} />, }, GenericTableSeparator { @@ -8562,6 +8569,7 @@ exports[`LineupStatsTable LineupStatsTable - should create snapshot (with indivi onHide={[Function]} onSave={[Function]} show={false} + showHelp={true} /> @@ -1651,6 +1652,7 @@ exports[`TeamReportStatsTable TeamReportStatsTable - should create snapshot (all truthVal={true} /> @@ -16148,6 +16150,7 @@ exports[`TeamReportStatsTable TeamReportStatsTable - should create snapshot (rep truthVal={true} /> @@ -16162,6 +16165,7 @@ exports[`TeamReportStatsTable TeamReportStatsTable - should create snapshot (rep truthVal={true} /> @@ -53453,6 +53457,7 @@ exports[`TeamReportStatsTable TeamReportStatsTable - should create snapshot (rep truthVal={true} /> @@ -53467,6 +53472,7 @@ exports[`TeamReportStatsTable TeamReportStatsTable - should create snapshot (rep truthVal={true} /> @@ -57508,6 +57514,7 @@ exports[`TeamReportStatsTable TeamReportStatsTable - should create snapshot 1`] truthVal={true} /> @@ -57522,6 +57529,7 @@ exports[`TeamReportStatsTable TeamReportStatsTable - should create snapshot 1`] truthVal={false} /> diff --git a/src/components/diags/LuckAdjDiagView.tsx b/src/components/diags/LuckAdjDiagView.tsx index 51b1a8d2..8da1bf55 100644 --- a/src/components/diags/LuckAdjDiagView.tsx +++ b/src/components/diags/LuckAdjDiagView.tsx @@ -29,9 +29,10 @@ type Props = { offLuck: OffLuckAdjustmentDiags, defLuck: DefLuckAdjustmentDiags, baseline: LuckAdjustmentBaseline, + showHelp: boolean, showDetailsOverride?: boolean }; -const LuckAdjDiagView: React.FunctionComponent = ({name, offLuck, defLuck, baseline, showDetailsOverride}) => { +const LuckAdjDiagView: React.FunctionComponent = ({name, offLuck, defLuck, baseline, showHelp, showDetailsOverride}) => { const topRef = React.createRef(); @@ -45,6 +46,7 @@ const LuckAdjDiagView: React.FunctionComponent = ({name, offLuck, defLuck return Luck Adjustment diagnostics [{name}] + {showHelp ? (?) : null}  off=[{o.deltaOffAdjEff.toFixed(1)}], def=[{d.deltaDefAdjEff.toFixed(1)}], margin=[{(o.deltaOffAdjEff - d.deltaDefAdjEff).toFixed(1)}] pts/100  ( { event.preventDefault(); setShowDetails(!showDetails) }}>show {showDetails ? "less" : "more"}) diff --git a/src/components/diags/__tests__/LuckAdjDiagView.test.tsx b/src/components/diags/__tests__/LuckAdjDiagView.test.tsx index 96bcc013..6dc554b2 100644 --- a/src/components/diags/__tests__/LuckAdjDiagView.test.tsx +++ b/src/components/diags/__tests__/LuckAdjDiagView.test.tsx @@ -14,6 +14,7 @@ describe("LuckAdjDiagView", () => { offLuck={sampleOffOnOffLuckDiagnostics} defLuck={sampleDefOnOffLuckDiagnostics} baseline="season" + showHelp={false} /> ); expect(toJson(wrapper)).toMatchSnapshot(); @@ -26,6 +27,7 @@ describe("LuckAdjDiagView", () => { offLuck={sampleOffOnOffLuckDiagnostics} defLuck={sampleDefOnOffLuckDiagnostics} baseline="baseline" + showHelp={true} showDetailsOverride={true} /> ); diff --git a/src/components/diags/__tests__/__snapshots__/LuckAdjDiagView.test.tsx.snap b/src/components/diags/__tests__/__snapshots__/LuckAdjDiagView.test.tsx.snap index c66707a5..96ff87f5 100644 --- a/src/components/diags/__tests__/__snapshots__/LuckAdjDiagView.test.tsx.snap +++ b/src/components/diags/__tests__/__snapshots__/LuckAdjDiagView.test.tsx.snap @@ -8,6 +8,15 @@ exports[`LuckAdjDiagView LuckAdjDiagView - should create snapshot (baseline, ove Test2 ] + + + + (?) + +  off=[ -1.8 diff --git a/src/components/shared/GenericTogglingMenuItem.tsx b/src/components/shared/GenericTogglingMenuItem.tsx index d9722fc1..abc61984 100644 --- a/src/components/shared/GenericTogglingMenuItem.tsx +++ b/src/components/shared/GenericTogglingMenuItem.tsx @@ -19,14 +19,16 @@ import { faCheck } from '@fortawesome/free-solid-svg-icons' type Props = { readonly text: string | React.ReactNode, readonly truthVal: boolean, - readonly onSelect: () => void + readonly onSelect: () => void, + readonly helpLink?: string }; -const GenericTogglingMenuItem: React.FunctionComponent = ({text, truthVal, onSelect}) => { +const GenericTogglingMenuItem: React.FunctionComponent = ({text, truthVal, onSelect, helpLink}) => { return -
onSelect()}> +
{ if (!e.target.href) onSelect() }}> {_.isString(text) ? {text} : text} + {helpLink ?  (?) : null}      {truthVal ? : null}
diff --git a/src/components/shared/LuckConfigModal.tsx b/src/components/shared/LuckConfigModal.tsx index d17ea582..1b0eb83d 100644 --- a/src/components/shared/LuckConfigModal.tsx +++ b/src/components/shared/LuckConfigModal.tsx @@ -23,15 +23,18 @@ type Props = { show: boolean, onHide: () => void, onSave: (luck: LuckParams) => void, - luck: LuckParams + luck: LuckParams, + showHelp: boolean }; -const LuckConfigModal: React.FunctionComponent = ({onSave, luck, ...props}) => { +const LuckConfigModal: React.FunctionComponent = ({onSave, luck, showHelp, ...props}) => { // State decomposition: const [ generalLuckBase, setGeneralLuckBase ] = useState(luck.base as "baseline" | "season"); return - Luck Adjustment Config + Luck Adjustment Config {showHelp ? + (?) : null + } diff --git a/src/components/shared/__tests__/GenericTogglingMenu.test.tsx b/src/components/shared/__tests__/GenericTogglingMenu.test.tsx index e2c169a8..c6ccfaaa 100644 --- a/src/components/shared/__tests__/GenericTogglingMenu.test.tsx +++ b/src/components/shared/__tests__/GenericTogglingMenu.test.tsx @@ -32,6 +32,7 @@ describe("GenericTogglingMenu", () => { text="Test2" truthVal={true} onSelect={() => ""} + helpLink="https://test.com" /> Test3} diff --git a/src/components/shared/__tests__/LuckConfigModal.test.tsx b/src/components/shared/__tests__/LuckConfigModal.test.tsx index c2fbc542..be8c1726 100644 --- a/src/components/shared/__tests__/LuckConfigModal.test.tsx +++ b/src/components/shared/__tests__/LuckConfigModal.test.tsx @@ -15,6 +15,7 @@ describe("LuckConfigModal", () => { onHide={() => {}} onSave={(l: LuckParams) => {}} luck={{base: "baseline"}} + showHelp={true} />
); diff --git a/src/components/shared/__tests__/__snapshots__/GenericTogglingMenu.test.tsx.snap b/src/components/shared/__tests__/__snapshots__/GenericTogglingMenu.test.tsx.snap index 3b9b186d..7e3d05dc 100644 --- a/src/components/shared/__tests__/__snapshots__/GenericTogglingMenu.test.tsx.snap +++ b/src/components/shared/__tests__/__snapshots__/GenericTogglingMenu.test.tsx.snap @@ -66,6 +66,15 @@ exports[`GenericTogglingMenu GenericTogglingMenuItem - should create snapshot 1` Test2 + +   + + (?) + +      diff --git a/src/components/shared/__tests__/__snapshots__/LuckConfigModal.test.tsx.snap b/src/components/shared/__tests__/__snapshots__/LuckConfigModal.test.tsx.snap index 10fa9281..97f2f7dc 100644 --- a/src/components/shared/__tests__/__snapshots__/LuckConfigModal.test.tsx.snap +++ b/src/components/shared/__tests__/__snapshots__/LuckConfigModal.test.tsx.snap @@ -11,6 +11,7 @@ exports[`LuckConfigModal LuckConfigModal - should create snapshot 1`] = ` onHide={[Function]} onSave={[Function]} show={true} + showHelp={true} /> `;