Skip to content

Commit 001f039

Browse files
committed
Add external link button on story view
1 parent 37fa3c2 commit 001f039

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

src/main/lobjur/main.cljs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
(.add_child v)
2424
(.set_visible_child v))
2525
(-> s
26+
(assoc :header-start nil)
27+
(assoc :header-end nil)
2628
(assoc :prev-state s)
2729
(assoc :curr-view v))))
2830
(defn push-titled-view [s view title]
@@ -52,7 +54,13 @@
5254
(stories-list-view (partial lobster/domain-stories payload))
5355
payload)
5456
:push-story
55-
(push-titled-view state (comments/comments-view payload) "Comments")
57+
(-> state
58+
(push-titled-view (comments/comments-view payload) "Comments")
59+
(assoc :header-end
60+
[Gtk/LinkButton
61+
:uri (lobster/rel "s/" (:short_id payload))
62+
:icon-name "web-browser-symbolic"
63+
:css_classes #js ["image-button"]]))
5664
:push-tagged-stories
5765
(push-titled-view state
5866
(stories-list-view (partial lobster/tagged payload))
@@ -66,7 +74,9 @@
6674
(assoc :prev-state (get-in state [:prev-state :prev-state]))
6775
(assoc :curr-view (:curr-view (:prev-state state)))
6876
(assoc :title-widget (:title-widget (:prev-state state)))
69-
(assoc :header-start (if (get-in state [:prev-state :prev-state]) back-btn nil)))))
77+
(assoc :header-start (get-in state [:prev-state :header-start]))
78+
(assoc :header-end (get-in state [:prev-state :header-end])))))
79+
7080
(f action)))))
7181
(state/add-transducer app-transducer)
7282

src/main/lobjur/widgets/window.cljs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77

88
(declare header-bar)
99
(defc header-bar []
10-
(let [header-start (derived-atom [state/state] :header-start #(get % :header-start nil))]
11-
[Adw/HeaderBar
12-
:.pack_start [Adw/Bin :child header-start]
13-
:title_widget (derived-atom
14-
[state/state] :title-widget #(get % :title-widget nil))]))
10+
11+
[Adw/HeaderBar
12+
:.pack_start [Adw/Bin :child
13+
(derived-atom [state/state]
14+
:header-start #(get % :header-start nil))]
15+
:.pack_end [Adw/Bin :child
16+
(derived-atom [state/state]
17+
:header-end #(get % :header-end nil))]
18+
:title_widget (derived-atom
19+
[state/state] :title-widget #(get % :title-widget nil))])
1520

1621
(defn window-content []
1722
[Gtk/Box

0 commit comments

Comments
 (0)