-
Notifications
You must be signed in to change notification settings - Fork 7
Bumps dependency versions; implements comboapp page #205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ee5d6af
Bump package version and upgrade dependencies; regenerate lockfile
sympact06 32a17de
Add combo checker dataset and rule-based interaction logic
sympact06 ab33086
Add self-hosted fonts and CSS module for Combo Checker UI
sympact06 792ccea
Add Combo Checker UI building blocks: Card, Legend, Selector, and Res…
sympact06 c4224cb
Add top-level ComboChecker component and page
sympact06 8e8fba2
Adjust package.json version
sympact06 62ea5a1
Switch combo logic to TripSit canonical dataset and JSON lookup
sympact06 0c024f1
Updated navlink with next link component
sympact06 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { RISK, type RiskKey } from "./comboData"; | ||
| import styles from "./comboChecker.module.css"; | ||
|
|
||
| interface ComboCardProps { | ||
| title: string; | ||
| risk: RiskKey; | ||
| note: string; | ||
| showNote: boolean; | ||
| delay: string; | ||
| } | ||
|
|
||
| function ComboCard({ title, risk, note, showNote, delay }: ComboCardProps) { | ||
| const r = RISK[risk]; | ||
| return ( | ||
| <div className={styles.card} style={{ animationDelay: delay }}> | ||
| <div className={styles.cardHead}> | ||
| <span className={styles.cardBadge} style={{ background: r.badge }}> | ||
| {r.glyph} | ||
| </span> | ||
| <div className={styles.cardTitleWrap}> | ||
| <div className={`${styles.cardTitle} ${styles.disp}`}>{title}</div> | ||
| <div | ||
| className={`${styles.cardLabel} ${styles.mono}`} | ||
| style={{ color: r.badge }} | ||
| > | ||
| {r.label} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| {showNote && note && <p className={styles.cardNote}>{note}</p>} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default ComboCard; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| import { useState, type CSSProperties } from "react"; | ||
| import Image from "next/image"; | ||
| import Link from "next/link"; | ||
| import logo from "../../../public/assets/img/logo.png"; | ||
| import { SUBSTANCES } from "./comboData"; | ||
| import Legend from "./Legend"; | ||
| import SubstanceSelector from "./SubstanceSelector"; | ||
| import ComboResults from "./ComboResults"; | ||
| import styles from "./comboChecker.module.css"; | ||
|
|
||
| interface ComboCheckerProps { | ||
| /** Accent color. Design options: #2487ce, #683394, #47aeff, #11dbcf. */ | ||
| accent?: string; | ||
| /** Show the explanation note on each result card. */ | ||
| showExplanations?: boolean; | ||
| /** Sort result cards by severity (most dangerous first). */ | ||
| sortBySeverity?: boolean; | ||
| } | ||
|
|
||
| function ComboChecker({ | ||
| accent = "#2487ce", | ||
| showExplanations = true, | ||
| sortBySeverity = true, | ||
| }: ComboCheckerProps) { | ||
| const domain = process.env.NEXT_PUBLIC_DNS_DOMAIN || "tripsit.me"; | ||
| const [selected, setSelected] = useState<string[]>([]); | ||
| const [query, setQuery] = useState(""); | ||
|
|
||
| const toggle = (name: string) => | ||
| setSelected((prev) => | ||
| prev.includes(name) ? prev.filter((n) => n !== name) : prev.concat(name), | ||
| ); | ||
|
|
||
| return ( | ||
| <div | ||
| className={styles.root} | ||
| style={{ "--cc-accent": accent } as CSSProperties} | ||
| > | ||
| <nav className={styles.nav}> | ||
| <a href={`https://${domain}`} className={styles.brand}> | ||
| <Image | ||
| src={logo} | ||
| alt="TripSit" | ||
| className={styles.brandLogo} | ||
| priority | ||
| /> | ||
| </a> | ||
| <div className={styles.navLinks}> | ||
| <a href={`https://${domain}#about`} className={styles.navLink}> | ||
| About | ||
| </a> | ||
| <Link href="/factsheets" className={styles.navLink}> | ||
| Factsheets | ||
| </Link> | ||
| <Link href="/webchat" className={styles.navLink}> | ||
| Chat | ||
| </Link> | ||
| <Link | ||
| href="/combo" | ||
| className={`${styles.navLink} ${styles.navLinkActive}`} | ||
| > | ||
| Tools | ||
| </Link> | ||
| </div> | ||
| </nav> | ||
|
|
||
| <main className={styles.main}> | ||
| <header> | ||
| <h1 className={`${styles.title} ${styles.disp}`}> | ||
| Drug Combinations | ||
| </h1> | ||
| <p className={styles.subtitle}> | ||
| Check how two or more substances interact before you mix. Pick | ||
| substances below. This is a quick-reference guide, not medical | ||
| advice. | ||
| </p> | ||
| </header> | ||
|
|
||
| <Legend /> | ||
|
|
||
| <SubstanceSelector | ||
| substances={SUBSTANCES} | ||
| selected={selected} | ||
| query={query} | ||
| onToggle={toggle} | ||
| onQuery={setQuery} | ||
| onClearAll={() => setSelected([])} | ||
| /> | ||
|
|
||
| <p | ||
| className={`${styles.sectionLabel} ${styles.sectionLabelResults} ${styles.disp}`} | ||
| > | ||
| Combinations | ||
| </p> | ||
| <ComboResults | ||
| selected={selected} | ||
| accent={accent} | ||
| showExplanations={showExplanations} | ||
| sortBySeverity={sortBySeverity} | ||
| /> | ||
|
|
||
| <div className={styles.disclaimer}> | ||
| This tool, like the combo chart, is a quick-reference guide.{" "} | ||
| <strong>Additional research MUST always be done</strong>. When in | ||
| doubt, don't mix; start low and go slow. | ||
| </div> | ||
| </main> | ||
|
|
||
| <footer className={styles.footer}> | ||
| <div className={styles.footerInner}> | ||
| <Image src={logo} alt="TripSit" className={styles.footerLogo} /> | ||
| <span className={styles.footerCopy}> | ||
| © Copyright TripSit. All Rights Reserved. | ||
| </span> | ||
| </div> | ||
| </footer> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default ComboChecker; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| import { useMemo } from "react"; | ||
| import { accentTone, getCombo, RANK, type RiskKey } from "./comboData"; | ||
| import ComboCard from "./ComboCard"; | ||
| import styles from "./comboChecker.module.css"; | ||
|
|
||
| interface ComboResultsProps { | ||
| selected: string[]; | ||
| accent: string; | ||
| showExplanations: boolean; | ||
| sortBySeverity: boolean; | ||
| } | ||
|
|
||
| interface Card { | ||
| key: string; | ||
| title: string; | ||
| risk: RiskKey; | ||
| note: string; | ||
| } | ||
|
|
||
| function ComboResults({ | ||
| selected, | ||
| accent, | ||
| showExplanations, | ||
| sortBySeverity, | ||
| }: ComboResultsProps) { | ||
| const cards = useMemo<Card[]>(() => { | ||
| const out: (Card & { rank: number })[] = []; | ||
| for (let i = 0; i < selected.length; i += 1) { | ||
| for (let j = i + 1; j < selected.length; j += 1) { | ||
| const a = selected[i]; | ||
| const b = selected[j]; | ||
| const { risk, note } = getCombo(a, b); | ||
| out.push({ | ||
| key: `${a}|${b}`, | ||
| title: `${a} + ${b}`, | ||
| risk, | ||
| note, | ||
| rank: RANK[risk], | ||
| }); | ||
| } | ||
| } | ||
| if (sortBySeverity) out.sort((x, y) => y.rank - x.rank); | ||
| return out; | ||
| }, [selected, sortBySeverity]); | ||
|
|
||
| if (selected.length < 2) { | ||
| const tone = accentTone(accent); | ||
| const emptyText = | ||
| selected.length === 0 | ||
| ? "Select two or more substances above to see how they interact." | ||
| : `Select at least one more substance to compare with ${selected[0]}.`; | ||
| return ( | ||
| <div className={styles.empty}> | ||
| <div | ||
| className={styles.emptyIcon} | ||
| style={{ background: tone.container }} | ||
| > | ||
| <svg | ||
| width="34" | ||
| height="24" | ||
| viewBox="0 0 40 28" | ||
| fill="none" | ||
| aria-hidden="true" | ||
| > | ||
| <circle cx="15" cy="14" r="11" stroke={accent} strokeWidth="2.4" /> | ||
| <circle cx="25" cy="14" r="11" stroke={accent} strokeWidth="2.4" /> | ||
| </svg> | ||
| </div> | ||
| <p className={styles.emptyText}>{emptyText}</p> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return ( | ||
| <div className={styles.grid}> | ||
| {cards.map((c, i) => ( | ||
| <ComboCard | ||
| key={c.key} | ||
| title={c.title} | ||
| risk={c.risk} | ||
| note={c.note} | ||
| showNote={showExplanations} | ||
| delay={`${Math.min(i, 8) * 0.035}s`} | ||
| /> | ||
| ))} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default ComboResults; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { LEGEND_ORDER, RISK } from "./comboData"; | ||
| import styles from "./comboChecker.module.css"; | ||
|
|
||
| function Legend() { | ||
| return ( | ||
| <div className={styles.legend}> | ||
| {LEGEND_ORDER.map((key) => { | ||
| const r = RISK[key]; | ||
| return ( | ||
| <span | ||
| key={key} | ||
| className={styles.legendItem} | ||
| style={{ background: r.cBg, color: r.cText }} | ||
| > | ||
| <span | ||
| className={styles.legendBadge} | ||
| style={{ background: r.badge }} | ||
| > | ||
| {r.glyph} | ||
| </span> | ||
| {r.label} | ||
| </span> | ||
| ); | ||
| })} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default Legend; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.