Create Tag component (#52)
This commit is contained in:
parent
aed657acaf
commit
eb368790f0
5 changed files with 40 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
21
src/components/atoms/tag.astro
Normal file
21
src/components/atoms/tag.astro
Normal 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>
|
||||
11
src/pages/playground/tag.astro
Normal file
11
src/pages/playground/tag.astro
Normal 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>
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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']>}`;
|
||||
}>;
|
||||
|
|
|
|||
Loading…
Reference in a new issue