Skip to content

Commit

Permalink
refactor: extract special unicode characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Macroz committed Nov 4, 2024
1 parent 2c386a4 commit 6c5a820
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/cljs/rems/administration/create_license.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[re-frame.core :as rf]
[rems.administration.administration :as administration]
[rems.administration.components :refer [localized-text-field localized-textarea-autosize organization-field radio-button-group]]
[rems.atoms :as atoms :refer [failure-symbol file-download document-title]]
[rems.atoms :as atoms :refer [document-title failure-symbol file-download nbsp]]
[rems.collapsible :as collapsible]
[rems.common.attachment-util :as attachment-util]
[rems.config]
Expand Down Expand Up @@ -187,7 +187,7 @@
[:a.attachment-link.btn.btn-secondary.mr-2
{:href (str "/api/licenses/attachments/" attachment-id)
:target :_blank}
[file-download] "\u00A0" filename]
[file-download] nbsp filename]
[:button.btn.btn-secondary.mr-2 {:type :button
:on-click (remove-attachment-event language attachment-id)}
(text :t.form/attachment-remove)]])
Expand Down
6 changes: 3 additions & 3 deletions src/cljs/rems/application.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
[rems.administration.duo :refer [duo-field duo-info-field]]
[rems.common.application-util :refer [accepted-licenses? can-see-everything? form-fields-editable? get-member-name is-handler? is-handling-user?]]
[rems.common.attachment-util :as attachment-util]
[rems.atoms :as atoms :refer [external-link file-download info-field readonly-checkbox document-title success-symbol make-empty-symbol]]
[rems.atoms :as atoms :refer [document-title external-link file-download info-field make-empty-symbol nbsp readonly-checkbox success-symbol]]
[rems.common.catalogue-util :refer [catalogue-item-more-info-url]]
[rems.collapsible :as collapsible]
[rems.common.form :as form]
Expand Down Expand Up @@ -483,7 +483,7 @@
[:a.btn.btn-secondary
{:href (str "/api/applications/" (:application/id application) "/attachments?all=false")
:target :_blank}
[file-download] "\u00A0" (text :t.form/attachments-as-zip)]))
[file-download] nbsp (text :t.form/attachments-as-zip)]))

(defn- link-license [license]
(let [title (localized (:license/title license))
Expand All @@ -507,7 +507,7 @@
"/license-attachment/" (:license/id license)
"/" (name @rems.config/current-language))]
[:a.license-title {:href link :target :_blank}
[file-download] "\u00A0" title]))
[file-download] nbsp title]))

(defn license-field [application license show-accepted-licenses?]
[:div.license.flex-row.d-flex
Expand Down
4 changes: 4 additions & 0 deletions src/cljs/rems/atoms.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
[rems.text :refer [text text-format localized localize-attachment]]
[rems.util :refer [class-names]]))

(def nbsp "\u00A0") ; non breaking space
(def nbhy "\u2011") ; non breaking hyphen
(def hamburger "\u2630") ; the hamburger menu icon

(defn external-link []
[:i {:class "fa fa-external-link-alt"}
[:span.sr-only (text :t.link/opens-in-new-window)]])
Expand Down
2 changes: 1 addition & 1 deletion src/cljs/rems/navbar.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
[:div.navbar.navbar-expand-sm.flex-fill
[:button.navbar-toggler
{:type :button :data-toggle "collapse" :data-target "#small-navbar"}
"\u2630"]
atoms/hamburger]
(when (rems.theme/use-navbar-logo?)
[:div.navbar-brand.logo-menu
[:div.img]])
Expand Down
5 changes: 3 additions & 2 deletions src/cljs/rems/phase.cljs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns rems.phase
(:require [rems.guide-util :refer [component-info example]]
(:require [rems.atoms :refer [nbsp]]
[rems.guide-util :refer [component-info example]]
[rems.text :refer [text]]))

(defn phases
Expand Down Expand Up @@ -33,7 +34,7 @@
[:span.sr-only (text :t.phases/phase-closed)]]
:else [:i.fa.fa-chevron-right {:style {:color "rgba(0,0,0,0)"}}
[:span.sr-only (text :t.phases/phase-pending)]])
"\u00a0"
nbsp
(if (:text phase)
(text (:text phase))
(:phase phase))]])))
Expand Down
5 changes: 3 additions & 2 deletions test/clj/rems/application/test_model.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[rems.api.schema :as schema]
[rems.application.events :as events]
[rems.application.model :as model]
[rems.atoms :refer [nbsp nbhy]]
[rems.common.application-util :as application-util]
[rems.common.util :refer [deep-merge]]
[rems.permissions :as permissions]
Expand Down Expand Up @@ -364,8 +365,8 @@
nowrap (fn [s]
;; GitHub will strip all CSS from markdown, so we cannot use CSS for nowrap
(-> s
(str/replace " " "\u00A0") ; non-breaking space
(str/replace "-" "\u2011")))] ; non-breaking hyphen
(str/replace " " nbsp) ; non-breaking space
(str/replace "-" nbhy)))] ; non-breaking hyphen
(hiccup/html
[:table {:border 1}
[:tr
Expand Down

0 comments on commit 6c5a820

Please sign in to comment.