diff --git a/package.json b/package.json index 1c5e9cc6..4c8b0191 100644 --- a/package.json +++ b/package.json @@ -31,4 +31,4 @@ "tsx": "^4.19.2", "@tailwindcss/typography": "^0.5.15" } -} +} \ No newline at end of file diff --git a/src/components/chart.astro b/src/components/chart.astro index aa6fdb53..42c614bc 100644 --- a/src/components/chart.astro +++ b/src/components/chart.astro @@ -1,109 +1,116 @@ --- const { title, data } = Astro.props; -import crypto from 'crypto' -let id = crypto.randomBytes(20).toString('hex'); +import crypto from "crypto"; +let id = crypto.randomBytes(20).toString("hex"); --- + -
-

{title}

+
+

{title}

diff --git a/src/components/confidence_panel.astro b/src/components/confidence_panel.astro index 505410f0..91585b5e 100644 --- a/src/components/confidence_panel.astro +++ b/src/components/confidence_panel.astro @@ -1,15 +1,13 @@ --- const { conf } = Astro.props; let explainer = { - "Low confidence" : "Low confidence: This risk rating could be wrong, we don't know much about this combination.", - "Medium confidence": "Medium confidence: We're pretty sure this risk rating is right, but we aren't certain.", - "High confidence" : "High confidence: There is good evidence to support the risk rating of this combination." -} - + "Low confidence": + "Low confidence: This risk rating could be wrong, we don't know much about this combination.", + "Medium confidence": + "Medium confidence: We're pretty sure this risk rating is right, but we aren't certain.", + "High confidence": + "High confidence: There is good evidence to support the risk rating of this combination.", +}; --- -{conf && -

- {explainer[conf]} -

-} +{conf &&

{explainer[conf]}

} diff --git a/src/components/disclaimer.astro b/src/components/disclaimer.astro index 5e3553ea..5be4213d 100644 --- a/src/components/disclaimer.astro +++ b/src/components/disclaimer.astro @@ -1,16 +1,18 @@
-

+ class="block rounded-lg my-6 bg-red-50 p-6 shadow-[0_2px_15px_-3px_rgba(0,0,0,0.07),0_10px_20px_-2px_rgba(0,0,0,0.04)] max-w-2xl mx-auto" +> +

Disclaimer

-

+

This website may contain errors. If you find one, please help us fix it.

-

- Psychoactive use is embedded in cultural and environmental contexts and should be treated with caution and respect. +

+ Psychoactive use is embedded in cultural and environmental contexts and + should be treated with caution and respect.

-

- We promote psychoactive science and do not endorse illegal activity. We are fully compliant with NSW and federal Australian law. +

+ We promote psychoactive science and do not endorse illegal activity. We are + fully compliant with NSW and federal Australian law.

diff --git a/src/components/edit_page.astro b/src/components/edit_page.astro index aced2688..1c322347 100644 --- a/src/components/edit_page.astro +++ b/src/components/edit_page.astro @@ -1,4 +1,12 @@ --- -const { slug,type } = Astro.props; +const { slug, type } = Astro.props; --- -

Disagree? Found a typo? Got more info? Edit this page or email us

+ +

+ Disagree? Found a typo? Got more info? + Edit this page + or email us +

