Skip to content

Commit

Permalink
Fix #152. Use right Android XML tag when transforming color
Browse files Browse the repository at this point in the history
  • Loading branch information
Jolanda Verhoef committed Jun 9, 2018
1 parent 9b9306a commit d95917d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 39 deletions.
70 changes: 35 additions & 35 deletions lib/__tests__/__snapshots__/formats.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
exports[`android.xml 1`] = `
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>
<resources>
<property name=\\"TOKEN_COLOR\\" category=\\"background-color\\">#bada55</property>
<property name=\\"TOKEN_SIZE\\" category=\\"spacing\\">20px</property>
<property name=\\"TOKEN_STRING\\" category=\\"test\\">/assets/images</property>
<property name=\\"TOKEN_NUMBER\\" category=\\"test\\">2</property>
<color name=\\"TOKEN_COLOR\\" category=\\"background-color\\">#bada55</property>
<dimen name=\\"TOKEN_SIZE\\" category=\\"spacing\\">20px</property>
<string name=\\"TOKEN_STRING\\" category=\\"test\\">/assets/images</property>
<integer name=\\"TOKEN_NUMBER\\" category=\\"test\\">2</property>
<property name=\\"TOKEN_QUOTES\\" category=\\"test\\">&apos;Salesforce Sans&apos;, &quot;Helvetica Neue&quot;, sans-serif</property>
</resources>"
`;
Expand Down Expand Up @@ -222,11 +222,11 @@ exports[`html 1`] = `
</header>
<div class=\\"container\\">
<main role=\\"main\\">
<section>
<table>
<thead>
<tr id=spacing>
<th scope=\\"col\\">Spacing</th>
Expand All @@ -235,7 +235,7 @@ exports[`html 1`] = `
<th scope=\\"col\\">Usage</th>
</tr>
</thead>
<tbody>
<tr>
<th scope=\\"row\\">
Expand All @@ -244,33 +244,33 @@ exports[`html 1`] = `
<td>
<code>20px</code>
</td>
<td>
<div class=\\"metric-box\\" style=\\"width: 20px; height: 20px;\\"></div>
</td>
<td></td>
</tr>
</tbody>
</table>
<hr />
</section>
<section>
<table>
<thead>
<tr id=background-color>
<th scope=\\"col\\">Background Colors</th>
Expand All @@ -279,7 +279,7 @@ exports[`html 1`] = `
<th scope=\\"col\\">Usage</th>
</tr>
</thead>
<tbody>
<tr>
<th scope=\\"row\\">
Expand All @@ -295,16 +295,16 @@ exports[`html 1`] = `
</table>
<hr />
</section>
</main>
</div>
</body>
Expand Down
16 changes: 12 additions & 4 deletions lib/formats/android.xml.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ module.exports = def => {
.get("props")
.map(prop => {
const key = (() => {
switch (prop.type) {
switch (prop.get("type")) {
case "color":
return prop.type;
return "color";
case "size":
return "dimen";
case "number":
return "integer";
case "string":
return "string";
default:
return "property";
}
Expand All @@ -32,6 +38,8 @@ module.exports = def => {
})
.toJS()
};

return xml(o, { indent: " ", declaration: true });
return xml(o, {
indent: " ",
declaration: true
});
};

0 comments on commit d95917d

Please sign in to comment.