src/components/Project.astro (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
---
import type { Project } from "@/types";
interface Props {
project: Project;
}
const {
project: { name, description, languages, links },
} = Astro.props;
const { source, live, internal } = links;
const externalLinks = [
{ href: source, label: "source" },
{ href: live, label: "live" },
].filter((link) => link.href);
---
<div class="project">
<div class="meta">
<h3>{name}</h3>
<p>{description}</p>
{
languages && languages.length > 0 && (
<div class="languages">
{languages.map((lang) => (
<span
class="language"
title={lang.name}
style={{ "--colour": `var(--${lang.colour})` }}
>
{lang.name}
</span>
))}
</div>
)
}
</div>
<div class="links">
{
externalLinks.length > 0 && (
<div class="link-section left">
{externalLinks.map((link) => (
<a href={link.href} target="_blank" rel="noreferrer">
{link.label}
</a>
))}
</div>
)
}
{
internal && (
<div class="link-section right">
<a href={`/p/${internal}`}>read about it</a>
</div>
)
}
</div>
</div>
<style>
.project {
display: flex;
flex-direction: column;
padding: 0.5rem;
}
.meta {
display: flex;
flex-direction: column;
h3 {
font-weight: 700;
font-size: 1.2rem;
}
p {
font-size: 0.9rem;
color: hsl(var(--subtext1));
margin-bottom: 0.5rem;
}
}
.languages {
display: flex;
flex-direction: row;
flex-wrap: wrap;
gap: 0.5rem;
margin-top: 0.25rem;
.language {
font-size: 0.75rem;
padding: 0.1rem 0.5rem;
border-radius: 1rem;
font-weight: 550;
background-color: hsla(var(--surface0) / 1);
color: hsl(var(--text));
border: 2px solid hsla(var(--colour) / 0.5);
}
}
.links {
display: flex;
flex-direction: row;
align-items: center;
gap: 1ch;
margin-top: 1ch;
.link-section {
display: flex;
flex-direction: row;
border-radius: 5rem;
overflow: hidden;
border: 2px solid hsla(var(--overlay0) / 0.25);
background-color: hsla(var(--accent) / 0.1);
&:has(a:focus-visible) {
outline-color: hsl(var(--accent));
}
}
a {
display: inline-block;
color: hsl(var(--text));
padding: 0.5rem 0.75rem;
text-decoration: none;
line-height: 1;
font-weight: 600;
outline: none;
position: relative;
& + &::before {
content: "";
position: absolute;
left: -1px;
width: 2px;
height: 50%;
background-color: hsla(var(--accent) / 0.2);
}
&:focus-visible,
&:hover {
background-color: hsla(var(--accent) / 1);
color: hsl(var(--on-accent));
}
&:active {
background-color: hsla(var(--accent) / 0.8);
color: hsl(var(--on-accent));
}
}
.right {
margin-left: auto;
}
}
</style>
|