Skip to content

Commit

Permalink
add Bug Report link, fix command bar
Browse files Browse the repository at this point in the history
  • Loading branch information
mhuebert committed Aug 14, 2023
1 parent 7864f01 commit 6bdffc8
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 25 deletions.
7 changes: 6 additions & 1 deletion editor2/src/main/maria/cloud/menubar.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

(def trigger-classes (v/classes ["px-1 h-7 bg-transparent rounded"
"hover:bg-zinc-200"
"text-zinc-500 visited:text-zinc-500 hover:text-zinc-700 "
"data-[highlighted]:bg-zinc-200"
"data-[delayed-open]:bg-zinc-200"
"data-[state*=open]:bg-zinc-200"]))
Expand Down Expand Up @@ -187,7 +188,11 @@
menubar-content
[:div.flex-grow]
#_[:a.text-black.inline-flex.items-center {:class trigger-classes
:href "/"} [icons/home "w-4 h-4"]]
:href "/"} [icons/home "w-4 h-4"]]
[:a.cursor-pointer.p-1.no-underline
{:href "https://github.com/mhuebert/maria/issues"
:target "_blank"
:class trigger-classes} "Bug Report"]
(let [cmd (keymaps/resolve-command :file/new)]
[:div.cursor-pointer.p-1
{:class [trigger-classes
Expand Down
5 changes: 3 additions & 2 deletions editor2/src/main/maria/cloud/persistence.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
(keymaps/register-commands!
{:file/new {:bindings [:Shift-Mod-b]
:f (fn [_] (new-blank-file!))}
:file/duplicate {:when (every-pred :ProseView :file/id)
:file/duplicate {:when (every-pred :file/id :ProseView)
;; create a new gist with contents of current doc.
:f (fn [{:keys [ProseView file/id]}]
(let [source (state-source (j/get ProseView :state))]
Expand All @@ -197,7 +197,8 @@
(commands/prose:replace-doc ProseView source)))}
:file/save {:bindings [:Ctrl-s]
:when (fn [{:keys [file/id]}]
(and (gh/get-token)
(and id
(gh/get-token)
(writable? id)))
;; if local, create a new gist and then navigate there.
;; if gist, save a new revision of that gist.
Expand Down
4 changes: 2 additions & 2 deletions editor2/src/main/maria/editor/command_bar.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
(reset! !search "")
(keymaps/hide-command-bar! {:command-bar/element @!input}))
:onValueChange #(reset! !search %)
:ref #(do (keymaps/add-context :command-bar/element %)
(reset! !input %))}]]
:ref #(do (reset! !input %)
(keymaps/add-context :command-bar/element %))}]]
[:div.absolute.h7.flex.items-center.right-2.top-0.bottom-0.placeholder
{:class (when (and @!open (not (str/blank? @!search))) "opacity-0")}
(-> (:editor/toggle-command-bar keymaps/commands:global)
Expand Down
15 changes: 8 additions & 7 deletions editor2/src/main/maria/editor/keymaps.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,12 @@
false)}
:editor/toggle-command-bar {:bindings [:Mod-k]
:kind :global
:hidden? true
:prepare (fn [cmd ctx]
(merge cmd (if (command-bar-open? ctx)
{:title "Hide command bar"
:f hide-command-bar!}
{:title "Show command bar"
:f show-command-bar!})))}
(assoc cmd :f
(if (command-bar-open? ctx)
hide-command-bar!
show-command-bar!)))}
:prose/toggle-prose-visibility {:kind :global
:when :ProseView
:prepare (fn [cmd {:keys [ProseView]}]
Expand Down Expand Up @@ -478,8 +478,9 @@
(let [cmd (if (keyword? cmd)
(@!command-registry cmd)
cmd)
cmd (assoc cmd :active? (active? context cmd))
cmd (if-let [prepare (:prepare cmd)]
is-active (active? context cmd)
cmd (assoc cmd :active? is-active)
cmd (if-let [prepare (and is-active (:prepare cmd))]
(prepare cmd context)
cmd)]
(assoc cmd :context context))))
Expand Down
20 changes: 10 additions & 10 deletions editor2/src/main/maria/editor/util.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,16 @@
second))

(defn truncate-segmented [s n ellipsis]
(let [segments (str/split s #"\s+")
segments-truncated (reduce (fn [out segment]
(if (>= (count out) n)
(reduced out)
(str out " " segment)))
(first segments)
(rest segments))]
(if (< (count segments-truncated) (count s))
(str segments-truncated ellipsis)
segments-truncated)))
(let [segments (str/split s #"[\s\n]+")
[truncated? s] (reduce (fn [[_ out] segment]
(if (>= (count out) n)
(reduced [true out])
[false (str out " " segment)]))
[false (first segments)]
(rest segments))]
(if truncated?
(str s ellipsis)
s)))

(defn slug [title]
(-> title
Expand Down
9 changes: 6 additions & 3 deletions editor2/src/maria.cloud.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@
.prose code::before, .prose code::after {
content: none;
}
a {
@apply underline text-blue-600 hover:text-blue-800 visited:text-purple-700
}
}
@layer components {

}
@layer utilities {

::placeholder, .placeholder {
Expand Down Expand Up @@ -199,9 +204,7 @@ h5 {
align-self: end;
}

a {
@apply underline text-blue-600 hover:text-blue-800 visited:text-purple-700
}


/* Radix UI */

Expand Down

0 comments on commit 6bdffc8

Please sign in to comment.