0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 10:38:13 -05:00

Add fill menu for text shape.

This commit is contained in:
Andrey Antukh 2016-03-02 18:47:27 +02:00
parent a0fbb1ac7c
commit 8e5d193518
3 changed files with 22 additions and 4 deletions

View file

@ -13,6 +13,7 @@
[uxbox.ui.keyboard :as kbd]
[uxbox.ui.shapes.core :as uusc]
[uxbox.ui.shapes.icon :as uusi]
[uxbox.util.color :as color]
[uxbox.util.dom :as dom])
(:import goog.events.EventType))
@ -134,14 +135,18 @@
[:font-size])
(defn- build-style
[{:keys [font]}]
[{:keys [font fill opacity] :or {fill "#000000" opacity 1}}]
(let [{:keys [family weight style size align]
:or {family "sourcesanspro"
weight "normal"
style "normal"
align "left"
size 16}} font]
size 16}} font
color (-> fill
(color/hex->rgba opacity)
(color/rgb->str))]
{:fontSize (str size "px")
:color color
:textAlign align
:fontFamily family
:fontWeight weight

View file

@ -36,7 +36,7 @@
:builtin/rect [:menu/rect-measures :menu/fill :menu/stroke]
:builtin/line [:menu/line-measures :menu/stroke]
:builtin/circle [:menu/circle-measures :menu/fill :menu/stroke]
:builtin/text [:menu/text]
:builtin/text [:menu/fill :menu/text]
:builtin/group []})
(def ^:const ^:private +menus-by-id+

View file

@ -6,7 +6,8 @@
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
(ns uxbox.util.color
"Color conversion utils.")
"Color conversion utils."
(:require [cuerdas.core :as str]))
(defn hex->rgb
[^string data]
@ -14,6 +15,18 @@
(rest)
(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
[[r g b]]
(letfn [(to-hex [c]