This commit is contained in:
cirroskais 2024-03-29 15:46:04 -04:00
parent c6dde49802
commit f393dacd10
No known key found for this signature in database
GPG key ID: 5FC73EBF2678E33D
19 changed files with 71 additions and 55 deletions

View file

@ -1,47 +1,3 @@
# Svelte + Vite
# simple-loading-screen
This template should help get you started developing with Svelte in Vite.
## Recommended IDE Setup
[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).
## Need an official Svelte framework?
Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.
## Technical considerations
**Why use this over SvelteKit?**
- It brings its own routing solution which might not be preferable for some users.
- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.
This template contains as little as possible to get started with Vite + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.
Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.
**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**
Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.
**Why include `.vscode/extensions.json`?**
Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.
**Why enable `checkJs` in the JS template?**
It is likely that most cases of changing variable types in runtime are likely to be accidental, rather than deliberate. This provides advanced typechecking out of the box. Should you like to take advantage of the dynamically-typed nature of JavaScript, it is trivial to change the configuration.
**Why is HMR not preserving my local component state?**
HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/sveltejs/svelte-hmr/tree/master/packages/svelte-hmr#preservation-of-local-state).
If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.
```js
// store.js
// An extremely simple external store
import { writable } from 'svelte/store'
export default writable(0)
```
need to write this soon...

BIN
public/audio/Lady.mp3 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 KiB

BIN
public/img/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 KiB

BIN
public/img/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 KiB

BIN
public/img/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

BIN
public/img/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

BIN
public/img/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB

BIN
public/img/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 KiB

BIN
public/img/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 351 KiB

BIN
public/img/8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 KiB

View file

@ -3,15 +3,18 @@
import { Map, Gamepad2, Disc3 } from "lucide-svelte";
import { gameDetails } from "./lib/events";
import Slideshow from "./lib/Slideshow.svelte";
import Playlist from "./lib/Playlist.svelte";
import { writable } from "svelte/store";
let volume = 0.05;
let title = writable();
</script>
{#if $gameDetails}
<div in:scale class="h-screen w-screen">
<div class="h-full w-full flex justify-center items-center absolute blur-sm">
<img class="h-screen w-screen" src="/cover.jpg" alt="" />
<audio src="/is there a point (girl u know).mp3" autoplay loop bind:volume></audio>
<Slideshow />
<Playlist {title} />
</div>
<div class="h-full w-full flex justify-center items-center relative z-10">
<div class="w-[42rem] grid grid-cols-3 gap-2">
@ -25,7 +28,7 @@
<Disc3 />
</div>
<p class="font-bold my-auto">Listening to:</p>
<p class="my-auto">EVABOY - is there a point (girl u know)</p>
<p class="my-auto">{$title}</p>
</div>
</div>
<div class="bg-black/65 col-span-1 p-2 rounded-lg shadow-lg">

9
src/config.json Normal file
View file

@ -0,0 +1,9 @@
{
"imageDuration": 10,
"images": ["/img/1.jpg", "/img/2.jpg", "/img/3.jpg", "/img/4.jpg", "/img/5.jpg", "/img/6.jpg", "/img/7.jpg", "/img/8.jpg"],
"playlist": [
{ "title": "MF DOOM - Rapp Snitch Knishes", "location": "/audio/Rapp Snitch Knishes.mp3" },
{ "title": "Modjo - Lady (Hear Me Tonight)", "location": "/audio/Lady.mp3" },
{ "title": "EVABOY - is there a point (girl u know)", "location": "/audio/is there a point (girl u know).mp3" }
]
}

20
src/lib/Playlist.svelte Normal file
View file

@ -0,0 +1,20 @@
<script>
import { playlist } from "../config.json";
let index = Math.floor(Math.random() * playlist.length),
selected = playlist[index],
volume = 0.05;
export let title;
title.set(selected.title);
function ended() {
index++;
if (index >= playlist.length) index = 0;
selected = playlist[index];
title.set(selected.title);
}
</script>
<audio src={selected.location} bind:volume autoplay on:ended={ended}></audio>

25
src/lib/Slideshow.svelte Normal file
View file

@ -0,0 +1,25 @@
<script>
import { slide } from "svelte/transition";
import { images, imageDuration } from "../config.json";
let index = Math.floor(Math.random() * images.length),
selected = images[index];
setInterval(function changeImage() {
index++;
if (index >= images.length) index = 0;
selected = images[index];
}, 1000 * imageDuration);
</script>
<svelte:head>
{#each images as image}
<link rel="preload" as="image" href={image} />
{/each}
</svelte:head>
{#each images as image}
{#if selected === image}
<img in:slide={{ axis: "x" }} out:slide={{ axis: "x" }} class="max-h-screen" src={image} alt="" />
{/if}
{/each}

View file

@ -1,3 +1,6 @@
/**
* @param {string} steamid64
*/
export default async function (steamid64) {
const response = await fetch(`https://steamcommunity.com/profiles/${steamid64}/?xml=1`);
const xml = await response.text();

View file

@ -1,8 +1,8 @@
import './app.css'
import App from './App.svelte'
import "./app.css";
import App from "./App.svelte";
const app = new App({
target: document.getElementById('app'),
})
target: document.getElementById("app"),
});
export default app
export default app;