Skip to content

Commit

Permalink
feat: removed button
Browse files Browse the repository at this point in the history
  • Loading branch information
categoricalcat committed Oct 17, 2022
1 parent 971206b commit ea0a1e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 58 deletions.
38 changes: 3 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/master/packages/create-svelte).
# Dog Day!

## Creating a project
Everyday is dog day so I made this App that shows information about a different dog breed everyday.

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npm create svelte@latest

# create a new project in my-app
npm create svelte@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://kit.svelte.dev/docs/adapters) for your target environment.
[Check it out here](https://walze.github.io/dog-day)
1 change: 1 addition & 0 deletions src/routes/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { PageLoad } from '$types/page';
import breeds from '../../static/breeds.json';

export const prerender = true;
export const csr = false;

export const load: PageLoad = async () => {
const id = breeds[(random() * breeds.length) | 0];
Expand Down
27 changes: 4 additions & 23 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
import type { PageData } from './$types';
import { getDog } from '$lib/getBreed';
import startCase from 'lodash/startCase';
export let data: PageData;
let timedOut = false;
$: ({
description,
image: { alt, height, src, width },
Expand Down Expand Up @@ -82,24 +79,8 @@
</div>
</article>

<button
disabled={timedOut}
on:click={async () => {
if (timedOut) return;
timedOut = true;

getDog()
.then((breed) => {
data.breed = breed;
})
.finally(() => {
setTimeout(() => {
timedOut = false;
}, 5000);
});
}}
class="block mt-4 font-semibold text-xl tracking-wide px-8 py-4 bg-white rounded-lg shadow-lg dark:bg-gray-800 w-full mx-auto max-w-lg "
>
{timedOut ? 'too many dogs, must wait now...' : 'GET A NEW DOG'}
</button>
<p class="w-full mx-auto max-w-lg my-6 px-6">
Everyday is dog day so I made this App that shows information about a
different dog breed everyday.
</p>
</main>

0 comments on commit ea0a1e8

Please sign in to comment.