Skip to content

Commit

Permalink
fixup warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
mastfissh committed Nov 26, 2024
1 parent 0c4a052 commit aeac131
Show file tree
Hide file tree
Showing 18 changed files with 505 additions and 399 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
"tsx": "^4.19.2",
"@tailwindcss/typography": "^0.5.15"
}
}
}
187 changes: 97 additions & 90 deletions src/components/chart.astro
Original file line number Diff line number Diff line change
@@ -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");
---

<span class={!title && "hidden"}>
<div class="block rounded-lg my-6 bg-slate-100 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">
<h2>{title} </h2>
<div
class="block rounded-lg my-6 bg-slate-100 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"
>
<h2>{title}</h2>
<canvas id={id}></canvas>
</div>
</span>
<script define:vars={{ data, id }}>
window.addEventListener("load", (event) => {
window.drawChart(id,data)
window.drawChart(id, data);
});
</script>
<script>
import Chart from 'chart.js/auto';
import { DateTime, Duration } from 'luxon';
import 'chartjs-adapter-luxon';
window.drawChart = function(targetId,duration_chart){
const now = DateTime.fromISO('12:00')
const ctx = document.getElementById(targetId);
let onset = Duration.fromISO("PT"+duration_chart.onset.toUpperCase())
let coming_up = Duration.fromISO("PT"+duration_chart.coming_up.toUpperCase())
let plateau = Duration.fromISO("PT"+duration_chart.plateau.toUpperCase())
let coming_down = Duration.fromISO("PT"+duration_chart.coming_down.toUpperCase())
let max = now.plus(onset).plus(coming_up).plus(plateau).plus(coming_down)
let chart_data = [
{x:now, y:0},
{x:now.plus(onset), y:0},
{x:now.plus(onset).plus(coming_up), y:1},
{x:now.plus(onset).plus(coming_up).plus(plateau), y:1},
{x:max, y:0},
]
Duration.fromISO('PT23H')
let total_duration_in_seconds = (max - now)/1000
function x_label_seconds(seconds) {
return `${seconds} secs`
}
function x_label_minutes(seconds) {
let display = Math.floor(seconds / 60)
return `${display} mins`
}
function x_label_hours(seconds) {
let display = Math.floor(seconds / 3600)
return `${display} hrs`
}
function x_label(timestamp) {
let diff = (timestamp - now.toMillis())/1000
if (total_duration_in_seconds < 400){
return x_label_seconds(diff)
import Chart from "chart.js/auto";
import { DateTime, Duration } from "luxon";
import "chartjs-adapter-luxon";
window.drawChart = function (targetId, duration_chart) {
const now = DateTime.fromISO("12:00");
const ctx = document.getElementById(targetId);
let onset = Duration.fromISO("PT" + duration_chart.onset.toUpperCase());
let coming_up = Duration.fromISO(
"PT" + duration_chart.coming_up.toUpperCase(),
);
let plateau = Duration.fromISO("PT" + duration_chart.plateau.toUpperCase());
let coming_down = Duration.fromISO(
"PT" + duration_chart.coming_down.toUpperCase(),
);
let max = now.plus(onset).plus(coming_up).plus(plateau).plus(coming_down);
let chart_data = [
{ x: now, y: 0 },
{ x: now.plus(onset), y: 0 },
{ x: now.plus(onset).plus(coming_up), y: 1 },
{ x: now.plus(onset).plus(coming_up).plus(plateau), y: 1 },
{ x: max, y: 0 },
];
Duration.fromISO("PT23H");
let total_duration_in_seconds = (max - now) / 1000;
function x_label_seconds(seconds) {
return `${seconds} secs`;
}
if (total_duration_in_seconds < 20000){
return x_label_minutes(diff)
function x_label_minutes(seconds) {
let display = Math.floor(seconds / 60);
return `${display} mins`;
}
return x_label_hours(diff)
}
let seen = []
function cleaned_x_label(timestamp, idx) {
let result = x_label(timestamp)
return idx % 4 === 0 ? result : ''
}
new Chart(ctx, {
type: 'line',
data: {
datasets: [
{
label: "Typical",
data: chart_data,
fill: false,
borderColor: 'rgb(75, 192, 192)',
cubicInterpolationMode: 'monotone',
tension: 0.4
function x_label_hours(seconds) {
let display = Math.floor(seconds / 3600);
return `${display} hrs`;
}
function x_label(timestamp) {
let diff = (timestamp - now.toMillis()) / 1000;
if (total_duration_in_seconds < 400) {
return x_label_seconds(diff);
}
]
},
options : {
scales: {
y: {
display: false,
grid: {
display: false
}
},
x: {
type: 'time',
grid: {
display: false
if (total_duration_in_seconds < 20000) {
return x_label_minutes(diff);
}
return x_label_hours(diff);
}
let seen = [];
function cleaned_x_label(timestamp, idx) {
let result = x_label(timestamp);
return idx % 4 === 0 ? result : "";
}
new Chart(ctx, {
type: "line",
data: {
datasets: [
{
label: "Typical",
data: chart_data,
fill: false,
borderColor: "rgb(75, 192, 192)",
cubicInterpolationMode: "monotone",
tension: 0.4,
},
],
},
options: {
scales: {
y: {
display: false,
grid: {
display: false,
},
},
ticks: {
callback: function(val, index, ticks) {
return cleaned_x_label(val, index);
x: {
type: "time",
grid: {
display: false,
},
major :{
enabled: true
}
}
}
ticks: {
callback: function (val, index, ticks) {
return cleaned_x_label(val, index);
},
major: {
enabled: true,
},
},
},
},
plugins: {
legend: {
display: false,
},
},
},
plugins: {
legend: {
display: false
}
}
}
});
}
});
};
</script>
18 changes: 8 additions & 10 deletions src/components/confidence_panel.astro
Original file line number Diff line number Diff line change
@@ -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 &&
<p>
{explainer[conf]}
</p>
}
{conf && <p>{explainer[conf]}</p>}
18 changes: 10 additions & 8 deletions src/components/disclaimer.astro
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<div
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" >
<h3
class="mb-2 text-xl font-medium leading-tight text-neutral-800 ">
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"
>
<h3 class="mb-2 text-xl font-medium leading-tight text-neutral-800">
Disclaimer
</h3>
<p class="mb-4 text-base text-neutral-600 ">
<p class="mb-4 text-base text-neutral-600">
This website may contain errors. If you find one, please help us fix it.
</p>
<p class="mb-4 text-base text-neutral-600 ">
Psychoactive use is embedded in cultural and environmental contexts and should be treated with caution and respect.
<p class="mb-4 text-base text-neutral-600">
Psychoactive use is embedded in cultural and environmental contexts and
should be treated with caution and respect.
</p>
<p class="mb-4 text-base text-neutral-600 ">
We promote psychoactive science and do not endorse illegal activity. We are fully compliant with NSW and federal Australian law.
<p class="mb-4 text-base text-neutral-600">
We promote psychoactive science and do not endorse illegal activity. We are
fully compliant with NSW and federal Australian law.
</p>
</div>
12 changes: 10 additions & 2 deletions src/components/edit_page.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
---
const { slug,type } = Astro.props;
const { slug, type } = Astro.props;
---
<p>Disagree? Found a typo? Got more info? <a class="font-medium text-blue-600 underline dark:text-blue-900 hover:no-underline" href={`https://github.com/mastfissh/safety_matrix/edit/main/src/content/${type}/${slug}.mdx`}> Edit this page </a> or <a href="mailto:[email protected]">email us</a></p>

<p>
Disagree? Found a typo? Got more info? <a
class="font-medium text-blue-600 underline dark:text-blue-900 hover:no-underline"
href={`https://github.com/mastfissh/safety_matrix/edit/main/src/content/${type}/${slug}.mdx`}
>
Edit this page
</a> or <a href="mailto:[email protected]">email us</a>
</p>
87 changes: 50 additions & 37 deletions src/components/footer.astro
Original file line number Diff line number Diff line change
@@ -1,42 +1,55 @@
<footer class="bg-gray-900">
<div class="mx-auto w-full max-w-screen-xl">
<div class="grid grid-cols-2 gap-8 px-4 py-6 lg:py-8 md:grid-cols-4">
<div>
<h2 class="mb-6 text-sm font-semibold text-white uppercase">Contact Us</h2>
<ul class="text-white font-medium">
<li class="mb-4">
<a href="mailto:[email protected]" class="hover:underline">Email</a>
</li>
<li class="mb-4">
<a href="https://github.com/mastfissh/safety_matrix/issues" class="hover:underline">Github</a>
</li>
</ul>
</div>
<div>
<h2 class="mb-6 text-sm font-semibold text-white uppercase">Sitemap</h2>
<ul class="text-white font-medium">
<li class="mb-4">
<a href="/" class="hover:underline">Combos</a>
</li>
<li class="mb-4">
<a href="/psychoactives" class="hover:underline">Psychoactives</a>
</li>
</ul>
</div>
<div>
<h2 class="mb-6 text-sm font-semibold text-white uppercase">Other Resources</h2>
<ul class="text-white font-medium">
<li class="mb-4">
<a href="https://www.themescalinegarden.com/" class="hover:underline">The Mescaline Garden</a>
</li>
</ul>
</div>
<div class="mx-auto w-full max-w-screen-xl">
<div class="grid grid-cols-2 gap-8 px-4 py-6 lg:py-8 md:grid-cols-4">
<div>
<h2 class="mb-6 text-sm font-semibold text-white uppercase">
Contact Us
</h2>
<ul class="text-white font-medium">
<li class="mb-4">
<a href="mailto:[email protected]" class="hover:underline"
>Email</a
>
</li>
<li class="mb-4">
<a
href="https://github.com/mastfissh/safety_matrix/issues"
class="hover:underline">Github</a
>
</li>
</ul>
</div>
<div>
<h2 class="mb-6 text-sm font-semibold text-white uppercase">Sitemap</h2>
<ul class="text-white font-medium">
<li class="mb-4">
<a href="/" class="hover:underline">Combos</a>
</li>
<li class="mb-4">
<a href="/psychoactives" class="hover:underline">Psychoactives</a>
</li>
</ul>
</div>
<div>
<h2 class="mb-6 text-sm font-semibold text-white uppercase">
Other Resources
</h2>
<ul class="text-white font-medium">
<li class="mb-4">
<a
href="https://www.themescalinegarden.com/"
class="hover:underline">The Mescaline Garden</a
>
</li>
</ul>
</div>
</div>
<div class="px-4 py-6 md:flex md:items-center md:justify-between">
<span class="text-sm text-white sm:text-center">
Open Source. Coded by <a href="https://github.com/mastfissh">mastfissh.</a> Content by <a href="www.liamengel.doctor">Liam Engel.</a>
</span>
</div>
</div>
<span class="text-sm text-white sm:text-center">
Open Source. Coded by <a href="https://github.com/mastfissh"
>mastfissh.</a
> Content by <a href="www.liamengel.doctor">Liam Engel.</a>
</span>
</div>
</div>
</footer>
Loading

0 comments on commit aeac131

Please sign in to comment.