status-im / status-fiddle

Online UI editor for status-react
10 stars 9 forks source link

Implement css to clojure map converter #19

Closed flexsurfer closed 6 years ago

flexsurfer commented 6 years ago

it should be possible to paste css and get clojure map

{
    width: 117px;
    height: 20px;
    font-family: SFUIText;
    font-size: 16px;
    line-height: 1.25;
    letter-spacing: -0.2px;
    text-align: left;
    color: #4360df;
}

to

{
:width 117
:height 20
:font-family "SFUIText"
:font-size 16
:line-height 1.25
:letter-spacing -0.2
:text-align :left
:color "#4360df"
}
benjicluff commented 6 years ago

FYI, I wrote this on a whim. Not sure if anyone else is working on it, so I wanted to mention it. I apologize I have zero context and am just getting familiar with your organization. I'll need a day or so to read through your lovely docs and go through the proper channels. Bear with me.

Description: It's a ~150 line lexer/parser. It's limited but is extensible. The only dependency is clojure.string. There are comments and usage examples in the gist.

Usage: (css->clj "{width: 1px; text-align: left;}") => {:width 1, :text-align :left}

Here is the gist. css_clj.clj

flexsurfer commented 6 years ago

thanks @benjicluff , no rush, please ask any questions, we will add SNT tomorrow to this contract

flexsurfer commented 6 years ago

hey @benjicluff i added your code here https://github.com/status-im/status-fiddle/commit/f9605258846d6f08190d1a04a395f243ef652489#diff-a8271ba9be94a5dbf825540f38c0aed9R9, feel free to modify it