From b697f2d356ac8efa2a9e29647244314224a48f24 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 14 Dec 2022 01:19:36 +0900 Subject: [PATCH] feat; Componentize tweet #118 --- src/lib/components/tweet.svelte | 238 +++++++++++++++++++++ src/lib/components/tweet_list.svelte | 74 +++++++ src/routes/home/+page.svelte | 301 +-------------------------- 3 files changed, 314 insertions(+), 299 deletions(-) create mode 100644 src/lib/components/tweet.svelte create mode 100644 src/lib/components/tweet_list.svelte diff --git a/src/lib/components/tweet.svelte b/src/lib/components/tweet.svelte new file mode 100644 index 0000000..125199d --- /dev/null +++ b/src/lib/components/tweet.svelte @@ -0,0 +1,238 @@ + + +
on_click_tweet(tweet)} on:keypress> + {#if tweet.is_retweet} +
+
+
+
+ {$_('name_retweeted', { + values: { name: tweet.retweet_user_name }, + })} +
+ {/if} +
+
+ + avatar + +
+
+
+
+ + +
·
+ +
+
+
+ +
+
+
+ {@html tweet.html_text} +
+
+ + {#if tweet.media_count === 1} +
+ 画像 +
+ {:else if tweet.media_count === 2} +
+
+
+ 画像 +
+
+ 画像 +
+
+
+ {:else if tweet.media_count === 3} +
+
+ 画像 +
+
+
+ 画像 +
+
+ 画像 +
+
+
+ {:else if tweet.media_count === 4} +
+
+
+ 画像 +
+
+ 画像 +
+
+
+
+ 画像 +
+
+ 画像 +
+
+
+ {/if} + +
+
+
+
+ +
+
{tweet.reply_count}
+
+
+
+
+ +
+
{tweet.retweet_count}
+
+
+
+
+ +
+
{tweet.like_count}
+
+
+
+
+ +
+
+
+
+
+
+ + diff --git a/src/lib/components/tweet_list.svelte b/src/lib/components/tweet_list.svelte new file mode 100644 index 0000000..c5ece5d --- /dev/null +++ b/src/lib/components/tweet_list.svelte @@ -0,0 +1,74 @@ + + +{#if is_loading} +
+ +
+{:else} +
+ {#each tweets_data as tweet_data} + + {/each} +
+{/if} diff --git a/src/routes/home/+page.svelte b/src/routes/home/+page.svelte index 0ad4e98..105c781 100644 --- a/src/routes/home/+page.svelte +++ b/src/routes/home/+page.svelte @@ -1,78 +1,12 @@ @@ -161,151 +87,7 @@
- {#if is_loading} -
- -
- {:else} -
- {#each tweets_data as tweet_data} - {@const tweet = new Tweet( - tweet_data, - user_data_map, - referenced_tweets_data_map, - media_data_map - )} -
on_click_tweet(tweet)} - on:keypress - > - {#if tweet.is_retweet} -
-
-
-
- {$_('name_retweeted', { - values: { name: tweet.retweet_user_name }, - })} -
- {/if} -
-
- - avatar - -
-
-
-
- - -
·
- -
-
-
- -
-
-
- {@html tweet.html_text} -
-
- - {#if tweet.media_count === 1} -
- 画像 -
- {:else if tweet.media_count === 2} -
-
-
- 画像 -
-
- 画像 -
-
-
- {:else if tweet.media_count === 3} -
-
- 画像 -
-
-
- 画像 -
-
- 画像 -
-
-
- {:else if tweet.media_count === 4} -
-
-
- 画像 -
-
- 画像 -
-
-
-
- 画像 -
-
- 画像 -
-
-
- {/if} - -
-
-
-
- -
-
{tweet.reply_count}
-
-
-
-
- -
-
{tweet.retweet_count}
-
-
-
-
- -
-
{tweet.like_count}
-
-
-
-
- -
-
-
-
-
-
- {/each} -
- {/if} +
@@ -338,83 +120,4 @@ .post_element { position: relative; } - - .tweet_container { - padding: 16px; - gap: 6px; - cursor: pointer; - } - - .tweet_container:hover { - transition: 0.2s; - background-color: rgb(245, 248, 250); - } - - .avatar_above { - min-width: 48px; - justify-content: flex-end; - } - - .tweet_element { - gap: 12px; - } - - .tweet_body { - gap: 12px; - min-width: 0; - flex: auto; - - font-size: 16px; - line-height: 20px; - font-weight: 400; - } - - .text_column { - gap: 8px; - min-width: 0; - overflow-wrap: break-word; - } - - .username_row { - gap: 4px; - - font-weight: 400; - font-size: 15px; - line-height: 20px; - } - - .time { - white-space: nowrap; - } - - .time a { - color: var(--gray-color); - } - - .action_row { - gap: 10px; - - color: var(--gray-color); - font-size: 13px; - line-height: 16px; - } - - .action { - gap: 10px; - flex: 1; - } - - .action_up_arrow { - flex: 0; - } - - .icon_text { - font-size: 14px; - } - - .action_icon { - width: 17.5px; - height: 17.5px; - fill: var(--gray-color); - }