Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix page overflow due to roll tooltips in character page #420

Merged
merged 6 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/clj/orcpub/styles/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@
[:.tooltip [:.tooltiptext
{:visibility "hidden"
:width "130px"
:bottom "100%"
:bottom "calc(100% - -5px)"
:left "50%"
:margin-left "-60px"
:background-color "black"
Expand Down
26 changes: 17 additions & 9 deletions src/cljs/orcpub/character_builder.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,13 @@

(def toggle-homebrew (memoize toggle-homebrew-fn))

(defn tooltip [text content]
(if @(subscribe [:mobile?])
content
[:div.tooltip
content
[:span.tooltiptext text]]))

(defn selection-section-base []
(let [expanded? (r/atom false)]
(fn [{:keys [title path parent-title name icon help max min remaining body hide-lock? hide-homebrew?]}]
Expand All @@ -603,21 +610,22 @@
(if (and path help)
[show-info-button expanded?])
(if (not hide-lock?)
[:div.tooltip
[tooltip
(if locked?
"Locked to prevent changes - click to unlock"
"Unlocked - click to lock the section to prevent changes")
[:i.fa.f-s-16.m-l-10.m-r-5.pointer
{:class-name (if locked? "fa-lock" "fa-unlock-alt opacity-5 hover-opacity-full")
:on-click (toggle-locked path)}]
(if locked? [:span.tooltiptext "Locked to prevent changes - click to unlock"]
[:span.tooltiptext "Unlocked - click to lock the section to prevent changes"])
])
:on-click (toggle-locked path)}]])
(if (not hide-homebrew?)
[:span.pointer
{:class-name (if (not homebrew?) "opacity-5 hover-opacity-full")
:on-click (toggle-homebrew path)}
[:div.tooltip
(views5e/svg-icon "beer-stein" 18)
(if (not homebrew?) [:span.tooltiptext "Homebrew is off for " title " - enabling this option allows you select options you would not normally have (turns on homebrew rules)"]
[:span.tooltiptext "Homebrew is on for " title " - you can select anything and make it homebrew"] )]])]
[tooltip
(if (not homebrew?)
(str "Homebrew is off for " title " - enabling this option allows you select options you would not normally have (turns on homebrew rules)")
(str "Homebrew is on for " title " - you can select anything and make it homebrew"))
(views5e/svg-icon "beer-stein" 18)]])]
(if (and help path @expanded?)
[help-section help])
(if (int? min)
Expand Down
32 changes: 16 additions & 16 deletions src/cljs/orcpub/dnd/e5/views.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1771,6 +1771,17 @@

(def button-roll-handler (memoize button-roll-fn))

(defn roll-button [message roll & {:keys [text disable-tooltip]}]
(let [mobile? @(subscribe [:mobile?])
button [:button.roll-button
{:on-click (button-roll-handler message roll)}
(if text text "Roll")]]
(if (or mobile? disable-tooltip)
button
[:div.tooltip
button
[:span.tooltiptext "ctrl+click for advantage shift+click for disadvantage"]])))

(defn cast-spell-component []
(let [selected-level (r/atom nil)]
(fn [id lvl]
Expand Down Expand Up @@ -2177,9 +2188,7 @@
{:class (csk/->kebab-case title)}
v]]
(if (boolean show-button)
[:div.f-s-24.f-w-b [:div.tooltip [:button.roll-button
{:on-click (button-roll-handler (str title " check: ") (str "1d20" v))}
"Roll"] [:span.tooltiptext "ctrl+click for advantage shift+click for disadvantage"]]])])
[:div.f-s-24.f-w-b (roll-button (str title " check: ") (str "1d20" v))])])

(def current-hit-points-editor-style
{:width "60px"
Expand Down Expand Up @@ -2257,9 +2266,7 @@
(svg-icon icon 18)
[:span.m-l-5 skill-name]]]
[:td [:div.p-5.skillbonus (common/bonus-str (skill-bonuses skill-key))]]
[:td [:div.tooltip [:button.roll-button
{:on-click (button-roll-handler (str skill-name " check: ") (str "1d20" (common/mod-str (skill-bonuses skill-key))))}
"Roll"][:span.tooltiptext "ctrl+click for advantage shift+click for disadvantage"]]]])
[:td (roll-button (str skill-name " check: ") (str "1d20" (common/mod-str (skill-bonuses skill-key))))]])
skills/skills))]]]]))

(defn ability-scores-section-2 [id]
Expand Down Expand Up @@ -2300,9 +2307,7 @@
(t/ability-icon k 18 theme)
[:span.m-l-5.saving-throw-name (s/upper-case (name k))]]]
[:td [:div.p-5.saving-throw-bonus (common/bonus-str (save-bonuses k))]]
[:td [:div.tooltip [:button.roll-button
{:on-click (button-roll-handler (str (s/upper-case (name k)) " check: ") (str "1d20" (common/mod-str (save-bonuses k))))}
"Roll"][:span.tooltiptext "ctrl+click for advantage shift+click for disadvantage"]]]])
[:td (roll-button (str (s/upper-case (name k)) " check: ") (str "1d20" (common/mod-str (save-bonuses k))))]])
char/ability-keys))]]]))

(defn feet-str [num]
Expand Down Expand Up @@ -2918,10 +2923,7 @@
(if skill-expertise
[:td.p-10 (boolean-icon expertise?)])
[:td.p-10.f-s-18.f-w-b (common/bonus-str (key skill-bonuses))]
[:td [:div.tooltip [:button.roll-button
{:on-click (button-roll-handler (str name " check: ") (str "1d20" (common/mod-str (key skill-bonuses))))}
"Roll"][:span.tooltiptext "ctrl+click for advantage shift+click for disadvantage"]]]
]))
[:td (roll-button (str name " check: ") (str "1d20" (common/mod-str (key skill-bonuses))))]]))
skills/skills))]]]]))))

(defn tool-prof-details-section-2 []
Expand Down Expand Up @@ -2960,9 +2962,7 @@
(if tool-expertise
[:td.p-10 (boolean-icon expertise?)])
[:td.p-10.f-s-18.f-w-b (common/bonus-str (tool-bonus-fn kw))]
[:td [:div.tooltip [:button.roll-button
{:on-click (button-roll-handler (str name " check: ") (str "1d20" (common/mod-str (tool-bonus-fn kw))))}
"Roll"] [:span.tooltiptext "ctrl+click for advantage shift+click for disadvantage"]]]]))
[:td (roll-button (str name " check: ") (str "1d20" (common/mod-str (tool-bonus-fn kw))))]]))
tool-profs))]]]])))))


Expand Down