1
Fork 0
tildes-shepherd/source/options/components/tour.tsx

39 lines
968 B
TypeScript
Raw Permalink Normal View History

import {Component} from "preact";
import {type TourData} from "../../tours/exports.js";
2023-06-15 13:06:41 +00:00
type Props = {
hasBeenCompleted: boolean;
tour: TourData;
2023-06-15 13:06:41 +00:00
};
function tourLink(tour: TourData): string {
const anchor = `#tildes-shepherd-tour=${tour.id}`;
2023-06-15 13:06:41 +00:00
const baseUrl = "https://tildes.net";
const path = tour.requirements.path;
2023-06-15 13:06:41 +00:00
return `${baseUrl}${path}${anchor}`;
}
export class Tour extends Component<Props> {
render() {
const {hasBeenCompleted, tour} = this.props;
2023-06-15 13:06:41 +00:00
const classes = ["tour", hasBeenCompleted ? "completed" : ""].join(" ");
const completed = hasBeenCompleted ? (
<p class="tour-completed" title="You've completed this tour before!">
</p>
) : undefined;
return (
<div class={classes.trim()}>
<h3>{tour.title}</h3>
2023-06-15 13:06:41 +00:00
{completed}
{tour.description}
2023-06-15 13:06:41 +00:00
<p class="tour-link">
<a href={tourLink(tour)}>Take this tour</a>
2023-06-15 13:06:41 +00:00
</p>
</div>
);
}
}