mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
Add fill menu for text shape.
This commit is contained in:
parent
a0fbb1ac7c
commit
8e5d193518
3 changed files with 22 additions and 4 deletions
|
@ -13,6 +13,7 @@
|
||||||
[uxbox.ui.keyboard :as kbd]
|
[uxbox.ui.keyboard :as kbd]
|
||||||
[uxbox.ui.shapes.core :as uusc]
|
[uxbox.ui.shapes.core :as uusc]
|
||||||
[uxbox.ui.shapes.icon :as uusi]
|
[uxbox.ui.shapes.icon :as uusi]
|
||||||
|
[uxbox.util.color :as color]
|
||||||
[uxbox.util.dom :as dom])
|
[uxbox.util.dom :as dom])
|
||||||
(:import goog.events.EventType))
|
(:import goog.events.EventType))
|
||||||
|
|
||||||
|
@ -134,14 +135,18 @@
|
||||||
[:font-size])
|
[:font-size])
|
||||||
|
|
||||||
(defn- build-style
|
(defn- build-style
|
||||||
[{:keys [font]}]
|
[{:keys [font fill opacity] :or {fill "#000000" opacity 1}}]
|
||||||
(let [{:keys [family weight style size align]
|
(let [{:keys [family weight style size align]
|
||||||
:or {family "sourcesanspro"
|
:or {family "sourcesanspro"
|
||||||
weight "normal"
|
weight "normal"
|
||||||
style "normal"
|
style "normal"
|
||||||
align "left"
|
align "left"
|
||||||
size 16}} font]
|
size 16}} font
|
||||||
|
color (-> fill
|
||||||
|
(color/hex->rgba opacity)
|
||||||
|
(color/rgb->str))]
|
||||||
{:fontSize (str size "px")
|
{:fontSize (str size "px")
|
||||||
|
:color color
|
||||||
:textAlign align
|
:textAlign align
|
||||||
:fontFamily family
|
:fontFamily family
|
||||||
:fontWeight weight
|
:fontWeight weight
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
:builtin/rect [:menu/rect-measures :menu/fill :menu/stroke]
|
:builtin/rect [:menu/rect-measures :menu/fill :menu/stroke]
|
||||||
:builtin/line [:menu/line-measures :menu/stroke]
|
:builtin/line [:menu/line-measures :menu/stroke]
|
||||||
:builtin/circle [:menu/circle-measures :menu/fill :menu/stroke]
|
:builtin/circle [:menu/circle-measures :menu/fill :menu/stroke]
|
||||||
:builtin/text [:menu/text]
|
:builtin/text [:menu/fill :menu/text]
|
||||||
:builtin/group []})
|
:builtin/group []})
|
||||||
|
|
||||||
(def ^:const ^:private +menus-by-id+
|
(def ^:const ^:private +menus-by-id+
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
||||||
|
|
||||||
(ns uxbox.util.color
|
(ns uxbox.util.color
|
||||||
"Color conversion utils.")
|
"Color conversion utils."
|
||||||
|
(:require [cuerdas.core :as str]))
|
||||||
|
|
||||||
(defn hex->rgb
|
(defn hex->rgb
|
||||||
[^string data]
|
[^string data]
|
||||||
|
@ -14,6 +15,18 @@
|
||||||
(rest)
|
(rest)
|
||||||
(mapv #(js/parseInt % 16))))
|
(mapv #(js/parseInt % 16))))
|
||||||
|
|
||||||
|
(defn hex->rgba
|
||||||
|
[^string data ^number opacity]
|
||||||
|
(-> (hex->rgb data)
|
||||||
|
(conj opacity)))
|
||||||
|
|
||||||
|
(defn rgb->str
|
||||||
|
[color]
|
||||||
|
{:pre [(vector? color)]}
|
||||||
|
(if (= (count color) 3)
|
||||||
|
(apply str/format "rgb(%s,%s,%s)" color)
|
||||||
|
(apply str/format "rgba(%s,%s,%s,%s)" color)))
|
||||||
|
|
||||||
(defn rgb->hex
|
(defn rgb->hex
|
||||||
[[r g b]]
|
[[r g b]]
|
||||||
(letfn [(to-hex [c]
|
(letfn [(to-hex [c]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue