aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/tau/components
diff options
context:
space:
mode:
authorMiguel Ángel Moreno <mail@migalmoreno.com>2023-01-17 13:17:40 +0100
committerMiguel Ángel Moreno <mail@migalmoreno.com>2023-01-17 13:17:40 +0100
commit81f03c0b449bec1fa60cf2936bfc3f66a5ad58c1 (patch)
treea2a7aa01f61dd71b511dd3729a9f4b28c35b531f /src/frontend/tau/components
parent5e995881dd0c431ae63b1a50c2d03e59962241f1 (diff)
chore: Rename project
Diffstat (limited to 'src/frontend/tau/components')
-rw-r--r--src/frontend/tau/components/comments.cljs77
-rw-r--r--src/frontend/tau/components/items.cljs93
-rw-r--r--src/frontend/tau/components/loading.cljs8
-rw-r--r--src/frontend/tau/components/navigation.cljs12
-rw-r--r--src/frontend/tau/components/player.cljs70
5 files changed, 0 insertions, 260 deletions
diff --git a/src/frontend/tau/components/comments.cljs b/src/frontend/tau/components/comments.cljs
deleted file mode 100644
index bfbf822..0000000
--- a/src/frontend/tau/components/comments.cljs
+++ /dev/null
@@ -1,77 +0,0 @@
-(ns tau.components.comments
- (:require
- [re-frame.core :as rf]
- [reitit.frontend.easy :as rfe]
- [tau.components.loading :as loading]
- [tau.events :as events]
- [tau.util :as util]))
-
-(defn comment-item
- [{:keys [id text uploader-name uploader-avatar uploader-url stream-position
- upload-date uploader-verified? like-count hearted-by-uploader?
- pinned? replies reply-count key show-replies author-name author-avatar]}]
- [:div.flex.my-4 {:key key}
- (when uploader-avatar
- [:div.flex.items-center.py-3.box-border.h-12
- (when uploader-url
- [:div.w-12
- [:a {:href (rfe/href :tau.routes/channel nil {:url uploader-url}) :title uploader-name}
- [:img.rounded-full.object-cover.min-w-full.min-h-full {:src uploader-avatar}]]])])
- [:div.ml-4
- [:div.flex.items-center
- (when pinned?
- [:i.fa-solid.fa-thumbtack.mr-2.text-xs])
- (when uploader-name
- [:div.flex.items-center
- [:a {:href (rfe/href :tau.routes/channel nil {:url uploader-url}) :title uploader-name}
- [:h1.text-gray-300.font-bold uploader-name]]
- (when stream-position
- [:p.mx-1.text-xs (str "at " (util/format-duration stream-position))])])
- (when uploader-verified?
- [:i.fa-solid.fa-circle-check.ml-2])]
- [:div.my-2
- [:p text]]
- [:div..flex.items-center.my-2
- [:div.mr-4
- [:p (util/format-date upload-date)]]
- (when (and like-count (> like-count 0))
- [:div.flex.items-center.my-2
- [:i.fa-solid.fa-thumbs-up.text-xs]
- [:p.mx-1 like-count]])
- (when hearted-by-uploader?
- [:div.relative.w-4.h-4.mx-2
- [:i.fa-solid.fa-heart.absolute.-bottom-1.-right-1.text-xs.text-red-500]
- [:img.rounded-full.object-covermax-w-full.min-h-full
- {:src author-avatar :title (str author-name " hearted this comment")}]])]
- [:div.flex.items-center.cursor-pointer
- {:on-click #(rf/dispatch [::events/toggle-comment-replies id])}
- (when replies
- (if show-replies
- [:<>
- [:p.font-bold "Hide replies"]
- [:i.fa-solid.fa-turn-up.mx-2.text-xs]]
- [:<>
- [:p.font-bold (str reply-count (if (= reply-count 1) " reply" " replies"))]
- [:i.fa-solid.fa-turn-down.mx-2.text-xs]]))]]])
-
-(defn comments
- [{:keys [comments next-page disabled?]} author-name author-avatar url]
- (let [pagination-loading? @(rf/subscribe [:show-pagination-loading])
- service-color @(rf/subscribe [:service-color])]
- [:div.flex.flex-col
- [:div
- (for [[i {:keys [replies show-replies] :as comment}] (map-indexed vector comments)]
- [:div.flex.flex-col {:key i}
- [comment-item (assoc comment :key i :author-name author-name :author-avatar author-avatar)]
- (when (and replies show-replies)
- [:div {:style {:marginLeft "32px"}}
- (for [[i reply] (map-indexed vector (:items replies))]
- [comment-item (assoc reply :key i :author-name author-name :author-avatar author-avatar)])])])]
- (when (:url next-page)
- (if pagination-loading?
- (loading/loading-icon service-color)
- [:div.flex.items-center.justify-center
- {:style {:cursor "pointer"}
- :on-click #(rf/dispatch [::events/comments-pagination url (:url next-page)])}
- [:i.fa-solid.fa-plus]
- [:p.px-2 "Show more comments"]]))]))
diff --git a/src/frontend/tau/components/items.cljs b/src/frontend/tau/components/items.cljs
deleted file mode 100644
index dccd43f..0000000
--- a/src/frontend/tau/components/items.cljs
+++ /dev/null
@@ -1,93 +0,0 @@
-(ns tau.components.items
- (:require
- [re-frame.core :as rf]
- [reitit.frontend.easy :as rfe]
- [tau.components.loading :as loading]
- [tau.util :as util]))
-
-(defn thumbnail
- [thumbnail-url route url name duration]
- [:div.flex.py-2.box-border.h-44.xs:h-28
- [:div.relative.min-w-full
- [:a.absolute.min-w-full.min-h-full.z-10 {:href route :title name}]
- [:img.rounded.object-cover.min-h-full.max-h-full.min-w-full {:src thumbnail-url}]
- (when duration
- [:div.rounded.p-2.absolute {:style {:bottom 5 :right 5 :background "rgba(0,0,0,.7)" :zIndex "0"}}
- [:p {:style {:fontSize "14px"}}
- (if (= duration 0)
- "LIVE"
- (util/format-duration duration))]])]])
-
-(defn item-content
- [{:keys [url name thumbnail-url description subscriber-count
- stream-count verified? key uploader-name uploader-url
- uploader-avatar upload-date short-description view-count]} item-route]
- [:<>
- (when name
- [:div.my-2
- [:a {:href item-route :title name}
- [:h1.line-clamp-2.my-1 name]]])
- (when-not (empty? uploader-name)
- [:div.flex.items-center.my-2
- (if uploader-url
- [:a {:href (rfe/href :tau.routes/channel nil {:url uploader-url}) :title uploader-name}
- [:h1.line-clamp-1.text-gray-300.font-bold.pr-2 uploader-name]]
- [:h1.line-clamp-1.text-gray-300.font-bold.pr-2 uploader-name])
- (when verified?
- [:i.fa-solid.fa-circle-check])])
- (when subscriber-count
- [:div.flex.items-center
- [:i.fa-solid.fa-users.text-xs]
- [:p.mx-2 subscriber-count]])
- (when stream-count
- [:div.flex.items-center
- [:i.fa-solid.fa-video.text-xs]
- [:p.mx-2 stream-count]])
- [:div.flex.my-1.justify-between
- [:p (util/format-date upload-date)]
- (when view-count
- [:div.flex.items-center.h-full.pl-2
- [:i.fa-solid.fa-eye.text-xs]
- [:p.pl-1.5 (util/format-quantity view-count)]])]])
-
-(defn stream-item
- [{:keys [url name thumbnail-url duration] :as item}]
- [:<>
- [thumbnail thumbnail-url (rfe/href :tau.routes/stream nil {:url url}) url name duration]
- [item-content item (rfe/href :tau.routes/stream nil {:url url})]])
-
-(defn channel-item
- [{:keys [url name thumbnail-url] :as item}]
- [:<>
- [thumbnail thumbnail-url (rfe/href :tau.routes/channel nil {:url url}) url name nil]
- [item-content item (rfe/href :tau.routes/channel nil {:url url})]])
-
-(defn playlist-item
- [{:keys [url name thumbnail-url] :as item}]
- [:<>
- [thumbnail thumbnail-url (rfe/href :tau.routes/playlist nil {:url url}) url name nil]
- [item-content item (rfe/href :tau.routes/playlist nil {:url url})]])
-
-(defn generic-item
- [item]
- [:div.w-full.xs:w-56.h-80.xs:h-72.my-2 {:key key}
- [:div.px-5.py-2.m-2.flex.flex-col.max-w-full.min-h-full.max-h-full
- (case (:type item)
- "stream" [stream-item item]
- "channel" [channel-item item]
- "playlist" [playlist-item item])]])
-
-(defn related-streams
- [related-streams next-page-url]
- (let [service-color @(rf/subscribe [:service-color])
- pagination-loading? @(rf/subscribe [:show-pagination-loading])]
- [:div.flex.flex-col.justify-center.items-center.flex-auto.my-2.md:my-8
- (if (empty? related-streams)
- [:div.flex.items-center
- [:p "No available streams"]]
- [:div.flex.justify-center.flex-wrap
- (for [[i item] (map-indexed vector related-streams)
- :let [keyed-item (assoc item :key i)]]
- [generic-item keyed-item])])
- (when-not (empty? next-page-url)
- [loading/loading-icon service-color "text-2xl" (when-not pagination-loading? "invisible")])]))
diff --git a/src/frontend/tau/components/loading.cljs b/src/frontend/tau/components/loading.cljs
deleted file mode 100644
index 40f6db3..0000000
--- a/src/frontend/tau/components/loading.cljs
+++ /dev/null
@@ -1,8 +0,0 @@
-(ns tau.components.loading)
-
-(defn loading-icon
- [service-color & styles]
- [:div.w-full.flex.justify-center.items-center.flex-auto
- [:i.fas.fa-circle-notch.fa-spin
- {:class (apply str (if (> (count styles) 1) (interpose " " styles) styles))
- :style {:color service-color}}]])
diff --git a/src/frontend/tau/components/navigation.cljs b/src/frontend/tau/components/navigation.cljs
deleted file mode 100644
index 87e6dc5..0000000
--- a/src/frontend/tau/components/navigation.cljs
+++ /dev/null
@@ -1,12 +0,0 @@
-(ns tau.components.navigation
- (:require
- [re-frame.core :as rf]
- [tau.events :as events]))
-
-(defn back-button [service-color]
- [:div.flex.items-center
- [:button.py-4.px-2
- {:on-click #(rf/dispatch [::events/history-back])}
- [:i.fa-solid.fa-chevron-left
- {:style {:color service-color}}]
- [:span " Back"]]])
diff --git a/src/frontend/tau/components/player.cljs b/src/frontend/tau/components/player.cljs
deleted file mode 100644
index 11cc9c5..0000000
--- a/src/frontend/tau/components/player.cljs
+++ /dev/null
@@ -1,70 +0,0 @@
-(ns tau.components.player
- (:require
- [reagent.core :as r]
- [reagent.dom :as rdom]
- [re-frame.core :as rf]
- [reitit.frontend.easy :as rfe]
- [tau.events :as events]
- ["video.js" :as videojs]))
-
-(defn global-player
- []
- (let [!player (r/atom nil)
- !loop? (r/atom nil)]
- (fn []
- (let [{:keys [uploader-name uploader-url name stream url service-color]} @(rf/subscribe [:global-stream])
- show-global-player? @(rf/subscribe [:show-global-player])]
- (when show-global-player?
- [:div.sticky.bottom-0.z-50.bg-neutral-900.p-5.absolute.box-border.m-0
- {:style {:borderColor service-color :borderTopWidth "2px" :borderStyle "solid"}}
- [:div.flex.items-center.justify-between
- [:div.flex.flex-wrap.items-center
- [:div.flex.flex-col
- [:a.text-xs
- {:href (rfe/href :tau.router/stream nil {:url url})} name]
- [:a.text-xs.text-gray-300
- {:href (rfe/href :tau.router/channel nil {:url uploader-url})} uploader-name]]
- [:div.px-2.py-0.md:pt-4
- [:audio {:src stream :ref #(reset! !player %) :loop @!loop?}]]
- [:div.mx-2
- [:button.focus:ring-transparent.mx-2
- {:on-click (fn [] (swap! !loop? #(not %)))}
- [:i.fa-solid.fa-repeat
- {:style {:color (when @!loop? service-color)}}]]
- [:button.focus:ring-transparent.mx-2
- {:on-click #(when-let [player @!player]
- (if (.-paused player)
- (.play player)
- (.pause player)))}
- (if @!player
- (if (.-paused @!player)
- [:i.fa-solid.fa-play]
- [:i.fa-solid.fa-pause])
- [:i.fa-solid.fa-play])]]]
- [:div.px-2
- [:i.fa-solid.fa-close.cursor-pointer
- {:on-click (fn []
- (rf/dispatch [::events/toggle-global-player])
- (.pause @!player))}]]]])))))
-
-(defn stream-player
- [options url]
- (let [!player (atom nil)]
- (r/create-class
- {:display-name "StreamPlayer"
- :component-did-mount
- (fn [this]
- (reset! !player (videojs (rdom/dom-node this) (clj->js options))))
- :component-did-update
- (fn [this [_ prev-argv prev-more]]
- (when (and @!player (not= prev-more (first (r/children this))))
- (.src @!player (apply array (map #(js-obj "type" % "src" (first (r/children this)))
- ["video/mp4" "video/webm"])))
- (.ready @!player #(.play @!player))))
- :component-will-unmount
- (fn [_]
- (when @!player
- (.dispose @!player)))
- :reagent-render
- (fn [options url]
- [:video-js.vjs-default-skin.vjs-big-play-centered.bottom-0.object-cover.min-h-full.max-h-full.min-w-full])})))