Skip to content

Commit

Permalink
Swap badge and text in property
Browse files Browse the repository at this point in the history
  • Loading branch information
alexBinns committed Oct 17, 2023
1 parent 51060eb commit 7cf941d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
13 changes: 8 additions & 5 deletions src/components/Badge.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
const { type = "default", text } = Astro.props;
const { type = "default", text, link } = Astro.props;
const badgeText = text ? text : type;
const coloursMap = {
experimental: 'bg-surface-accent-light text-content-accent border-outline-opaque',
Expand All @@ -11,8 +12,10 @@ const coloursMap = {
default: 'text-content-primary border-outline-opaque bg-surface-tertiary'
}
---
const badgeClass =`${coloursMap[type]} type-caption-2 inline-flex text-xs px-2 py-0.5 rounded-full border`
<span class=`${ coloursMap[type] } type-caption-2 inline-flex text-xs px-2 py-0.5 rounded-full border`>
{ text ? text : type }
</span>
---
{link ?
<a class={badgeClass} href={link}>{badgeText}</a> :
<span class={badgeClass}>{badgeText}</span>
}
9 changes: 3 additions & 6 deletions src/components/Property.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Badge from '../components/Badge.astro';
const { name, type } = Astro.props;
const customDataTypes = ['timestamp', 'bignumber', 'monetary', 'crn', 'location', 'phonenumber'];
const formattedType = type.toLowerCase();
const isLink = customDataTypes.includes(formattedType);
const link = customDataTypes.includes(formattedType) ? '/api/data-types#' + formattedType :undefined;
---

<li class="m-0 px-0 py-4 first:pt-0 last:pb-0">
Expand All @@ -14,14 +14,11 @@ const isLink = customDataTypes.includes(formattedType);
Name
</dt>
<dd>
<Badge text={name}/>
{name}
</dd>
<dt class="sr-only">Type</dt>
<dd class="font-mono text-xs text-zinc-400 dark:text-zinc-500">
{isLink ?
<a href={'/api/data-types#' + formattedType}>{formattedType}</a> :
<span>{formattedType}</span>
}
<Badge text={formattedType} link={link}>
</dd>
<dt class="sr-only">
Description
Expand Down

0 comments on commit 7cf941d

Please sign in to comment.