Skip to content

Commit

Permalink
feat(hiccup-css): add/fix class handling, update Format
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Mar 3, 2018
1 parent 3a4cf1e commit 5247b8f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions packages/hiccup-css/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ css(["#foo",

```css
#foo h1 small {
color:#999;
color: #999;
}
#foo h1 {
font-size:2em;
font-size: 2em;
}
#foo h2 .title, #foo h3 .title {
font-weight:700;
#foo h2.title, #foo h3.title {
font-weight: 700;
}
#foo {
background:#eee;
background: #eee;
}
```

Expand Down
9 changes: 5 additions & 4 deletions packages/hiccup-css/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,18 @@ import { map } from "@thi.ng/transducers/xform/map";
export interface Format {
rules: string;
ruleSep: string;
valSep: string;
decls: string;
declsStart: string;
declEnd: string;
indent: string;
}

const NO_SPACES = ":[";
const NO_SPACES = ".:[";

export const FORMATS: IObjectOf<Format> = {
min: { rules: "", ruleSep: ",", decls: "", declsStart: "{", declEnd: "}", indent: "" },
pretty: { rules: "\n", ruleSep: ", ", decls: "\n", declsStart: " {\n", declEnd: "\n}", indent: " " },
min: { rules: "", ruleSep: ",", valSep: "", decls: "", declsStart: "{", declEnd: "}", indent: "" },
pretty: { rules: "\n", ruleSep: ", ", valSep: " ", decls: "\n", declsStart: " {\n", declEnd: "\n}", indent: " " },
};

const xfSel = ((a, b) => (x) => a(b(x)))(
Expand Down Expand Up @@ -61,7 +62,7 @@ function format(rules: any, fmt: Format) {
const acc = [];
for (let r in rules) {
if (rules.hasOwnProperty(r)) {
acc.push(`${fmt.indent}${r}:${rules[r]};`);
acc.push(`${fmt.indent}${r}:${fmt.valSep}${rules[r]};`);
}
}
return acc.join(fmt.decls);
Expand Down

0 comments on commit 5247b8f

Please sign in to comment.