2023-07-02 09:28:41 +00:00
|
|
|
import {Component} from "preact";
|
|
|
|
import {type TourData} from "../../tours/exports.js";
|
2023-06-15 13:06:41 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
hasBeenCompleted: boolean;
|
2023-07-02 09:28:41 +00:00
|
|
|
tour: TourData;
|
2023-06-15 13:06:41 +00:00
|
|
|
};
|
|
|
|
|
2023-07-02 09:28: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";
|
2023-07-02 09:28:41 +00:00
|
|
|
const path = tour.requirements.path;
|
2023-06-15 13:06:41 +00:00
|
|
|
|
|
|
|
return `${baseUrl}${path}${anchor}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Tour extends Component<Props> {
|
|
|
|
render() {
|
2023-07-02 09:28:41 +00:00
|
|
|
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()}>
|
2023-07-02 09:28:41 +00:00
|
|
|
<h3>{tour.title}</h3>
|
2023-06-15 13:06:41 +00:00
|
|
|
{completed}
|
2023-07-02 09:28:41 +00:00
|
|
|
{tour.description}
|
2023-06-15 13:06:41 +00:00
|
|
|
<p class="tour-link">
|
2023-07-02 09:28:41 +00:00
|
|
|
<a href={tourLink(tour)}>Take this tour</a>
|
2023-06-15 13:06:41 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|