-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4965bf9
commit 71beb25
Showing
7 changed files
with
87 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
--- | ||
const { class: className, ...restProps } = Astro.props; | ||
const {class: className, ...restProps} = Astro.props | ||
--- | ||
|
||
<button | ||
class:list={[ | ||
className, | ||
"bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded w-full", | ||
]} | ||
{...Astro.props} | ||
class:list={[ | ||
className, | ||
'bg-blue-500 hover:bg-blue-700 active:bg-blue-900 text-white font-bold py-2 px-4 rounded w-full', | ||
]} | ||
{...Astro.props} | ||
> | ||
<slot /> | ||
<slot /> | ||
</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
import Layout from '#layouts/Layout.astro' | ||
import Prose from '#components/prose.astro' | ||
import Button from '#components/button.astro' | ||
--- | ||
|
||
<Layout> | ||
<Prose as="main"> | ||
<main class="min-w-[26rem] text-center"> | ||
<Button data-refresh-button>Flip</Button> | ||
<div class="text-9xl font-black font-mono" data-result> | ||
</div> | ||
</main> | ||
</Prose> | ||
</Layout> | ||
<script> | ||
let refreshButton: HTMLButtonElement = document.querySelector( | ||
'[data-refresh-button]' | ||
)!, | ||
result: HTMLElement = | ||
document.querySelector('[data-result]')! | ||
|
||
function renderResult(el: HTMLElement) { | ||
return (el.innerText = Math.round(Math.random()) | ||
? 'heads' | ||
: 'tails') | ||
} | ||
|
||
renderResult(result) | ||
|
||
refreshButton.addEventListener('click', () => { | ||
result.innerText = '🪙' | ||
|
||
setTimeout(() => { | ||
renderResult(result) | ||
}, 300) | ||
}) | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
import Layout from '#layouts/Layout.astro' | ||
import Prose from '#components/prose.astro' | ||
import Button from '#components/button.astro' | ||
--- | ||
|
||
<Layout> | ||
<Prose as="main"> | ||
<main class="min-w-[26rem] text-center"> | ||
<Button data-refresh-button>Flip</Button> | ||
<div class="text-9xl font-black font-mono" data-result> | ||
</div> | ||
</main> | ||
</Prose> | ||
</Layout> | ||
<script> | ||
let refreshButton: HTMLButtonElement = document.querySelector( | ||
'[data-refresh-button]' | ||
)!, | ||
result: HTMLElement = | ||
document.querySelector('[data-result]')! | ||
|
||
function renderResult(el: HTMLElement) { | ||
const sides = | ||
Number( | ||
new URL(location.href).searchParams.get('sides') | ||
) || 6 | ||
return (el.innerText = String( | ||
Math.floor(Math.random() * sides) + 1 | ||
)) | ||
} | ||
|
||
renderResult(result) | ||
|
||
refreshButton.addEventListener('click', () => { | ||
result.innerText = '🎲' | ||
|
||
setTimeout(() => { | ||
renderResult(result) | ||
}, 300) | ||
}) | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.