Back
slice (clj)
(source)function
(slice s begin)
(slice s begin end)
Extracts a section of a string and returns a new string.
Examples
penpot/penpot
(ns app.main.ui.workspace.viewport.presence
(:require
[app.main.refs :as refs]
[app.util.time :as dt]
[app.util.timers :as ts]
[beicon.v2.core :as rx]
[cuerdas.core :as str]
[rumext.v2 :as mf]))
(mf/defc session-cursor
[{:keys [session profile] :as props}]
(let [zoom (mf/deref refs/selected-zoom)
point (:point session)
background-color (:color session "var(--black)")
text-color (:text-color session "var(--white)")
transform (str/fmt "translate(%s, %s) scale(%s)" (:x point) (:y point) (/ 1 zoom))
shown-name (if (> (count (:fullname profile)) 16)
(str (str/slice (:fullname profile) 0 12) "...")
(:fullname profile))]
[:g.multiuser-cursor {:transform transform}
[:path {:fill background-color
:d pointer-icon-path}]
[:g {:transform "translate(17 -10)"}
[:foreignObject {:x -0.3
:y -12.5
:width 300
:height 120}
[:div.profile-name {:style {:background-color background-color
:color text-color}}
shown-name]]]]))