Create Tag component (#52)

This commit is contained in:
Konrad Szwarc 2022-10-22 12:38:53 +02:00 committed by GitHub
parent aed657acaf
commit eb368790f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 40 additions and 6 deletions

View file

@ -1,7 +1,9 @@
import { Icon as IconComponent } from '@iconify-icon/react';
import type { IconName } from '@/types/icon';
export interface IconProps {
name?: string;
name?: IconName;
color?: string;
size: number;
}

View file

@ -0,0 +1,21 @@
---
import type { IconName } from '@/types/icon';
import Icon from './icon';
export interface Props {
icon?: {
name: IconName;
color: string;
};
}
const {
props: { icon },
} = Astro;
---
<div class="flex items-center w-fit h-6 px-2.5 rounded text-sm font-medium text-gray-700 bg-gray-100 gap-x-1.5">
{icon && <Icon client:load name={icon.name} color={icon.color} size={16} />}
<slot />
</div>

View file

@ -0,0 +1,11 @@
---
import Tag from '@/atoms/tag.astro';
---
<div class="p-5">
<Tag>Tag text</Tag>
</div>
<div class="p-5">
<Tag icon={{ name: 'simple-icons:react', color: '#61DAFB' }}>Tag text</Tag>
</div>

View file

@ -1,4 +1,4 @@
import type { Icon } from './icon';
import type { IconName } from './icon';
export type LocalImage = Promise<{ default: ImageMetadata }>;
@ -9,13 +9,13 @@ export interface Detail {
export interface Social {
name: string;
icon: Icon;
icon: IconName;
url: string;
}
export interface Tag {
name: string;
icon?: Icon;
icon?: IconName;
iconColor?: string;
url?: string;
description?: string;
@ -23,5 +23,5 @@ export interface Tag {
export interface SectionConfig {
title: string;
icon: Icon;
icon: IconName;
}

View file

@ -7,6 +7,6 @@ type IconSets = {
'circle-flags': typeof import('@iconify/json/json/circle-flags.json');
};
export type Icon = ValueOf<{
export type IconName = ValueOf<{
[IconSet in keyof IconSets]: `${IconSet}:${StringKeyOf<IconSets[IconSet]['icons']>}`;
}>;