|
9 | 9 | [portal.ui.icons :as icons]
|
10 | 10 | [portal.ui.inspector :as ins]
|
11 | 11 | [portal.ui.options :as opts]
|
| 12 | + [portal.ui.rpc :as rpc] |
12 | 13 | [portal.ui.select :as select]
|
13 | 14 | [portal.ui.state :as state]
|
14 | 15 | [portal.ui.styled :as s]
|
|
87 | 88 | [s/div {:style {:grid-row "1"}} "]"]]
|
88 | 89 | [s/div {:style {:flex "1"}}]]))
|
89 | 90 |
|
90 |
| -(defn- runtime-info [] |
| 91 | +(defn- use-runtime-info [] |
91 | 92 | (let [opts (opts/use-options)
|
92 | 93 | theme (theme/use-theme)
|
93 |
| - connected? (status/use-status) |
94 | 94 | header (if (= :dev (:mode opts))
|
95 | 95 | (::c/diff-add theme)
|
96 | 96 | (::c/background2 theme))]
|
|
106 | 106 | (str/join
|
107 | 107 | " - "
|
108 | 108 | [(:window-title opts name) platform version]))))
|
109 |
| - #js [opts]) |
110 |
| - (when-not connected? |
111 |
| - [s/div |
112 |
| - {:style {:color (::c/exception theme)}} |
113 |
| - "ERROR: Disconnected from runtime!"]))) |
| 109 | + #js [opts]))) |
114 | 110 |
|
115 | 111 | (defn inspect-footer []
|
116 | 112 | (let [theme (theme/use-theme)
|
117 | 113 | state (state/use-state)
|
| 114 | + connected? (status/use-status) |
118 | 115 | selected-context (state/get-all-selected-context @state)
|
119 | 116 | viewer (ins/get-viewer state (first selected-context))
|
120 | 117 | compatible-viewers (ins/get-compatible-viewers @ins/viewers selected-context)]
|
| 118 | + (use-runtime-info) |
121 | 119 | [s/div
|
122 | 120 | {:style
|
123 | 121 | {:display :flex
|
124 | 122 | :padding-top (:padding theme)
|
125 | 123 | :padding-bottom (:padding theme)
|
126 | 124 | :padding-right (* 1.5 (:padding theme))
|
127 | 125 | :padding-left (* 1.5 (:padding theme))
|
128 |
| - :align-items :stretch |
| 126 | + :align-items :center |
129 | 127 | :justify-content :space-between
|
130 |
| - :background (::c/background2 theme) |
| 128 | + :background (if-not connected? |
| 129 | + (::c/exception theme) |
| 130 | + (::c/background2 theme)) |
131 | 131 | :box-sizing :border-box
|
132 | 132 | :border-top [1 :solid (::c/border theme)]}}
|
133 |
| - [s/select |
134 |
| - {:title "Select a different viewer." |
135 |
| - :value (pr-str (:name viewer)) |
136 |
| - :on-change |
137 |
| - (fn [e] |
138 |
| - (ins/set-viewer! |
139 |
| - state |
140 |
| - selected-context |
141 |
| - (keyword (.substr (.. e -target -value) 1)))) |
142 |
| - :style |
143 |
| - {:background (::c/background theme) |
144 |
| - :padding (:padding theme) |
145 |
| - :box-sizing :border-box |
146 |
| - :font-family (:font-family theme) |
147 |
| - :font-size (:font-size theme) |
148 |
| - :color (::c/text theme) |
149 |
| - :border-radius (:border-radius theme) |
150 |
| - :border [1 :solid (::c/border theme)]}} |
151 |
| - (for [{:keys [name]} compatible-viewers] |
152 |
| - ^{:key name} |
153 |
| - [s/option {:value (pr-str name)} (pr-str name)])] |
154 |
| - [runtime-info] |
155 |
| - [s/button |
156 |
| - {:title "Open command palette." |
157 |
| - :on-click #(commands/open-command-palette state) |
158 |
| - :style |
159 |
| - {:font-family (:font-family theme) |
160 |
| - :background (::c/background theme) |
161 |
| - :border-radius (:border-radius theme) |
162 |
| - :border [1 :solid (::c/border theme)] |
163 |
| - :box-sizing :border-box |
164 |
| - :padding-top (:padding theme) |
165 |
| - :padding-bottom (:padding theme) |
166 |
| - :padding-left (* 2.5 (:padding theme)) |
167 |
| - :padding-right (* 2.5 (:padding theme)) |
168 |
| - :color (::c/tag theme) |
169 |
| - :font-size (:font-size theme) |
170 |
| - :font-weight :bold |
171 |
| - :cursor :pointer}} |
172 |
| - [icons/terminal]]])) |
| 133 | + [s/div |
| 134 | + {:style {:flex "1"}} |
| 135 | + [s/select |
| 136 | + {:title "Select a different viewer." |
| 137 | + :value (pr-str (:name viewer)) |
| 138 | + :on-change |
| 139 | + (fn [e] |
| 140 | + (ins/set-viewer! |
| 141 | + state |
| 142 | + selected-context |
| 143 | + (keyword (.substr (.. e -target -value) 1)))) |
| 144 | + :style |
| 145 | + {:background (::c/background theme) |
| 146 | + :padding (:padding theme) |
| 147 | + :box-sizing :border-box |
| 148 | + :font-family (:font-family theme) |
| 149 | + :font-size (:font-size theme) |
| 150 | + :color (::c/text theme) |
| 151 | + :border-radius (:border-radius theme) |
| 152 | + :border [1 :solid (::c/border theme)]}} |
| 153 | + (for [{:keys [name]} compatible-viewers] |
| 154 | + ^{:key name} |
| 155 | + [s/option {:value (pr-str name)} (pr-str name)])]] |
| 156 | + |
| 157 | + (when-not connected? |
| 158 | + [s/div |
| 159 | + {:style {:text-align :center :flex "1" :color (::c/text theme)}} |
| 160 | + [s/div |
| 161 | + #_{:style {:display :flex :gap (:padding theme)}} |
| 162 | + [s/span {:style {:font-weight :bold}} "Error: "] |
| 163 | + "Connection lost"] |
| 164 | + [s/div |
| 165 | + "(portal.api/start " |
| 166 | + (pr-str (select-keys (rpc/resolve-connection) [:port])) |
| 167 | + ")"]]) |
| 168 | + |
| 169 | + [s/div |
| 170 | + {:style {:flex "1" :text-align :right}} |
| 171 | + [s/button |
| 172 | + {:title "Open command palette." |
| 173 | + :on-click #(commands/open-command-palette state) |
| 174 | + :style |
| 175 | + {:font-family (:font-family theme) |
| 176 | + :background (::c/background theme) |
| 177 | + :border-radius (:border-radius theme) |
| 178 | + :border [1 :solid (::c/border theme)] |
| 179 | + :box-sizing :border-box |
| 180 | + :padding-top (:padding theme) |
| 181 | + :padding-bottom (:padding theme) |
| 182 | + :padding-left (* 3 (:padding theme)) |
| 183 | + :padding-right (* 3 (:padding theme)) |
| 184 | + :color (::c/tag theme) |
| 185 | + :font-size (:font-size theme) |
| 186 | + :font-weight :bold |
| 187 | + :cursor :pointer}} |
| 188 | + [icons/terminal]]]])) |
173 | 189 |
|
174 | 190 | (defn- search-input []
|
175 | 191 | (let [ref (react/useRef nil)
|
|
0 commit comments