From f258bc6cb4fde612d73af6dbd20c1024220dc364 Mon Sep 17 00:00:00 2001 From: Konrad Szwarc Date: Sat, 22 Oct 2022 13:04:36 +0200 Subject: [PATCH] Make all props used in components listed explicitly --- src/components/atoms/button.astro | 4 ++-- src/components/atoms/icon-button.astro | 22 +++++++++++---------- src/components/atoms/labelled-value.astro | 6 +++--- src/components/atoms/section-card.astro | 8 +------- src/components/atoms/sidebar-item.astro | 11 +++++------ src/components/atoms/skill-level-tile.astro | 4 +++- src/components/organisms/sidebar.astro | 8 +------- src/components/organisms/skill-level.astro | 7 ++++--- src/components/organisms/skill.astro | 16 +++++++-------- src/pages/playground/icon-button.astro | 8 ++++---- src/pages/playground/skill.astro | 2 +- 11 files changed, 43 insertions(+), 53 deletions(-) diff --git a/src/components/atoms/button.astro b/src/components/atoms/button.astro index 55f8025..72acb89 100644 --- a/src/components/atoms/button.astro +++ b/src/components/atoms/button.astro @@ -3,7 +3,7 @@ export interface Props { href: string; } -const { props } = Astro; +const { href } = Astro.props; const classes = { main: 'inline-flex items-center px-4 h-10 text-base font-medium rounded-md shadow-sm text-white bg-primary-600 select-none cursor-pointer', @@ -13,4 +13,4 @@ const classes = { }; --- - + diff --git a/src/components/atoms/icon-button.astro b/src/components/atoms/icon-button.astro index df5b3ef..88343ff 100644 --- a/src/components/atoms/icon-button.astro +++ b/src/components/atoms/icon-button.astro @@ -1,11 +1,14 @@ --- +import type { IconName } from '@/types/icon'; + import Icon from './icon'; type IconButtonSize = 'small' | 'large'; -export interface Props extends astroHTML.JSX.AnchorHTMLAttributes { - icon: string; - name: string; +export interface Props { + icon: IconName; + target?: astroHTML.JSX.AnchorHTMLAttributes['target']; + href: string; size: IconButtonSize; } @@ -14,11 +17,12 @@ const sizeMap: Record = { large: 'w-9 h-9', }; -const { icon, name, size, ...props } = Astro.props; +const { icon, href, target, size } = Astro.props; --- - + diff --git a/src/components/atoms/labelled-value.astro b/src/components/atoms/labelled-value.astro index 895f1e2..b357118 100644 --- a/src/components/atoms/labelled-value.astro +++ b/src/components/atoms/labelled-value.astro @@ -1,13 +1,13 @@ --- -export interface Props extends astroHTML.JSX.HTMLAttributes { +export interface Props { label: string; value: string; } -const { label, value, ...props } = Astro.props; +const { label, value } = Astro.props; --- -
+
{label}: {value}
diff --git a/src/components/atoms/section-card.astro b/src/components/atoms/section-card.astro index d79a884..283f44a 100644 --- a/src/components/atoms/section-card.astro +++ b/src/components/atoms/section-card.astro @@ -1,7 +1 @@ ---- -export interface Props extends astroHTML.JSX.HTMLAttributes {} - -const { props } = Astro; ---- - -
+
diff --git a/src/components/atoms/sidebar-item.astro b/src/components/atoms/sidebar-item.astro index 58aaf17..97d82f1 100644 --- a/src/components/atoms/sidebar-item.astro +++ b/src/components/atoms/sidebar-item.astro @@ -1,24 +1,23 @@ --- -import type { Icon as IconName } from '@/types/icon'; +import type { IconName } from '@/types/icon'; import Icon from './icon'; -export interface Props extends astroHTML.JSX.ButtonHTMLAttributes { +export interface Props { icon: IconName; active?: boolean; } -const { props } = Astro; +const { icon, active } = Astro.props; --- diff --git a/src/components/atoms/skill-level-tile.astro b/src/components/atoms/skill-level-tile.astro index 85bbd86..adf875e 100644 --- a/src/components/atoms/skill-level-tile.astro +++ b/src/components/atoms/skill-level-tile.astro @@ -1,9 +1,11 @@ --- -export interface Props extends astroHTML.JSX.HTMLAttributes { +export interface Props { skillLevel: number; tileLevel: number; } + const { skillLevel, tileLevel } = Astro.props; + const isFilled = skillLevel >= tileLevel; --- diff --git a/src/components/organisms/sidebar.astro b/src/components/organisms/sidebar.astro index 8df5a60..611c83d 100644 --- a/src/components/organisms/sidebar.astro +++ b/src/components/organisms/sidebar.astro @@ -1,9 +1,3 @@ ---- -export interface Props extends astroHTML.JSX.HTMLAttributes {} - -const { props } = Astro; ---- - -