diff --git a/src/components/footer.astro b/src/components/footer.astro index 689e4033..04670fec 100644 --- a/src/components/footer.astro +++ b/src/components/footer.astro @@ -1,42 +1,55 @@ diff --git a/src/components/grid.tsx b/src/components/grid.tsx index 4b71bef0..01877134 100644 --- a/src/components/grid.tsx +++ b/src/components/grid.tsx @@ -48,7 +48,7 @@ function href(items){ } function title(items, psych_data) { - let subs = [...new Set(items)] + let subs :any[] = [...new Set(items)] subs.sort() if (subs.length == 1){ return psych_data[subs[0]].title @@ -61,7 +61,14 @@ function warn(i1, i2, data) { return (confidence([i1,i2], data) == 'Low confidence') } -class GridTable extends Component { +interface GridTableProps { + data: any[]; + chosen: any[]; + psych_data: any[]; + ordering: any[]; +} + +class GridTable extends Component { render(i, { value }) { let chosen = i.chosen let ordering = i.ordering @@ -161,49 +168,49 @@ export default class Grid extends Component { let ordering = slugs(i.data) let psychs = search(i.psych_data, query, ordering, this.state.checked_boxes) return ( - - -
- -
- {value == "" &&
- -
} - {value != "" &&
- - - - -
} - -
-
-
    - {psychs.map(item => ( - -
  • - -
  • + +
      + {psychs.map(item => ( + +
    • + + +
    • +
      + ))} +
    - ))} -
-
); } } diff --git a/src/components/navbar.astro b/src/components/navbar.astro index 08d0f0f2..a7ba69d2 100644 --- a/src/components/navbar.astro +++ b/src/components/navbar.astro @@ -1,39 +1,49 @@ --- -import { Image } from 'astro:assets' -import Search from '../components/search.tsx'; -import Offline from '../components/offline.tsx'; -import { getCollection } from 'astro:content'; -const substances = await getCollection('psychoactives'); -import logo from '/src/assets/logo.png' -let preact_data = [] -for (let sub of substances){ +import { Image } from "astro:assets"; +import Search from "../components/search.tsx"; +import Offline from "../components/offline.tsx"; +import { getCollection } from "astro:content"; +const substances = await getCollection("psychoactives"); +import logo from "/src/assets/logo.png"; +let preact_data = []; +for (let sub of substances) { let item = { - title : sub.data.title, - slug : sub.slug, - aka : sub.data.aka, - fam : sub.data.family_members - } - preact_data.push(item) + title: sub.data.title, + slug: sub.slug, + aka: sub.data.aka, + fam: sub.data.family_members, + }; + preact_data.push(item); } --- + - diff --git a/src/components/offline.tsx b/src/components/offline.tsx index 8ca30baf..418fa45a 100644 --- a/src/components/offline.tsx +++ b/src/components/offline.tsx @@ -17,7 +17,8 @@ async function getTotalFiles(){ const response = await fetch("/file_count.json"); const total = await response.json(); return total.file_count -} +} + // Available states: // We're on the server : grey signal // We're on an unspported browser : grey no-signal diff --git a/src/components/risk_panel.astro b/src/components/risk_panel.astro index e8607064..0e8e91da 100644 --- a/src/components/risk_panel.astro +++ b/src/components/risk_panel.astro @@ -1,17 +1,14 @@ --- const { risk } = Astro.props; + let risk_map = { -SR : "Significant risk: Danger! This is our most dangerous combination rating.", -GR : "Greater risk: Careful... This combination has a fair chance of harm.", -MR : "Minor risk: Watch out, this combination might have some unwanted effects.", -LRS : "Low risk synergy: This combination will enhance the effects of each psychoactive, or sometimes give new effects.", -LRD : "Low risk decrease: This combination will decrease the effects of one or both of these psychoactives.", -LRNS : "Low risk no synergy: This combination won't do much more than the individual effects of the psychoactives involved.", -} + SR: "Significant risk: Danger! This is our most dangerous combination rating.", + GR: "Greater risk: Careful... This combination has a fair chance of harm.", + MR: "Minor risk: Watch out, this combination might have some unwanted effects.", + LRS: "Low risk synergy: This combination will enhance the effects of each psychoactive, or sometimes give new effects.", + LRD: "Low risk decrease: This combination will decrease the effects of one or both of these psychoactives.", + LRNS: "Low risk no synergy: This combination won't do much more than the individual effects of the psychoactives involved.", +}; --- -{risk && -

- {risk_map[risk]} -

-} +{risk &&

{risk_map[risk]}

} diff --git a/src/components/search.tsx b/src/components/search.tsx index 302ef1dd..fd6d796c 100644 --- a/src/components/search.tsx +++ b/src/components/search.tsx @@ -55,7 +55,11 @@ function search(data, query, limit) { return out } -export default class Search extends Component { +interface SearchProps { + data: any[]; +} + +export default class Search extends Component { state = { value: '' }; onSubmit = e => { diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 9d431ce6..15f736c4 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -1,12 +1,13 @@ --- import { getImage } from "astro:assets"; -import Navbar from '../components/navbar.astro'; -import Footer from '../components/footer.astro'; -import { ViewTransitions } from 'astro:transitions'; +import Navbar from "../components/navbar.astro"; +import Footer from "../components/footer.astro"; +import { ViewTransitions } from "astro:transitions"; const { pageTitle, metaDescription } = Astro.props; -import logo from '/src/assets/logo.png' -let logo_data = await getImage({src: logo, width: 32, format: 'png'}) +import logo from "/src/assets/logo.png"; +let logo_data = await getImage({ src: logo, width: 32, format: "png" }); --- + @@ -18,13 +19,12 @@ let logo_data = await getImage({src: logo, width: 32, format: 'png'}) {pageTitle} {metaDescription && } - - - - + + +
-
+
diff --git a/src/pages/combos/[...slug].astro b/src/pages/combos/[...slug].astro index 3dbe2d61..6e30476d 100644 --- a/src/pages/combos/[...slug].astro +++ b/src/pages/combos/[...slug].astro @@ -1,70 +1,82 @@ --- -import { getCollection, getEntry } from 'astro:content'; +import { getCollection, getEntry } from "astro:content"; // 1. Generate a new path for every collection entry export async function getStaticPaths() { - const pages = await getCollection('combos'); - return pages.map(entry => ({ - params: { slug: entry.slug }, props: { entry }, + const pages = await getCollection("combos"); + return pages.map((entry) => ({ + params: { slug: entry.slug }, + props: { entry }, })); } // 2. When it's time to render, you can get the entry directly from the prop const { entry } = Astro.props; const { Content } = await entry.render(); -import data from '../../data.json'; -let value = entry.slug - -import BaseLayout from '../../layouts/BaseLayout.astro'; -let visible = false -if (entry.data.display_grid){ - visible = true +import data from "../../data.json"; +import BaseLayout from "../../layouts/BaseLayout.astro"; +let visible = false; +if (entry.data.display_grid) { + visible = true; } -import { getImage } from "astro:assets"; -import Disclaimer from '../../components/disclaimer.astro'; -import ConfidencePanel from '../../components/confidence_panel.astro'; -import EditPage from '../../components/edit_page.astro'; -import RiskPanel from '../../components/risk_panel.astro'; -import PsychLink from '../../components/psychlink.astro'; -let [psych1, psych2] = entry.slug.split('_') -const psych1_info = await getEntry('psychoactives', psych1); -const psych2_info = await getEntry('psychoactives', psych2); -import { risk, confidence, risk_to_bg } from '../../util'; -let psych1_info_img = await getImage({src: psych1_info.data.image_location, width: 700}) -let psych2_info_img = await getImage({src: psych2_info.data.image_location, width: 700}) +import Disclaimer from "../../components/disclaimer.astro"; +import ConfidencePanel from "../../components/confidence_panel.astro"; +import EditPage from "../../components/edit_page.astro"; +import RiskPanel from "../../components/risk_panel.astro"; +let [psych1, psych2] = entry.slug.split("_"); +const psych1_info = await getEntry("psychoactives", psych1); +const psych2_info = await getEntry("psychoactives", psych2); +import { risk, confidence } from "../../util"; --- - + + - + diff --git a/src/pages/index.astro b/src/pages/index.astro index 5c802662..c43de2df 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,69 +1,111 @@ --- import { getImage } from "astro:assets"; -import data from '../data.json'; -import Grid from '../components/grid.tsx'; -import Disclaimer from '../components/disclaimer.astro'; -import BaseLayout from '../layouts/BaseLayout.astro'; +import data from "../data.json"; +import Grid from "../components/grid.tsx"; +import Disclaimer from "../components/disclaimer.astro"; +import BaseLayout from "../layouts/BaseLayout.astro"; const pageTitle = "Combos"; -import { getCollection } from 'astro:content'; -const substances = await getCollection('psychoactives'); +import { getCollection } from "astro:content"; +const substances = await getCollection("psychoactives"); import Icon from "heroicons-astro/Heroicon.astro"; -import { combo, risk, drug_css_prefix, confidence, linkify, risk_to_bg } from '../util'; +import { risk_to_bg } from "../util"; -let preact_data = {} -for (let sub of substances){ +let preact_data = {}; +for (let sub of substances) { let item = { - title : sub.data.title, - slug : sub.slug, - aka : sub.data.aka, - fam : sub.data.family_members, - img : await getImage({src: sub.data.image_location, width: 220}), - img_capt : sub.data.image_caption - } - preact_data[sub.slug] = item + title: sub.data.title, + slug: sub.slug, + aka: sub.data.aka, + fam: sub.data.family_members, + img: await getImage({ src: sub.data.image_location, width: 220 }), + img_capt: sub.data.image_caption, + }; + preact_data[sub.slug] = item; } - --- - -
-
-
-
-

Psychoactive Combination Matrix

-

What this chart tells you

-

- How risky it is when you combine two psychoactives. -

-

How this chart works

-

- The coloured square where two psychoactives intersect on the grid is coded to show their combination risk. -

-

- Select psychoactives below to show them on the grid, or select psychoactives or combinations in the chart to learn more. -

-
+ + +
+
+
+
+

+ Psychoactive Combination Matrix +

+

What this chart tells you

+

+ How risky it is when you combine two psychoactives. +

+

How this chart works

+

+ The coloured square where two psychoactives intersect on the grid is + coded to show their combination risk. +

+

+ Select psychoactives below to show them on the grid, or select + psychoactives or combinations in the chart to learn more. +

-
-
-
-

Key

-

Risk = danger or hazard

-

Synergy = increased effects, or new effects

-

Decrease = reduced effects

-

-
- - = low confidence in the risk rating -
- - Significant Risk - Greater Risk - Minor Risk - Low Risk Synergy - Low Risk Decrease - Low Risk No Synergy +
+
+
+
+

Key

+

Risk = danger or hazard

+

Synergy = increased effects, or new effects

+

Decrease = reduced effects

+
+
+ + = low confidence in the risk rating +
+ + + Significant Risk + + Greater Risk + + Minor Risk + + Low Risk Synergy + + Low Risk Decrease + + Low Risk No Synergy -
- - + + diff --git a/src/pages/psychoactives.astro b/src/pages/psychoactives.astro index 0a356586..22a15f12 100644 --- a/src/pages/psychoactives.astro +++ b/src/pages/psychoactives.astro @@ -1,40 +1,50 @@ --- -import data from '../data.json'; -import { combo, risk, drug_css_prefix, confidence, linkify } from '../util'; -import BaseLayout from '../layouts/BaseLayout.astro'; +import data from "../data.json"; +import { combo, risk, drug_css_prefix, confidence, linkify } from "../util"; +import BaseLayout from "../layouts/BaseLayout.astro"; const pageTitle = "Psychs"; -import { getCollection } from 'astro:content'; -import { Image } from 'astro:assets' -const unsorted_substances = await getCollection('psychoactives'); -let idx = {} -for (let sub of unsorted_substances){ - idx[sub['slug']] = sub +import { getCollection } from "astro:content"; +import { Image } from "astro:assets"; +const unsorted_substances = await getCollection("psychoactives"); +let idx = {}; +for (let sub of unsorted_substances) { + idx[sub["slug"]] = sub; } -let substances = [] +let substances = []; for (let drug of data["drugs"]) { - let item = idx[linkify(drug)] - substances.push(item) + let item = idx[linkify(drug)]; + substances.push(item); } --- - -
- - {substances.map((substance) => ( - -
-

{substance.data.title}

-
- {substance.data.image_caption} -
- - ))} -
-
+ +
+ + { + substances.map((substance) => ( + +
+

+ {substance.data.title} +

+
+ {substance.data.image_caption} +
+ )) + } +
+
- diff --git a/src/pages/psychoactives/[...slug].astro b/src/pages/psychoactives/[...slug].astro index 8d9dc2a0..176fe2de 100644 --- a/src/pages/psychoactives/[...slug].astro +++ b/src/pages/psychoactives/[...slug].astro @@ -13,15 +13,11 @@ const { Content } = await entry.render(); import data from '../../data.json'; let value = entry.slug const substances = await getCollection('psychoactives'); -import { getImage } from "astro:assets"; import BaseLayout from '../../layouts/BaseLayout.astro'; import EditPage from '../../components/edit_page.astro'; import Disclaimer from '../../components/disclaimer.astro'; -import Psychimage from '../../components/psychimage.astro'; import Icon from "heroicons-astro/Heroicon.astro"; -import { Image } from 'astro:assets' import { combo, risk, drug_css_prefix, confidence, linkify, risk_to_bg } from '../../util'; -let info_img = await getImage({src: entry.data.image_location, width: 700}) --- @@ -30,8 +26,8 @@ let info_img = await getImage({src: entry.data.image_location, width: 700})
{entry.data.image_caption}
{entry.data.image_caption} @@ -74,11 +70,11 @@ let info_img = await getImage({src: entry.data.image_location, width: 700})

{substance.data.title}

- {substance.data.image_caption} diff --git a/tailwind.config.cjs b/tailwind.config.cjs index 7868cfb6..5e42e32c 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.cjs @@ -1,10 +1,10 @@ /** @type {import('tailwindcss').Config} */ module.exports = { - content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'], - theme: { - extend: {}, - }, - plugins: [ - require('@tailwindcss/typography'), - ], + content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'], + theme: { + extend: {}, + }, + plugins: [ + require('@tailwindcss/typography'), + ], } diff --git a/tsconfig.json b/tsconfig.json index e05432a4..31b49677 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,6 +3,6 @@ "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "preact", - "allowJs" : true + "allowJs": true } -} +} \ No newline at end of file