Replies: 3 comments 9 replies
-
Hello @glenlong Thank you for communicating with us. For now we have been moving through the latest variant, providing the basics in functionality and giving some widgets and letting each developer follow their path from there, also given the complexity of the design. It is something very personal and depends on the type of topic addressed. However we are working on something that we will release soon that will help you choose specialized and custom widgets to make it a little easier to implement specialized sites using the template. We'll let you know as soon as we have it. |
Beta Was this translation helpful? Give feedback.
-
Please take a look at this example of a widget migrated to props and tell me what you think. There are some complexities in using it and we have decided for now to use a combination of For example, in the case of Case 1: ---
import Hero from '~/components/widgets/Hero.astro';
---
<Hero
title="Hello Hero"
subtitle="Lorem ipsum lorem"
callToAction1={{
text: "Get started",
href: "#",
icon: "tabler:arrow-down-right"
}}
callToAction2={{
text: "Learn more",
href: "#"
}}
image={{
src: import('~/assets/images/hero.png'),
alt: ""
}}
/> Case 2: ---
import Hero from '~/components/widgets/Hero.astro';
const heroData= {
title: "Hello Hero",
subtitle: "Lorem ipsum lorem",
callToAction1: {
text: "Get started",
href: "#",
icon: "tabler:arrow-down-right"
},
callToAction2: {
text: "Learn more",
href: "#"
},
image: {
src: import('~/assets/images/hero.png'),
alt: "Some alt"
}
}
---
<Hero
{...heroData}
/> Case 3: ---
import { Picture } from '@astrojs/image/components';
import Hero from '~/components/widgets/Hero.astro';
---
<Hero
subtitle="Lorem ipsum lorem"
callToAction1={{
text: "Get started",
href: "#",
icon: "tabler:arrow-down-right"
}}
callToAction2={{
text: "Learn more",
href: "#"
}}
>
<Fragment slot="title">
Title with some mix between <strong>Text</strong> and <strong>Html</strong>
</Fragment>
<Fragment slot="image">
<Picture
src={import('~/assets/images/hero.png')}
alt="Some alt"
class="mx-auto rounded-md w-full"
widths={[400, 768, 1480]}
sizes="(max-width: 767px) 400px, (max-width: 1479px) 768px, 1480px"
aspectRatio={1480 / 833}
loading="eager"
width={1480}
height={833}
/>
</Fragment>
</Hero> This is the source code of the example ---
import { Icon } from 'astro-icon';
import { Picture } from '@astrojs/image/components';
interface CallToAction {
text: string;
href: string;
icon?: string;
}
export interface Props {
title?: string;
subtitle?: string;
callToAction1?: string | CallToAction;
callToAction2?: string | CallToAction;
image?: string | any; // TODO: find HTMLElementProps
}
const {
title = await Astro.slots.render('title'),
subtitle = await Astro.slots.render('subtitle'),
callToAction1 = await Astro.slots.render('callToAction1'),
callToAction2 = await Astro.slots.render('callToAction2'),
image = await Astro.slots.render('image'),
} = Astro.props;
---
<section>
<div class="max-w-6xl mx-auto px-4 sm:px-6">
<div class="py-12 md:py-20">
<div class="text-center pb-10 md:pb-16 max-w-5xl mx-auto">
{
title && (
<h1
class="text-5xl md:text-[3.50rem] font-bold leading-tighter tracking-tighter mb-4 font-heading"
set:html={title}
/>
)
}
<div class="max-w-3xl mx-auto">
{subtitle && <p class="text-xl text-gray-600 mb-8 dark:text-slate-400" set:html={subtitle} />}
<div class="max-w-xs sm:max-w-md m-auto flex flex-nowrap flex-col sm:flex-row sm:justify-center gap-4">
{
callToAction1 && (
<div class="flex w-full sm:w-auto">
{typeof callToAction1 === 'string' ? (
<Fragment set:html={callToAction1} />
) : (
<a class="btn btn-primary sm:mb-0 w-full" href={callToAction1?.href} target="_blank" rel="noopener">
{callToAction1?.icon && <><Icon name={callToAction1.icon} class="w-5 h-5 mr-1 -ml-1.5" />{' '}</>}
{callToAction1?.text}
</a>
)}
</div>
)
}
{
callToAction2 && (
<div class="flex w-full sm:w-auto">
{typeof callToAction2 === 'string' ? (
<Fragment set:html={callToAction2} />
) : (
<a class="btn w-full" href={callToAction2?.href}>
{callToAction2?.icon && <><Icon name={callToAction2.icon} class="w-5 h-5 mr-1 -ml-1.5" />{' '}</>}
{callToAction2.text}
</a>
)}
</div>
)
}
</div>
</div>
</div>
<div>
{
image && (
<div class="relative m-auto max-w-4xl">
{typeof image === 'string' ? (
<Fragment set:html={image} />
) : (
<Picture
class="mx-auto rounded-md w-full"
widths={[400, 768, 1480]}
sizes="(max-width: 767px) 400px, (max-width: 1479px) 768px, 1480px"
aspectRatio={1480 / 833}
loading="eager"
width={1480}
height={833}
{...image}
/>
)}
</div>
)
}
</div>
</div>
</div>
</section> |
Beta Was this translation helpful? Give feedback.
-
Hi @prototypa, Love the updates! I agree it makes sense to use slots in certain places. I think you are doing this anyway, but it would be good to make sure that consistent property names are used across all the widgets, e.g., title, subtitle, description, etc. One other quick thought. You have several Features widgets, which is great. but Features1, Features2 is not very descriptive. Also I think maybe Features2 in AstroWind is a different layout to Features2 in TailNext, which could cause confusion later on. I wonder if maybe there is a way to name the widgets which is not too long, but more descriptive. For example: FeaturesListPlusImage These may not be quite right but hopefully you get the idea. Let me know what you think! |
Beta Was this translation helpful? Give feedback.
-
Love the template! Any plans to remove the hard-coded data in widgets like FAQs so that the content can be passed in via properties?
Beta Was this translation helpful? Give feedback.
All reactions