-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
7 changed files
with
112 additions
and
8 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,6 +1,13 @@ | ||
<script lang="ts"> | ||
import Footer from './views/Footer.svelte'; | ||
import RealTimeSindo from './views/RealTimeSindo/index.svelte' | ||
</script> | ||
<div> | ||
<RealTimeSindo /> | ||
<div class="flex flex-col h-dvh"> | ||
<div class="grow"> | ||
content content | ||
</div> | ||
<hr /> | ||
<div> | ||
<Footer /> | ||
</div> | ||
</div> |
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 +1,9 @@ | ||
@import url('@unocss/reset/tailwind.css'); | ||
|
||
.hide-scrollbar::-webkit-scrollbar { | ||
display: none; | ||
} | ||
.hide-scrollbar { | ||
-ms-overflow-style: none; | ||
scrollbar-width: none; | ||
} |
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,6 @@ | ||
export const getServerTime = async (): Promise<Date> => { | ||
const json = await fetch(`${import.meta.env.VITE_EQUAKE_API_URL}/time`).then( | ||
(r) => r.json(), | ||
) | ||
return new Date(Date.parse(json.string)) | ||
} |
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,36 @@ | ||
<script lang="ts"> | ||
import { onDestroy, onMount } from 'svelte'; | ||
import { getServerTime } from '../utils/client/time'; | ||
import News from './News.svelte' | ||
// hh:mm:ss | ||
const formatter = new Intl.DateTimeFormat('ja-JP', { | ||
hour: '2-digit', | ||
minute: '2-digit', | ||
second: '2-digit', | ||
}) | ||
let isDestroyed = false | ||
let time: Date | ||
onMount(() => { | ||
const update = async () => { | ||
time = await getServerTime() | ||
if (isDestroyed) { | ||
return | ||
} | ||
setTimeout(update, 100) | ||
} | ||
update() | ||
}) | ||
onDestroy(() => { | ||
isDestroyed = true | ||
}) | ||
$: formattedTime = formatter.format(time) | ||
</script> | ||
<div class="flex items-center"> | ||
<News /> | ||
<div class="border-l-2 p-2 m-2 text-4xl font-mono"> | ||
{formattedTime} | ||
</div> | ||
</div> |
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,3 @@ | ||
<script lang="ts"> | ||
</script> |
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,40 @@ | ||
<script lang="ts"> | ||
import { onDestroy, onMount } from 'svelte' | ||
// 下に流れてるニュース | ||
const content = 'この放送は、eQuake Live が提供しています。この文字列はテスト用であり、本来はニュースを放送します。この放送は、eQuake Live が提供しています。この文字列はテスト用であり、本来はニュースを放送します。' | ||
let divRef: HTMLDivElement | ||
let isDestroyed = false | ||
onMount(() => { | ||
let lastScrollLeft = 0 | ||
const update = async () => { | ||
divRef.scrollLeft += 1 | ||
if (divRef.scrollLeft === lastScrollLeft) { | ||
divRef.scrollTo({ | ||
left: 0, | ||
behavior: 'smooth', | ||
}) | ||
setTimeout(() => { | ||
update() | ||
}, 1000) | ||
return | ||
} | ||
lastScrollLeft = divRef.scrollLeft | ||
if (isDestroyed) { | ||
return | ||
} | ||
requestAnimationFrame(update) | ||
} | ||
update() | ||
}) | ||
onDestroy(() => { | ||
isDestroyed = true | ||
}) | ||
</script> | ||
<div bind:this={divRef} class="px-2 no-wrap text-xl w-full overflow-scroll hide-scrollbar whitespace-nowrap"> | ||
{content} | ||
</div> |
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