Skip to content

Commit

Permalink
add alpine example for Hero
Browse files Browse the repository at this point in the history
  • Loading branch information
yuheiy committed Oct 4, 2023
1 parent 0f77654 commit 20c3b86
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/components/Hero.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@ type Props<Tag extends HTMLTag> = Polymorphic<{
const { as: Tag = 'div', class: className, title, description, ...props } = Astro.props;
---

<Tag {...props} class:list={['my-12', className]}>
<Tag x-data="hero" {...props} class:list={['my-12', className]}>
<h1 class="text-4xl font-bold kerning-all">
{title}
</h1>
{description && <p class="mt-8 text-xl">{description}</p>}
</Tag>

<script>
// eslint-disable-next-line import/no-named-as-default
import Alpine from 'alpinejs';

Alpine.data('hero', () => ({
init() {
if (import.meta.env.DEV) {
console.log('init hero component');
}
},
}));
</script>
2 changes: 1 addition & 1 deletion src/scripts/components/example.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function (Alpine: Alpine) {
Alpine.data('example', () => ({
init() {
if (import.meta.env.DEV) {
console.log('init component');
console.log('init example component');
}
},
}));
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/stores/example.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function (Alpine: Alpine) {
Alpine.store('example', {
init() {
if (import.meta.env.DEV) {
console.log('init store');
console.log('init example store');
}
},
});
Expand Down

0 comments on commit 20c3b86

Please sign in to comment.