Skip to content

Commit

Permalink
Add asset ID to asset box as capsule
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanqui committed Jan 8, 2025
1 parent 0337f2b commit c202358
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 21 deletions.
22 changes: 17 additions & 5 deletions src/lib/AssetBox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,38 @@
import type { AssetData } from "$src/types";
import Box from "./Box.svelte";
import SvelteMarkdown from '@humanspeak/svelte-markdown'
import Capsule from "./Capsule.svelte";
interface Props {
data: AssetData;
}
let { data }: Props = $props();
</script>

<Box>
<div class="asset">
<div>
<div class="asset-name">
<a href="{ data.inventory_url }"> { data.name }</a>
<a href="{ data.inventory_url }">
{#if data.id}
<Capsule>
HH{data.id}
</Capsule>
{/if}
</a>
<a href="{ data.inventory_url }">
{ data.name }
</a>
</div>
<p>
<SvelteMarkdown source={data.description} />
</p>
</div>
{#if data.picture.url}
<div class="asset-photo">
<a href="{ data.inventory_url }" class="asset-photo">
<img src="{ data.picture.url }" class="asset-img" alt="">
</div>
</a>
{/if}
</div>
</Box>
Expand All @@ -39,7 +50,7 @@
}
.asset-photo {
width: 350px;
display: block;
margin-right: 4px;
margin-left: 16px;
flex-shrink: 0;
Expand All @@ -52,7 +63,8 @@
width: 334px;
height: 200px;
object-fit: cover;
}
}
@media only screen and (max-width: 600px) {
.asset {
Expand Down
27 changes: 27 additions & 0 deletions src/lib/Capsule.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<script lang="ts">
import type { Snippet } from 'svelte';
let props: {
children?: Snippet;
} = $props();
</script>

<span class="capsule">
{@render props.children?.()}
</span>

<style>
.capsule {
background-color: var(--color-secondary);
color: white;
padding: 2px 4px;
border-radius: 4px;
font-size: 0.9em;
/* margin-left: 8px; */
font-size: 18px;
display: inline-block;
vertical-align: middle;
margin-bottom: 3px;
}
</style>
21 changes: 5 additions & 16 deletions src/lib/InterviewBox.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import type { InterviewData } from "$src/types";
import Box from "./Box.svelte";
import Capsule from "./Capsule.svelte";
interface Props {
data: InterviewData;
Expand All @@ -16,7 +17,10 @@
<h3>
<a href={data.complete ? "/interviews/" + data.slug : undefined}>{ data.title }</a>
{#if !data.complete}
<br><span class="in-progress">připravujeme</span>
<br>
<Capsule>
připravujeme
</Capsule>
{/if}
</h3>
{#if compact}
Expand Down Expand Up @@ -82,21 +86,6 @@
color: black;
}
.in-progress {
background-color: var(--color-secondary);
color: white;
padding: 2px 4px;
border-radius: 4px;
font-size: 0.9em;
margin-left: 8px;
font-size: 18px;
display: inline-block;
vertical-align: middle;
margin-bottom: 3px;
}
.compact h3 {
font-size: 1.2em;
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/rhinventory_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export async function loadRHInventoryAssetData(

const assets = apiAssets.assets.map(APIAsset => {
return {
id: APIAsset.id,
name: APIAsset.name,
picture: {url: APIAsset.primary_image_path},
description: APIAsset.description,
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface InterviewData {
}

export interface AssetData {
id?: string;
name: string;
picture: Photo;
description: string;
Expand Down

0 comments on commit c202358

Please sign in to comment.