Skip to content

Commit

Permalink
fix(swift): add missing space after UIColor's alpha property (#648)
Browse files Browse the repository at this point in the history
  • Loading branch information
NausJessy authored Jun 7, 2021
1 parent 8295b0d commit 7c65733
Show file tree
Hide file tree
Showing 6 changed files with 293 additions and 293 deletions.
570 changes: 285 additions & 285 deletions __integration__/__snapshots__/swift.test.js.snap

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions __tests__/common/transforms.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,21 +398,21 @@ describe('common', () => {
var value = transforms["color/UIColorSwift"].transformer({
value: "#aaaaaa"
});
expect(value).toBe("UIColor(red: 0.667, green: 0.667, blue: 0.667, alpha:1)");
expect(value).toBe("UIColor(red: 0.667, green: 0.667, blue: 0.667, alpha: 1)");
});

it('should retain enough precision when converting to decimal', () => {
var value = transforms["color/UIColorSwift"].transformer({
value: "#1d1d1d"
});
expect(value).toBe("UIColor(red: 0.114, green: 0.114, blue: 0.114, alpha:1)");
expect(value).toBe("UIColor(red: 0.114, green: 0.114, blue: 0.114, alpha: 1)");
});

it('should handle colors with transparency', () => {
var value = transforms["color/UIColorSwift"].transformer({
value: "#aaaaaa99"
});
expect(value).toBe("UIColor(red: 0.667, green: 0.667, blue: 0.667, alpha:0.6)");
expect(value).toBe("UIColor(red: 0.667, green: 0.667, blue: 0.667, alpha: 0.6)");
});
});

Expand Down
2 changes: 1 addition & 1 deletion docs/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ Creates a Swift implementation file of a class with values
**Example**
```swift
public class StyleDictionary {
public static let colorBackgroundDanger = UIColor(red: 1.000, green: 0.918, blue: 0.914, alpha:1)
public static let colorBackgroundDanger = UIColor(red: 1.000, green: 0.918, blue: 0.914, alpha: 1)
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/transforms.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ Transforms the value into an UIColor swift class for iOS
```swift
// Matches: token.attributes.category === 'color'
// Returns:
UIColor(red: 0.667, green: 0.667, blue: 0.667, alpha:0.6)
UIColor(red: 0.667, green: 0.667, blue: 0.667, alpha: 0.6)
```


Expand Down
2 changes: 1 addition & 1 deletion lib/common/formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ declare const ${moduleName}: ${JSON.stringify(treeWalker(dictionary.tokens), nul
* @example
* ```swift
* public class StyleDictionary {
* public static let colorBackgroundDanger = UIColor(red: 1.000, green: 0.918, blue: 0.914, alpha:1)
* public static let colorBackgroundDanger = UIColor(red: 1.000, green: 0.918, blue: 0.914, alpha: 1)
* }
* ```
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/common/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ module.exports = {
* ```swift
* // Matches: token.attributes.category === 'color'
* // Returns:
* UIColor(red: 0.667, green: 0.667, blue: 0.667, alpha:0.6)
* UIColor(red: 0.667, green: 0.667, blue: 0.667, alpha: 0.6)
* ```
*
* @memberof Transforms
Expand All @@ -470,7 +470,7 @@ module.exports = {
const rFixed = (r / 255.0).toFixed(3);
const gFixed = (g / 255.0).toFixed(3);
const bFixed = (b / 255.0).toFixed(3);
return `UIColor(red: ${rFixed}, green: ${gFixed}, blue: ${bFixed}, alpha:${a})`;
return `UIColor(red: ${rFixed}, green: ${gFixed}, blue: ${bFixed}, alpha: ${a})`;
}
},

Expand Down

0 comments on commit 7c65733

Please sign in to comment.