From 8401a3fd45b7dcfccde17ebf35f6568ccd490f1a Mon Sep 17 00:00:00 2001 From: prototypa Date: Sun, 8 Jan 2023 21:55:29 -0500 Subject: [PATCH] Migrate more widgets to props and slots --- src/assets/styles/base.css | 4 + src/components/widgets/CallToAction.astro | 2 +- src/components/widgets/Stats.astro | 6 +- src/components/widgets/Steps2.astro | 134 +++++++++++----------- src/pages/index.astro | 26 ++++- 5 files changed, 101 insertions(+), 71 deletions(-) diff --git a/src/assets/styles/base.css b/src/assets/styles/base.css index 8d44ad1..700fd9f 100644 --- a/src/assets/styles/base.css +++ b/src/assets/styles/base.css @@ -28,6 +28,10 @@ stroke-width: 1.2; } +[astro-icon].icon-bold > * { + stroke-width: 2.4; +} + [data-aw-toggle-menu] path { @apply transition; } diff --git a/src/components/widgets/CallToAction.astro b/src/components/widgets/CallToAction.astro index dbd0250..20740bc 100644 --- a/src/components/widgets/CallToAction.astro +++ b/src/components/widgets/CallToAction.astro @@ -41,7 +41,7 @@ const { callToAction.text && callToAction.href && (
- + {callToAction.icon && } {callToAction.text} diff --git a/src/components/widgets/Stats.astro b/src/components/widgets/Stats.astro index cf255c1..3464e79 100644 --- a/src/components/widgets/Stats.astro +++ b/src/components/widgets/Stats.astro @@ -19,7 +19,7 @@ const { } = Astro.props; --- -
+
{ (title || subtitle || highlight) && (
@@ -43,8 +43,8 @@ const {
{ items.map(({ name, value }) => ( -
-
{value}
+
+
{value}

{name}

diff --git a/src/components/widgets/Steps2.astro b/src/components/widgets/Steps2.astro index 3c2ac48..b493a42 100644 --- a/src/components/widgets/Steps2.astro +++ b/src/components/widgets/Steps2.astro @@ -1,5 +1,33 @@ --- import { Icon } from 'astro-icon'; + +interface Item { + title: string; + description: string; + icon?: string; +} + +interface CallToAction { + text: string; + href: string; + icon?: string; +} + +export interface Props { + title?: string; + subtitle?: string; + highlight?: string; + callToAction?: string | CallToAction; + items: Array; +} + +const { + title = await Astro.slots.render('title'), + subtitle = await Astro.slots.render('subtitle'), + highlight, + callToAction = await Astro.slots.render('callToAction'), + items = [], +} = Astro.props; ---
@@ -9,78 +37,54 @@ import { Icon } from 'astro-icon';
-

- Sed ac magna sit amet risus tristique interdum, at vel velit in hac habitasse platea dictumst. -

- -

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sagittis, quam nec venenatis lobortis, mi - risus tempus nulla, sed porttitor est nibh at nulla. Praesent placerat enim ut ex tincidunt vehicula. - Fusce sit amet dui tellus. -

+ { + highlight && ( +

+ ) + } + {title &&

} + {subtitle &&

}

- - Get template - + { + typeof callToAction === 'string' ? ( + + ) : ( + callToAction && + callToAction.text && + callToAction.href && ( + + {callToAction.icon && } + {callToAction.text} + + ) + ) + }

    -
  • -
    - - 1 -
    -
    -

    Responsive Elements

    -

    - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sagittis, quam nec venenatis - lobortis, mi risus tempus nulla. -

    -
    -
  • -
  • -
    - - 2 -
    -
    -

    Flexible Team

    -

    - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sagittis, quam nec venenatis - lobortis, mi risus tempus nulla. -

    -
    -
  • -
  • -
    - - 3 -
    -
    -

    Ecologic Software

    -

    - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sagittis, quam nec venenatis - lobortis, mi risus tempus nulla. -

    -
    -
  • + { + items && items.length + ? items.map(({ title: title2, description, icon }, index) => ( +
  • +
    + + {icon ? : index + 1} + +
    +
    +

    +

    +

    +
  • + )) + : '' + }
diff --git a/src/pages/index.astro b/src/pages/index.astro index b8f61f4..04618b5 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -128,7 +128,7 @@ const meta = { ]} image={{ src: import('~/assets/images/astronaut.jpg'), - alt: "Steps image" + alt: 'Steps image', }} /> @@ -192,7 +192,29 @@ const meta = { - +