-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(prefabs): add Size2D prefab (#211)
feat(targets): add iOS and web bindings for Size2D tweak(prefabs): use Size2D for width/height on Image tweak(examples): use Size2D for day part icons in PoodleSurf tweak(examples): use Size2D in PoodleSurfObjC fix(examples): expose Point2D to Objective-C tweak(examples): use Point2D in PoodleSurfObjC
- Loading branch information
Showing
38 changed files
with
432 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {prefab} from '@diez/engine'; | ||
|
||
/** | ||
* Size data. | ||
*/ | ||
export interface Size2DData { | ||
/** | ||
* The width value of the size. | ||
*/ | ||
width: number; | ||
/** | ||
* The height value of the size. | ||
*/ | ||
height: number; | ||
} | ||
|
||
/** | ||
* Provides a two dimensional size. | ||
* | ||
* Usage: `size = Size2D.make(1920, 1080);`. | ||
* | ||
* @noinheritdoc | ||
*/ | ||
export class Size2D extends prefab<Size2DData>() { | ||
defaults = { | ||
width: 0, | ||
height: 0, | ||
}; | ||
|
||
/** | ||
* Creates a two dimensional size. | ||
*/ | ||
static make (width: number, height: number) { | ||
return new Size2D({width, height}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {Size2D} from '../src/size2d'; | ||
|
||
describe('Size2D', () => { | ||
test('basic functionality', () => { | ||
const size = Size2D.make(400, 300); | ||
expect(size.serialize()).toEqual({width: 400, height: 300}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Foundation | ||
import CoreGraphics | ||
|
||
extension Size2D { | ||
@objc | ||
public var cgSize: CGSize { | ||
return CGSize(width: width, height: height) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export declare class Size2D { | ||
/** | ||
* The width of the size. | ||
*/ | ||
width: number; | ||
/** | ||
* The height of the size. | ||
*/ | ||
height: number; | ||
/** | ||
* The CSS `width` value. | ||
* @example | ||
* 400px | ||
*/ | ||
widthCss: string; | ||
/** | ||
* The CSS `height` value. | ||
* @example | ||
* 300px | ||
*/ | ||
heightCss: string; | ||
/** | ||
* CSS declarations for the `width` and `height` CSS properties. | ||
*/ | ||
style: {width: string, height: string}; | ||
/** | ||
* The CSS `background-size` value. | ||
* @example | ||
* 400px 300px | ||
*/ | ||
backgroundSizeCss: string; | ||
/** | ||
* CSS declarations for the `background-size` CSS property. | ||
*/ | ||
backgroundSizeStyle: {backgroundSize: string}; | ||
} |
Oops, something went wrong.