2017-07-02 62 views
0

在JavaScript中,處理動態類的常用方法是使用classnames庫。在Reagent或Re-Frame應用程序中處理動態類的慣用方式

我無法找到任何ClojureScript替代解決方案,似乎大多數人都很好用直列如果與(str ...)喜歡的語句:

(str "location flex-column border-box" (if is-current " current")) 

這對我來說似乎是脆弱的,乏味的(見空格處理) 。

我期望此功能類似工作:

(class-names { 
    :location true 
    :flex-column true 
    :border-box true 
    :current is-current 
}) 
; -> "location flex-column border-box" 
; or "location flex-column border-box current" 

或者像

(class-names "location" "flex-column" "border-box" { 
    :current is-current 
}) 

當然,手工編寫這樣的功能應該不難,但我認爲這應該已經解決不知何故已經。

+0

到目前爲止,我有這個https://gist.github.com/YurySolovyov/834e9cd6258f36d6f333fd3d0806c238 –

+0

而這一次的https:/ /github.com/YurySolovyov/class-names-cljs –

回答

相關問題