Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(swift): add missing space after UIColor's alpha property #648

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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