Compare commits

...

35 Commits

Author SHA1 Message Date
Emil Sjolander
352f592767 Allow decimal measurements on java
Summary: Preserve floating point values when passing them across the JNI bridge.

Differential Revision: D4366605

fbshipit-source-id: 0b94ee87a03a6ed918360dd9998930e780fc865d
2016-12-29 04:55:56 -08:00
Emil Sjolander
f2080e520f Move yoga docs into docs folder on master branch
Summary: Move yoga docs into master branch so that pull requests are able to include doc updates as part of other changes.

Reviewed By: JoelMarcey

Differential Revision: D4365700

fbshipit-source-id: 2f46a88974104c454c00bcdf1257abb5c4075a68
2016-12-28 04:09:48 -08:00
Lukas Woehrl
cd78291de5 C# use YogaSize throughout the measure call chain
Summary:
Java still has the same problem (see #296)

Also there is no need to have double in the method signature as we only use float internally, which could confuse some.
Closes https://github.com/facebook/yoga/pull/300

Reviewed By: splhack

Differential Revision: D4365993

Pulled By: emilsjolander

fbshipit-source-id: 681f8b1725e63eddcfb9a6c756f2ae215a44425a
2016-12-24 02:54:38 -08:00
Emil Sjolander
ab595d1875 ignore .buckversion
Summary: ignore .buckversion file from source control

Reviewed By: vjeux

Differential Revision: D4366002

fbshipit-source-id: 910173bab5f3235673a8686ae6b606624380df09
2016-12-24 02:54:38 -08:00
Emil Sjolander
597544e30a Add note about gtest submodule to readme
Summary: Add note about gtest submodule to readme

Reviewed By: vjeux

Differential Revision: D4366004

fbshipit-source-id: 13ddc040faa251d52aa4c253caff9f5478e12ca6
2016-12-24 02:54:38 -08:00
Kazuki Sakamoto
9f59a13836 Remove unused P/Invoke interface
Summary:
- Remove YGNodeGetContext and YGNodeSetContext from Native.cs
- https://github.com/facebook/yoga/pull/297#discussion_r93789907

Reviewed By: emilsjolander

Differential Revision: D4365845

fbshipit-source-id: 89b41ec773baa1b4901f637f5e83427c9fba4aed
2016-12-23 12:09:40 -08:00
Kazuki Sakamoto
12017e49bd Update .git/hgignore
Summary: Fix paths

Reviewed By: emilsjolander

Differential Revision: D4365853

fbshipit-source-id: 1eb5b1046f4bb7a18b8f29d2876c0d560c3fad49
2016-12-23 12:09:40 -08:00
Kazuki Sakamoto
abad796c44 Fix BUCK
Summary: Remove internal arg

Reviewed By: emilsjolander

Differential Revision: D4365827

fbshipit-source-id: 705855732146e03da65f21cbaa746277719b72f4
2016-12-23 11:24:37 -08:00
desmondyao
92137273a2 Not re-calculate value in Step1.
Summary:
Not re-calculate `paddingAndBorderAxisMain`/`paddingAndBorderAxisCross`/`paddingAndBorderAxisRow`/`paddingAndBorderAxisColumn` in Step1 of `YGNodelayoutImpl`.

They can be figure out by values calculated before.
Closes https://github.com/facebook/yoga/pull/298

Reviewed By: dshahidehpour

Differential Revision: D4365533

Pulled By: emilsjolander

fbshipit-source-id: 6caf60bc6ef3addd49915b39b48f01a8b4926e9c
2016-12-23 10:24:32 -08:00
Kazuki Sakamoto
f1ab289022 Run unit tests before building Unity package
Summary:
- Enable destructor unit tests in Unity Editor
- Exit pack.sh immediately if a command exits with a non-zero status
- Run unit tests before building Unity package

Reviewed By: emilsjolander

Differential Revision: D4365773

fbshipit-source-id: 20d0a51f4cef791154c17d329ac36598dc333a60
2016-12-23 09:54:32 -08:00
David Hart
a302b76d59 Added gitignore rule for Xcode xcuserdata
Summary: Closes https://github.com/facebook/yoga/pull/294

Reviewed By: dshahidehpour

Differential Revision: D4365534

Pulled By: emilsjolander

fbshipit-source-id: ff899d3526156ce9bbe8cba07418ca77b2f38ac8
2016-12-23 08:54:37 -08:00
Filip Frącz
4717594e93 Switched to using SafeHandle for native code interrupt
Summary:
This PR fixes issue #295

- Created a new internal YGNodeHandle class extending SafeHandle.
- YogaNode now stores a reference to YGNodeHandle.
- Removed finalizer from YogaNode.
- Pulling in System.Runtime.Handles 4.3.0.
Closes https://github.com/facebook/yoga/pull/297

Reviewed By: emilsjolander

Differential Revision: D4365462

Pulled By: splhack

fbshipit-source-id: 73293b105962cbedb71f4e3d8d1244251db1ea79
2016-12-23 08:39:33 -08:00
Hannes Verlinde
df0f76bba5 Run unit tests on Sandcastle
Summary:
- Change the CI config so it runs the tests for Editor on Sandcastle
- Don't run tests for effects-framework and yoga libraries when building for Mac (triggers code signing issues that I don't want to deal with right now)
- Add target for unit tests (aka EditorTests)
- Make the existing unit tests build and pass. These include both Objective-C and Swift (we should probably get rid of some of these though). I will convert these to Swift 3 before landing (after the migration is complete).
- Exclude the EditorUITests target for now. It only contains a single dummy test and it causes a code signing failure on Sandcastle. I did not manage to work around that yet but there is a separate task for it.

Reviewed By: Perspx

Differential Revision: D4352670

fbshipit-source-id: 0295004a72953bd8e7ae83895b2e5712bab7bd32
2016-12-23 02:09:35 -08:00
Kazuki Sakamoto
e43c9f66ff Add script to build Unity package
Summary:
Added Bash script and bat file to build a package of Yoga in order to import Yoga for Unity easily.
Closes https://github.com/facebook/yoga/pull/288

Reviewed By: emilsjolander

Differential Revision: D4344198

Pulled By: splhack

fbshipit-source-id: 49ae27dbc513b4a2d161840ca5c5f4c9df2ab227
2016-12-22 08:39:35 -08:00
Emil Sjolander
0df58d8aa2 Declaratively initialize default values of nodes
Summary: Improve performance of allocations and reseting by writing fewer bits. Also just looks nicer imho.

Reviewed By: passy

Differential Revision: D4356994

fbshipit-source-id: ebbe52163e0c86230bfa4131b657941afe16fbf1
2016-12-22 03:10:06 -08:00
David Hart
ff1a0e1eb8 Transform the Count enum values into private constants
Summary:
Hides implementation details for the C, Objective-C and Swift APIs.
Closes https://github.com/facebook/yoga/pull/292

Differential Revision: D4351523

Pulled By: emilsjolander

fbshipit-source-id: 18a1149d169f0d52bd078714295000b5d07434dd
2016-12-22 03:10:06 -08:00
Emil Sjolander
ed765fe508 Convert max cache count into a define
Summary: This should not be an enum. A define makes a whole lot more sense

Differential Revision: D4346529

fbshipit-source-id: 8641c4c5017d915d64e5884cae09ac8f01861337
2016-12-22 03:10:06 -08:00
Emil Sjolander
1b5eb7da5e BREAKING - Increase priority of AspectRatio to override flex, align stretch, and fixed sizes if specified.
Summary:
@public
AspectRatio is a new addition and soon after introduction we noticed use cases which is did not support. Specifically we wanted to support a node being as large as possible within a container while maintaining an arbitrary aspect ratio. This was not possible due to the low priority of AspectRatio, by increasing the priority of AspectRatio this is now possible as FlexGrow will grow an item to fit its parent unless the AspectRatio makes it too big in the cross axis, the AspectRatio will now override the FlexGrow in the main axis in that case.

Differential Revision: D4346720

fbshipit-source-id: 1f15613604190e3ad5ff4a467ba57db4bcfd2741
2016-12-22 03:10:06 -08:00
Emil Sjolander
071f576db9 BREAKING - Change aspect ratio to always be width/height
Summary:
@public

Aspect ratio being defined as width/height or height/width depending on the situation it was used in turned out to be very confusing. This diff makes aspect ratio always be defined as width/height irregardless of the usage.

Differential Revision: D4339132

fbshipit-source-id: e5da32750b55ddaf6acaf1cbd7662d86f2b480c3
2016-12-22 03:10:06 -08:00
Emil Sjolander
3d10ba5f72 Correctly check if child is flex by also accounting for undefined
Summary: We were incorrectly returning true for children which had no flex as the flex was nan and not 0.

Differential Revision: D4346712

fbshipit-source-id: 69ef0bb3fe5b4fcd3b3e2fe5aa348529be40252a
2016-12-22 03:10:05 -08:00
Georgiy Kassabli
85b8386ba1 Test for minHeight with flexing
Summary: This test creates a repro case for Yoga to emulate UFI layout failure

Reviewed By: emilsjolander

Differential Revision: D4313632

fbshipit-source-id: 35be7d86b50a9ae08c81891a889a74e4b61f2d27
2016-12-21 11:39:34 -08:00
Dustin Shahidehpour
7ec3607446 Fix diffing algorithm for reattaching views.
Summary:
There is a bug currently where we don't traverse the entire tree to detect view hierarchy changes.

Currently, if you had a hierachy like this:
```
container = UIView
container.subviews = @[subview1, subview2];

subview1.subviews = @[sub11, sub12, sub13];
subview2.subviews = @[sub21, sub22, sub23];
```

and then modified via:
```
subview2.subviews = @[newView1, newView2, newView3];
```

our algorithm wouldn't identify that we had new views that needed their layout calculated, and would cause a crash later on.

Reviewed By: emilsjolander

Differential Revision: D4357662

fbshipit-source-id: 2f61f213c5f1a62948a653f3b1fa3d874c5075f7
2016-12-21 11:09:38 -08:00
Dustin Shahidehpour
835bb1cd9c Add isLeaf flag to Views.
Summary: While building some views with YogaKit, I found an interesting problem. If you are apply `yg_` properties to a view which is constructed of subclassed views (that don't use Yoga.) we still treat view (and it's subviews) like they are using YogaKit. This fixes that behavior.

Reviewed By: emilsjolander

Differential Revision: D4348344

fbshipit-source-id: 37b8648918529f55afea1d1883a03af398aac849
2016-12-20 11:39:36 -08:00
yiminghe
9d35dce63e explicit default justifyContent value
Summary:
make default justifyContent value explicit like alignItems

https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content

https://developer.mozilla.org/en-US/docs/Web/CSS/align-items

https://developer.mozilla.org/en-US/docs/Web/CSS/align-content
Closes https://github.com/facebook/yoga/pull/293

Differential Revision: D4351597

Pulled By: emilsjolander

fbshipit-source-id: b65ff2284ede4d75f1cc5e22d4106042ab0b0d02
2016-12-20 03:24:40 -08:00
Emil Sjolander
74fb205083 Rename test files to match other test file names
Summary: Rename test files to match other test file names

Differential Revision: D4335198

fbshipit-source-id: b8f38162c3094231476059eb1f54326d8ba84848
2016-12-16 09:09:37 -08:00
Kazuki Sakamoto
ba0bb10366 Build iOS fat static library for Unity and Xamarin
Summary:
$ buck build //csharp:yoganet-ios
    $ buck targets --show-output //csharp:yoganet-ios
    //csharp:yoganet-ios buck-out/gen/csharp/yoganet-ios/libyoga.a

    $ lipo -info buck-out/gen/csharp/yoganet-ios/libyoga.a
    Architectures in the fat file: buck-out/gen/csharp/yoganet-ios/libyoga.a are: armv7 x86_64 arm64

    $ nm buck-out/gen/csharp/yoganet-ios/libyoga.a|grep -e 'T _YGNodeNew' -e 'ygNode' -e 'T _YGInteropSetLogger'
    0000000000000000 T _YGNodeNew
    0000000000001070 t -[UIView(Yoga) ygNode]
    0000000000000000 T _YGInteropSetLogger
Closes https://github.com/facebook/yoga/pull/286

Reviewed By: emilsjolander

Differential Revision: D4338919

Pulled By: splhack

fbshipit-source-id: 7acfdfa0dc4d152d7bfe92161efdeb9f161f70e6
2016-12-16 06:54:35 -08:00
Emil Sjolander
0296511f2c YGNodeChildCount -> YGNodeGetChildCount for consistency
Summary: I kept wrongly typing this function which is a good sign that the name is inconsistent.

Reviewed By: gkassabli

Differential Revision: D4333480

fbshipit-source-id: 17058f18fa9e26b3e02f7a1651f7295cae59acad
2016-12-16 04:39:41 -08:00
Kazuki Sakamoto
04fe81f88f YGNodeInit is no longer exported
Summary:
- Problem: Can't link yoga static libraries with Unity and Xamarin.iOS since YGNodeInit is undefined in the libraries.
- Solution: Remove the reference in Native.cs

Reviewed By: emilsjolander

Differential Revision: D4338485

fbshipit-source-id: 9dc95aec8f1fd50f3f9d66e1623afe2fb1992210
2016-12-16 00:09:40 -08:00
Kazuki Sakamoto
98bbc15435 Support Xamarin.iOS
Summary:
- `__Internal`

https://developer.xamarin.com/guides/ios/advanced_topics/native_interop/#Static_Libraries

 > Since you can only use static libraries on iOS, there is no external shared library to link with, so the path parameter in the DllImport attribute needs to use the special name __Internal (note the double underscore characters at the start of the name) as opposed to the path name.

- `__IOS__`

https://developer.xamarin.com/guides/cross-platform/application_fundamentals/building_cross_platform_applications/part_4_-_platform_divergence_abstraction_divergent_implementation/#iOS

 > Xamarin.iOS defines __IOS__ which you can use to detect iOS devices.
Closes https://github.com/facebook/yoga/pull/277

Reviewed By: emilsjolander

Differential Revision: D4338420

Pulled By: splhack

fbshipit-source-id: 375efecbaf88fffbba544073c6d6b30fb1f4c8ba
2016-12-16 00:09:40 -08:00
Kazuki Sakamoto
25b206ac53 Build native library with BUCK for .NET (Mono, Xamarin)
Summary:
Examples:

- macOS on macOS (Mono, Xamarin.Mac, Unity)
  - `buck build //csharp:yoganet#shared,default` -> `libyoga.dylib`
- Android (Xamarin.Android, Unity)
  - `buck build //csharp:yoganet#shared,android-armv7` -> `libyoga.so`
- iOS (Xamarin.iOS, Unity)
  - `buck build //:yoga#static,iphoneos-arm64` -> `libyoga.a`
  - `buck build //csharp:yoganet#static,iphoneos-arm64` -> `libyoganet.a`
Closes https://github.com/facebook/yoga/pull/282

Reviewed By: emilsjolander

Differential Revision: D4333811

Pulled By: splhack

fbshipit-source-id: 54f4364d93b2419d7504392eb558296a5d06772f
2016-12-15 13:54:34 -08:00
Emil Sjolander
88a4e44fd4 Add YGNodeGetParent api
Summary: Fixes https://github.com/facebook/css-layout/issues/248

Reviewed By: gkassabli

Differential Revision: D4333456

fbshipit-source-id: 388afd0a01c19a6db73c175bf24c566278832cb9
2016-12-15 09:54:35 -08:00
Kazuki Sakamoto
642ea07d6f Update unmanaged dll name
Summary: - Update unmanaged dll name from `Yoga.dll` to `yoga.dll` since Native.cs `DllName` referes lowercase `yoga`

Reviewed By: emilsjolander

Differential Revision: D4295954

fbshipit-source-id: 16b91c407506685b84902102cf4380cb149b5b2c
2016-12-15 07:24:46 -08:00
Kazuki Sakamoto
e85c5ce39d lowercase argument
Summary: - Fix arguments of YogaNode.Create

Reviewed By: emilsjolander

Differential Revision: D4296488

fbshipit-source-id: f6eb5074b1b1462f2251d330929f7b8082ad72eb
2016-12-15 07:24:46 -08:00
Jatin Pandey
cf753af247 Make documentation clearer
Summary:
Fixing a typo :)
Closes https://github.com/facebook/yoga/pull/270

Reviewed By: dshahidehpour

Differential Revision: D4333129

Pulled By: emilsjolander

fbshipit-source-id: 28215de8fcd571fb889fe145ff303f231a50c598
2016-12-15 07:24:46 -08:00
Emil Sjolander
12efe604bb Fix YogaKit tests on travis
Summary: Fix include path

Reviewed By: dshahidehpour

Differential Revision: D4333185

fbshipit-source-id: 27638324e093260aa1b23134fab5140a0c703bc9
2016-12-15 07:24:46 -08:00
154 changed files with 6663 additions and 429 deletions

42
.gitignore vendored
View File

@@ -5,6 +5,48 @@
/.buckconfig.local
/.buckd
/gentest/test.html
.buckversion
# Visual studio code
.vscode
# Xcode
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xcuserstate
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build

View File

@@ -5,6 +5,48 @@
/.buckconfig.local
/.buckd
/gentest/test.html
.buckversion
# Visual studio code
.vscode
# Xcode
## Build generated
build/
DerivedData/
## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
## Other
*.moved-aside
*.xcuserstate
## Obj-C/Swift specific
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Pods/
# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build

8
BUCK
View File

@@ -7,14 +7,6 @@
include_defs('//YOGA_DEFS')
BASE_COMPILER_FLAGS = [
'-fno-omit-frame-pointer',
'-fexceptions',
'-Wall',
'-Werror',
'-O3',
]
GMOCK_OVERRIDE_FLAGS = [
# gmock does not mark mocked methods as override, ignore the warnings in tests
'-Wno-inconsistent-missing-override',

View File

@@ -4,6 +4,8 @@
Yoga builds with [buck](https://buckbuild.com). Make sure you install buck before contributing to Yoga. Yoga's main implementation is in C, with bindings to supported languages and frameworks. When making changes to Yoga please ensure the changes are also propagated to these bindings when applicable.
## Testing
For testing we rely on [gtest](https://github.com/google/googletest) as a submodule. After cloning Yoga run `git submodule init` followed by `git submodule update`.
For any changes you make you should ensure that all the tests are passing. In case you make any fixes or additions to the library please also add tests for that change to ensure we don't break anything in the future. Tests are located in the `tests` directory. Run the tests by executing `buck test //:yoga`.
Instead of manually writing a test which ensures parity with web implementations of Flexbox you can run `gentest/gentest.rb` to generated a test for you. You can write html which you want to verify in Yoga, in `gentest/fixtures` folder, such as the following.

View File

@@ -17,6 +17,14 @@ CXX_LIBRARY_WHITELIST = [
'//java:jni',
]
BASE_COMPILER_FLAGS = [
'-fno-omit-frame-pointer',
'-fexceptions',
'-Wall',
'-Werror',
'-O3',
]
def yoga_dep(dep):
return '//' + dep

View File

@@ -9,7 +9,7 @@
#import <XCTest/XCTest.h>
#import "UIView+Yoga.h"
#import <YogaKit/UIView+Yoga.h>
@interface YogaKitTests : XCTestCase
@end
@@ -268,4 +268,79 @@
}
}
- (void)testyg_isLeafFlag
{
UIView *view = [[UIView alloc] initWithFrame:CGRectZero];
XCTAssertTrue(view.yg_isLeaf);
for (int i=0; i<10; i++) {
UIView *subview = [[UIView alloc] initWithFrame:CGRectZero];
[view addSubview:subview];
}
XCTAssertTrue(view.yg_isLeaf);
[view yg_setUsesYoga:YES];
[view yg_setWidth:50.0];
XCTAssertTrue(view.yg_isLeaf);
UIView *const subview = view.subviews[0];
[subview yg_setUsesYoga:YES];
[subview yg_setWidth:50.0];
XCTAssertFalse(view.yg_isLeaf);
}
- (void)testThatWeCorrectlyAttachNestedViews
{
UIView *container = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 50)];
[container yg_setUsesYoga:YES];
[container yg_setFlexDirection:YGFlexDirectionColumn];
UIView *subview1 = [[UIView alloc] initWithFrame:CGRectZero];
[subview1 yg_setUsesYoga:YES];
[subview1 yg_setWidth:100];
[subview1 yg_setFlexGrow:1];
[subview1 yg_setFlexDirection:YGFlexDirectionColumn];
[container addSubview:subview1];
UIView *subview2 = [[UIView alloc] initWithFrame:CGRectZero];
[subview2 yg_setUsesYoga:YES];
[subview2 yg_setWidth:150];
[subview2 yg_setFlexGrow:1];
[subview2 yg_setFlexDirection:YGFlexDirectionColumn];
[container addSubview:subview2];
for (UIView *view in @[subview1, subview2]) {
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
[someView yg_setUsesYoga:YES];
[someView yg_setFlexGrow:1];
[view addSubview:someView];
}
[container yg_applyLayout];
// Add the same amount of new views, reapply layout.
for (UIView *view in @[subview1, subview2]) {
UIView *someView = [[UIView alloc] initWithFrame:CGRectZero];
[someView yg_setUsesYoga:YES];
[someView yg_setFlexGrow:1];
[view addSubview:someView];
}
[container yg_applyLayout];
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(100, 25), subview1.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview1.bounds.size));
for (UIView *subview in subview1.subviews) {
const CGSize subviewSize = subview.bounds.size;
XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subviewSize));
XCTAssertFalse(isnan(subviewSize.height));
XCTAssertFalse(isnan(subviewSize.width));
}
XCTAssertTrue(CGSizeEqualToSize(CGSizeMake(150, 25), subview2.bounds.size), @"Actual size is %@", NSStringFromCGSize(subview2.bounds.size));
for (UIView *subview in subview2.subviews) {
const CGSize subviewSize = subview.bounds.size;
XCTAssertFalse(CGSizeEqualToSize(CGSizeZero, subview.bounds.size));
XCTAssertFalse(isnan(subviewSize.height));
XCTAssertFalse(isnan(subviewSize.width));
}
}
@end

View File

@@ -55,7 +55,7 @@
- (YGDirection)yg_resolvedDirection;
/**
Perform a layout calculation and update the frames of the views in the hierarchy with th results
Perform a layout calculation and update the frames of the views in the hierarchy with the results
*/
- (void)yg_applyLayout;
@@ -69,4 +69,9 @@
*/
- (NSUInteger)yg_numberOfChildren;
/**
Return a BOOL indiciating whether or not we this node contains any subviews that are included in Yoga's layout.
*/
- (BOOL)yg_isLeaf;
@end

View File

@@ -53,7 +53,21 @@
- (NSUInteger)yg_numberOfChildren
{
return YGNodeChildCount([self ygNode]);
return YGNodeGetChildCount([self ygNode]);
}
- (BOOL)yg_isLeaf
{
NSAssert([NSThread isMainThread], @"This method must be called on the main thread.");
if ([self yg_usesYoga]) {
for (UIView *subview in self.subviews) {
if ([subview yg_usesYoga] && [subview yg_includeInLayout]) {
return NO;
}
}
}
return YES;
}
#pragma mark - Setters
@@ -276,17 +290,32 @@ static CGFloat YGSanitizeMeasurement(
return result;
}
static void YGAttachNodesFromViewHierachy(UIView *view) {
YGNodeRef node = [view ygNode];
static BOOL YGNodeHasExactSameChildren(const YGNodeRef node, NSArray<UIView *> *subviews)
{
if (YGNodeGetChildCount(node) != subviews.count) {
return NO;
}
for (int i=0; i<subviews.count; i++) {
if (YGNodeGetChild(node, i) != subviews[i].ygNode) {
return NO;
}
}
return YES;
}
static void YGAttachNodesFromViewHierachy(UIView *const view)
{
const YGNodeRef node = [view ygNode];
// Only leaf nodes should have a measure function
if (![view yg_usesYoga] || view.subviews.count == 0) {
if (view.yg_isLeaf) {
YGNodeSetMeasureFunc(node, YGMeasureView);
YGRemoveAllChildren(node);
} else {
YGNodeSetMeasureFunc(node, NULL);
// Create a list of all the subviews that we are going to use for layout.
NSMutableArray<UIView *> *subviewsToInclude = [[NSMutableArray alloc] initWithCapacity:view.subviews.count];
for (UIView *subview in view.subviews) {
if ([subview yg_includeInLayout]) {
@@ -294,26 +323,15 @@ static void YGAttachNodesFromViewHierachy(UIView *view) {
}
}
BOOL shouldReconstructChildList = NO;
if (YGNodeChildCount(node) != subviewsToInclude.count) {
shouldReconstructChildList = YES;
} else {
for (int i = 0; i < subviewsToInclude.count; i++) {
if (YGNodeGetChild(node, i) != [subviewsToInclude[i] ygNode]) {
shouldReconstructChildList = YES;
break;
if (!YGNodeHasExactSameChildren(node, subviewsToInclude)) {
YGRemoveAllChildren(node);
for (int i=0; i<subviewsToInclude.count; i++) {
YGNodeInsertChild(node, [subviewsToInclude[i] ygNode], i);
}
}
}
if (shouldReconstructChildList) {
YGRemoveAllChildren(node);
for (int i = 0 ; i < subviewsToInclude.count; i++) {
UIView *const subview = subviewsToInclude[i];
YGNodeInsertChild(node, [subview ygNode], i);
for (UIView *const subview in subviewsToInclude) {
YGAttachNodesFromViewHierachy(subview);
}
}
}
}
@@ -324,8 +342,8 @@ static void YGRemoveAllChildren(const YGNodeRef node)
return;
}
while (YGNodeChildCount(node) > 0) {
YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeChildCount(node) - 1));
while (YGNodeGetChildCount(node) > 0) {
YGNodeRemoveChild(node, YGNodeGetChild(node, YGNodeGetChildCount(node) - 1));
}
}
@@ -340,7 +358,8 @@ static CGFloat YGRoundPixelValue(CGFloat value)
return round(value * scale) / scale;
}
static void YGApplyLayoutToViewHierarchy(UIView *view) {
static void YGApplyLayoutToViewHierarchy(UIView *view)
{
NSCAssert([NSThread isMainThread], @"Framesetting should only be done on the main thread.");
if (![view yg_includeInLayout]) {
return;
@@ -368,9 +387,8 @@ static void YGApplyLayoutToViewHierarchy(UIView *view) {
},
};
const BOOL isLeaf = ![view yg_usesYoga] || view.subviews.count == 0;
if (!isLeaf) {
for (NSUInteger i = 0; i < view.subviews.count; i++) {
if (!view.yg_isLeaf) {
for (NSUInteger i=0; i<view.subviews.count; i++) {
YGApplyLayoutToViewHierarchy(view.subviews[i]);
}
}

View File

@@ -1,91 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13687D421DF8748300E7C260"
BuildableName = "YogaKitSample.app"
BlueprintName = "YogaKitSample"
ReferencedContainer = "container:YogaKitSample.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13687D421DF8748300E7C260"
BuildableName = "YogaKitSample.app"
BlueprintName = "YogaKitSample"
ReferencedContainer = "container:YogaKitSample.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13687D421DF8748300E7C260"
BuildableName = "YogaKitSample.app"
BlueprintName = "YogaKitSample"
ReferencedContainer = "container:YogaKitSample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "13687D421DF8748300E7C260"
BuildableName = "YogaKitSample.app"
BlueprintName = "YogaKitSample"
ReferencedContainer = "container:YogaKitSample.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -1,22 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>YogaKitSample.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>13687D421DF8748300E7C260</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

9
csharp/.gitignore vendored
View File

@@ -30,15 +30,14 @@ bld/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
csharp/tests/Facebook.Yoga/NUnit-[0-9\.]+/
csharp/tests/Facebook.Yoga/YogaTest.dll
csharp/tests/Facebook.Yoga/YogaTest.dll.mdb
csharp/tests/Facebook.Yoga/libyoga.dylib
csharp/tests/Facebook.Yoga/libyoga.dylib.dSYM/
# NUNIT
*.VisualState.xml
TestResult.xml
tests/Facebook.Yoga/NUnit-[0-9\.]*/
tests/Facebook.Yoga/YogaTest.dll
tests/Facebook.Yoga/YogaTest.dll.mdb
tests/Facebook.Yoga/libyoga.dylib
# Build Results of an ATL Project
[Dd]ebugPS/

View File

@@ -34,11 +34,10 @@ bld/
# NUNIT
*.VisualState.xml
TestResult.xml
csharp/tests/Facebook.Yoga/NUnit-[0-9\.]+/
csharp/tests/Facebook.Yoga/YogaTest.dll
csharp/tests/Facebook.Yoga/YogaTest.dll.mdb
csharp/tests/Facebook.Yoga/libyoga.dylib
csharp/tests/Facebook.Yoga/libyoga.dylib.dSYM/
tests/Facebook.Yoga/NUnit-[0-9\.]*/
tests/Facebook.Yoga/YogaTest.dll
tests/Facebook.Yoga/YogaTest.dll.mdb
tests/Facebook.Yoga/libyoga.dylib
# Build Results of an ATL Project
[Dd]ebugPS/

View File

@@ -5,6 +5,10 @@
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
include_defs('//YOGA_DEFS')
COMPILER_FLAGS = BASE_COMPILER_FLAGS + ['-std=c++11']
csharp_library(
name = 'yogalibnet46',
dll_name = 'Facebook.Yoga.dll',
@@ -18,3 +22,42 @@ csharp_library(
framework_ver = 'net45',
srcs = glob(['**/*.cs']),
)
cxx_library(
name = 'yoganet',
soname = 'libyoga.$(ext)',
srcs = glob(['Yoga/YGInterop.cpp']),
compiler_flags = COMPILER_FLAGS,
link_style = 'static',
link_whole = True,
deps = [yoga_dep(':yoga')],
visibility = ['PUBLIC'],
)
with allow_unsafe_import():
import os
if os.path.isdir('/Applications/Xcode.app'):
yoganet_ios_srcs = []
for arch in ['iphonesimulator-x86_64', 'iphoneos-arm64', 'iphoneos-armv7']:
name = 'yoganet-' + arch
yoganet_ios_srcs.append(':' + name)
genrule(
name = name,
srcs = [
yoga_dep(':yoga#%s,static' % arch),
yoga_dep('YogaKit:YogaKit#%s,static' % arch),
yoga_dep('csharp:yoganet#%s,static' % arch),
],
out = 'libyoga-%s.a' % arch,
cmd = 'libtool -static -o $OUT $SRCS',
visibility = [yoga_dep('csharp:yoganet-ios')],
)
genrule(
name = 'yoganet-ios',
srcs = yoganet_ios_srcs,
out = 'libyoga.a',
cmd = 'lipo $SRCS -create -output $OUT',
visibility = ['PUBLIC'],
)

View File

@@ -9,7 +9,7 @@
namespace Facebook.Yoga
{
public delegate long MeasureFunction(
public delegate YogaSize MeasureFunction(
YogaNode node,
float width,
YogaMeasureMode widthMode,

View File

@@ -11,24 +11,9 @@ namespace Facebook.Yoga
{
public class MeasureOutput
{
public static long Make(double width, double height)
public static YogaSize Make(float width, float height)
{
return Make((int) width, (int) height);
}
public static long Make(int width, int height)
{
return (long)(((ulong) width) << 32 | ((uint) height));
}
public static int GetWidth(long measureOutput)
{
return (int) (0xFFFFFFFF & (measureOutput >> 32));
}
public static int GetHeight(long measureOutput)
{
return (int) (0xFFFFFFFF & measureOutput);
return new YogaSize { width = width, height = height};
}
}
}

View File

@@ -14,27 +14,46 @@ namespace Facebook.Yoga
{
internal static class Native
{
#if UNITY_IOS && !UNITY_EDITOR
#if (UNITY_IOS && !UNITY_EDITOR) || __IOS__
private const string DllName = "__Internal";
#else
private const string DllName = "yoga";
#endif
internal class YGNodeHandle : SafeHandle
{
private YGNodeHandle() : base(IntPtr.Zero, true)
{
}
public override bool IsInvalid
{
get
{
return this.handle == IntPtr.Zero;
}
}
protected override bool ReleaseHandle()
{
Native.YGNodeFree(this.handle);
GC.KeepAlive(this);
return true;
}
}
[DllImport(DllName)]
public static extern void YGInteropSetLogger(
[MarshalAs(UnmanagedType.FunctionPtr)] YogaLogger.Func func);
[DllImport(DllName)]
public static extern IntPtr YGNodeNew();
[DllImport(DllName)]
public static extern void YGNodeInit(IntPtr node);
public static extern YGNodeHandle YGNodeNew();
[DllImport(DllName)]
public static extern void YGNodeFree(IntPtr node);
[DllImport(DllName)]
public static extern void YGNodeReset(IntPtr node);
public static extern void YGNodeReset(YGNodeHandle node);
[DllImport(DllName)]
public static extern int YGNodeGetInstanceCount();
@@ -49,237 +68,225 @@ namespace Facebook.Yoga
YogaExperimentalFeature feature);
[DllImport(DllName)]
public static extern void YGNodeInsertChild(IntPtr node, IntPtr child, uint index);
public static extern void YGNodeInsertChild(YGNodeHandle node, YGNodeHandle child, uint index);
[DllImport(DllName)]
public static extern void YGNodeRemoveChild(IntPtr node, IntPtr child);
public static extern void YGNodeRemoveChild(YGNodeHandle node, YGNodeHandle child);
[DllImport(DllName)]
public static extern IntPtr YGNodeGetChild(IntPtr node, uint index);
[DllImport(DllName)]
public static extern uint YGNodeChildCount(IntPtr node);
[DllImport(DllName)]
public static extern void YGNodeCalculateLayout(IntPtr node,
public static extern void YGNodeCalculateLayout(YGNodeHandle node,
float availableWidth,
float availableHeight,
YogaDirection parentDirection);
[DllImport(DllName)]
public static extern void YGNodeMarkDirty(IntPtr node);
public static extern void YGNodeMarkDirty(YGNodeHandle node);
[DllImport(DllName)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool YGNodeIsDirty(IntPtr node);
public static extern bool YGNodeIsDirty(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodePrint(IntPtr node, YogaPrintOptions options);
public static extern void YGNodePrint(YGNodeHandle node, YogaPrintOptions options);
[DllImport(DllName)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool YGValueIsUndefined(float value);
[DllImport(DllName)]
public static extern void YGNodeCopyStyle(IntPtr dstNode, IntPtr srcNode);
public static extern void YGNodeCopyStyle(YGNodeHandle dstNode, YGNodeHandle srcNode);
#region YG_NODE_PROPERTY
[DllImport(DllName)]
public static extern void YGNodeSetContext(IntPtr node, IntPtr context);
[DllImport(DllName)]
public static extern IntPtr YGNodeGetContext(IntPtr node);
[DllImport(DllName)]
public static extern void YGNodeSetMeasureFunc(
IntPtr node,
YGNodeHandle node,
[MarshalAs(UnmanagedType.FunctionPtr)] YogaMeasureFunc measureFunc);
[DllImport(DllName)]
[return: MarshalAs(UnmanagedType.FunctionPtr)]
public static extern YogaMeasureFunc YGNodeGetMeasureFunc(IntPtr node);
public static extern YogaMeasureFunc YGNodeGetMeasureFunc(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeSetHasNewLayout(IntPtr node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout);
public static extern void YGNodeSetHasNewLayout(YGNodeHandle node, [MarshalAs(UnmanagedType.I1)] bool hasNewLayout);
[DllImport(DllName)]
[return: MarshalAs(UnmanagedType.I1)]
public static extern bool YGNodeGetHasNewLayout(IntPtr node);
public static extern bool YGNodeGetHasNewLayout(YGNodeHandle node);
#endregion
#region YG_NODE_STYLE_PROPERTY
[DllImport(DllName)]
public static extern void YGNodeStyleSetDirection(IntPtr node, YogaDirection direction);
public static extern void YGNodeStyleSetDirection(YGNodeHandle node, YogaDirection direction);
[DllImport(DllName)]
public static extern YogaDirection YGNodeStyleGetDirection(IntPtr node);
public static extern YogaDirection YGNodeStyleGetDirection(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetFlexDirection(IntPtr node, YogaFlexDirection flexDirection);
public static extern void YGNodeStyleSetFlexDirection(YGNodeHandle node, YogaFlexDirection flexDirection);
[DllImport(DllName)]
public static extern YogaFlexDirection YGNodeStyleGetFlexDirection(IntPtr node);
public static extern YogaFlexDirection YGNodeStyleGetFlexDirection(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetJustifyContent(IntPtr node, YogaJustify justifyContent);
public static extern void YGNodeStyleSetJustifyContent(YGNodeHandle node, YogaJustify justifyContent);
[DllImport(DllName)]
public static extern YogaJustify YGNodeStyleGetJustifyContent(IntPtr node);
public static extern YogaJustify YGNodeStyleGetJustifyContent(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetAlignContent(IntPtr node, YogaAlign alignContent);
public static extern void YGNodeStyleSetAlignContent(YGNodeHandle node, YogaAlign alignContent);
[DllImport(DllName)]
public static extern YogaAlign YGNodeStyleGetAlignContent(IntPtr node);
public static extern YogaAlign YGNodeStyleGetAlignContent(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetAlignItems(IntPtr node, YogaAlign alignItems);
public static extern void YGNodeStyleSetAlignItems(YGNodeHandle node, YogaAlign alignItems);
[DllImport(DllName)]
public static extern YogaAlign YGNodeStyleGetAlignItems(IntPtr node);
public static extern YogaAlign YGNodeStyleGetAlignItems(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetAlignSelf(IntPtr node, YogaAlign alignSelf);
public static extern void YGNodeStyleSetAlignSelf(YGNodeHandle node, YogaAlign alignSelf);
[DllImport(DllName)]
public static extern YogaAlign YGNodeStyleGetAlignSelf(IntPtr node);
public static extern YogaAlign YGNodeStyleGetAlignSelf(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetPositionType(IntPtr node, YogaPositionType positionType);
public static extern void YGNodeStyleSetPositionType(YGNodeHandle node, YogaPositionType positionType);
[DllImport(DllName)]
public static extern YogaPositionType YGNodeStyleGetPositionType(IntPtr node);
public static extern YogaPositionType YGNodeStyleGetPositionType(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetFlexWrap(IntPtr node, YogaWrap flexWrap);
public static extern void YGNodeStyleSetFlexWrap(YGNodeHandle node, YogaWrap flexWrap);
[DllImport(DllName)]
public static extern YogaWrap YGNodeStyleGetFlexWrap(IntPtr node);
public static extern YogaWrap YGNodeStyleGetFlexWrap(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetOverflow(IntPtr node, YogaOverflow flexWrap);
public static extern void YGNodeStyleSetOverflow(YGNodeHandle node, YogaOverflow flexWrap);
[DllImport(DllName)]
public static extern YogaOverflow YGNodeStyleGetOverflow(IntPtr node);
public static extern YogaOverflow YGNodeStyleGetOverflow(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetFlex(IntPtr node, float flex);
public static extern void YGNodeStyleSetFlex(YGNodeHandle node, float flex);
[DllImport(DllName)]
public static extern void YGNodeStyleSetFlexGrow(IntPtr node, float flexGrow);
public static extern void YGNodeStyleSetFlexGrow(YGNodeHandle node, float flexGrow);
[DllImport(DllName)]
public static extern float YGNodeStyleGetFlexGrow(IntPtr node);
public static extern float YGNodeStyleGetFlexGrow(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetFlexShrink(IntPtr node, float flexShrink);
public static extern void YGNodeStyleSetFlexShrink(YGNodeHandle node, float flexShrink);
[DllImport(DllName)]
public static extern float YGNodeStyleGetFlexShrink(IntPtr node);
public static extern float YGNodeStyleGetFlexShrink(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetFlexBasis(IntPtr node, float flexBasis);
public static extern void YGNodeStyleSetFlexBasis(YGNodeHandle node, float flexBasis);
[DllImport(DllName)]
public static extern float YGNodeStyleGetFlexBasis(IntPtr node);
public static extern float YGNodeStyleGetFlexBasis(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetWidth(IntPtr node, float width);
public static extern void YGNodeStyleSetWidth(YGNodeHandle node, float width);
[DllImport(DllName)]
public static extern float YGNodeStyleGetWidth(IntPtr node);
public static extern float YGNodeStyleGetWidth(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetHeight(IntPtr node, float height);
public static extern void YGNodeStyleSetHeight(YGNodeHandle node, float height);
[DllImport(DllName)]
public static extern float YGNodeStyleGetHeight(IntPtr node);
public static extern float YGNodeStyleGetHeight(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetMinWidth(IntPtr node, float minWidth);
public static extern void YGNodeStyleSetMinWidth(YGNodeHandle node, float minWidth);
[DllImport(DllName)]
public static extern float YGNodeStyleGetMinWidth(IntPtr node);
public static extern float YGNodeStyleGetMinWidth(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetMinHeight(IntPtr node, float minHeight);
public static extern void YGNodeStyleSetMinHeight(YGNodeHandle node, float minHeight);
[DllImport(DllName)]
public static extern float YGNodeStyleGetMinHeight(IntPtr node);
public static extern float YGNodeStyleGetMinHeight(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetMaxWidth(IntPtr node, float maxWidth);
public static extern void YGNodeStyleSetMaxWidth(YGNodeHandle node, float maxWidth);
[DllImport(DllName)]
public static extern float YGNodeStyleGetMaxWidth(IntPtr node);
public static extern float YGNodeStyleGetMaxWidth(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetMaxHeight(IntPtr node, float maxHeight);
public static extern void YGNodeStyleSetMaxHeight(YGNodeHandle node, float maxHeight);
[DllImport(DllName)]
public static extern float YGNodeStyleGetMaxHeight(IntPtr node);
public static extern float YGNodeStyleGetMaxHeight(YGNodeHandle node);
[DllImport(DllName)]
public static extern void YGNodeStyleSetAspectRatio(IntPtr node, float aspectRatio);
public static extern void YGNodeStyleSetAspectRatio(YGNodeHandle node, float aspectRatio);
[DllImport(DllName)]
public static extern float YGNodeStyleGetAspectRatio(IntPtr node);
public static extern float YGNodeStyleGetAspectRatio(YGNodeHandle node);
#endregion
#region YG_NODE_STYLE_EDGE_PROPERTY
[DllImport(DllName)]
public static extern void YGNodeStyleSetPosition(IntPtr node, YogaEdge edge, float position);
public static extern void YGNodeStyleSetPosition(YGNodeHandle node, YogaEdge edge, float position);
[DllImport(DllName)]
public static extern float YGNodeStyleGetPosition(IntPtr node, YogaEdge edge);
public static extern float YGNodeStyleGetPosition(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName)]
public static extern void YGNodeStyleSetMargin(IntPtr node, YogaEdge edge, float margin);
public static extern void YGNodeStyleSetMargin(YGNodeHandle node, YogaEdge edge, float margin);
[DllImport(DllName)]
public static extern float YGNodeStyleGetMargin(IntPtr node, YogaEdge edge);
public static extern float YGNodeStyleGetMargin(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName)]
public static extern void YGNodeStyleSetPadding(IntPtr node, YogaEdge edge, float padding);
public static extern void YGNodeStyleSetPadding(YGNodeHandle node, YogaEdge edge, float padding);
[DllImport(DllName)]
public static extern float YGNodeStyleGetPadding(IntPtr node, YogaEdge edge);
public static extern float YGNodeStyleGetPadding(YGNodeHandle node, YogaEdge edge);
[DllImport(DllName)]
public static extern void YGNodeStyleSetBorder(IntPtr node, YogaEdge edge, float border);
public static extern void YGNodeStyleSetBorder(YGNodeHandle node, YogaEdge edge, float border);
[DllImport(DllName)]
public static extern float YGNodeStyleGetBorder(IntPtr node, YogaEdge edge);
public static extern float YGNodeStyleGetBorder(YGNodeHandle node, YogaEdge edge);
#endregion
#region YG_NODE_LAYOUT_PROPERTY
[DllImport(DllName)]
public static extern float YGNodeLayoutGetLeft(IntPtr node);
public static extern float YGNodeLayoutGetLeft(YGNodeHandle node);
[DllImport(DllName)]
public static extern float YGNodeLayoutGetTop(IntPtr node);
public static extern float YGNodeLayoutGetTop(YGNodeHandle node);
[DllImport(DllName)]
public static extern float YGNodeLayoutGetRight(IntPtr node);
public static extern float YGNodeLayoutGetRight(YGNodeHandle node);
[DllImport(DllName)]
public static extern float YGNodeLayoutGetBottom(IntPtr node);
public static extern float YGNodeLayoutGetBottom(YGNodeHandle node);
[DllImport(DllName)]
public static extern float YGNodeLayoutGetWidth(IntPtr node);
public static extern float YGNodeLayoutGetWidth(YGNodeHandle node);
[DllImport(DllName)]
public static extern float YGNodeLayoutGetHeight(IntPtr node);
public static extern float YGNodeLayoutGetHeight(YGNodeHandle node);
[DllImport(DllName)]
public static extern YogaDirection YGNodeLayoutGetDirection(IntPtr node);
public static extern YogaDirection YGNodeLayoutGetDirection(YGNodeHandle node);
#endregion
}

View File

@@ -31,12 +31,12 @@ namespace Facebook.Yoga
Spacing margin = null,
Spacing padding = null,
Spacing border = null,
float? Width = null,
float? Height = null,
float? MaxWidth = null,
float? MaxHeight = null,
float? MinWidth = null,
float? MinHeight = null)
float? width = null,
float? height = null,
float? maxWidth = null,
float? maxHeight = null,
float? minWidth = null,
float? minHeight = null)
{
YogaNode node = new YogaNode();
@@ -197,34 +197,34 @@ namespace Facebook.Yoga
}
}
if (Width.HasValue)
if (width.HasValue)
{
node.Width = Width.Value;
node.Width = width.Value;
}
if (Height.HasValue)
if (height.HasValue)
{
node.Height = Height.Value;
node.Height = height.Value;
}
if (MinWidth.HasValue)
if (minWidth.HasValue)
{
node.MinWidth = MinWidth.Value;
node.MinWidth = minWidth.Value;
}
if (MinHeight.HasValue)
if (minHeight.HasValue)
{
node.MinHeight = MinHeight.Value;
node.MinHeight = minHeight.Value;
}
if (MaxWidth.HasValue)
if (maxWidth.HasValue)
{
node.MaxWidth = MaxWidth.Value;
node.MaxWidth = maxWidth.Value;
}
if (MaxHeight.HasValue)
if (maxHeight.HasValue)
{
node.MaxHeight = MaxHeight.Value;
node.MaxHeight = maxHeight.Value;
}
return node;

View File

@@ -17,7 +17,7 @@ namespace Facebook.Yoga
{
public partial class YogaNode : IEnumerable<YogaNode>
{
private IntPtr _ygNode;
private Native.YGNodeHandle _ygNode;
private WeakReference _parent;
private List<YogaNode> _children;
private MeasureFunction _measureFunction;
@@ -29,17 +29,12 @@ namespace Facebook.Yoga
YogaLogger.Initialize();
_ygNode = Native.YGNodeNew();
if (_ygNode == IntPtr.Zero)
if (_ygNode.IsInvalid)
{
throw new InvalidOperationException("Failed to allocate native memory");
}
}
~YogaNode()
{
Native.YGNodeFree(_ygNode);
}
public void Reset()
{
_measureFunction = null;
@@ -537,8 +532,7 @@ namespace Facebook.Yoga
throw new InvalidOperationException("Measure function is not defined.");
}
long output = _measureFunction(this, width, widthMode, height, heightMode);
return new YogaSize { width = MeasureOutput.GetWidth(output), height = MeasureOutput.GetHeight(output) };
return _measureFunction(this, width, widthMode, height, heightMode);
}
public string Print(YogaPrintOptions options =

View File

@@ -3,7 +3,8 @@
"version": "3.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6.0"
"NETStandard.Library": "1.6.0",
"System.Runtime.Handles": "4.3.0"
},
"frameworks": {

3
csharp/Unity/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
Yoga
yoga.dll
yoga.unitypackage

64
csharp/Unity/pack.sh Executable file
View File

@@ -0,0 +1,64 @@
#!/bin/sh
# Copyright (c) 2014-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.
set -e
cd "$( dirname "$0" )"
if [ \! -f yoga.dll ]; then
echo "Launch win.bat on Windows and copy yoga.dll to here"
exit 1
fi
function build {
buck build $1
echo "$root/`buck targets --show-output $1|tail -1|awk '{print $2}'`"
}
function copy {
mkdir -p $3
cp $1 $3/$2
}
rm -rf Yoga yoga.unitypackage
root=`buck root|tail -f`
mac=$(build '//csharp:yoganet#default,shared')
armv7=$(build '//csharp:yoganet#android-armv7,shared')
ios=$(build '//csharp:yoganet-ios')
win=yoga.dll
Unity -quit -batchMode -createProject Yoga
copy $win ${win##*/} Yoga/Assets/Facebook.Yoga/Plugins/x86_64
copy $mac yoga Yoga/Assets/Facebook.Yoga/Plugins/x86_64/yoga.bundle/Contents/MacOS
armv7path=Assets/Plugins/Android/libs/armeabi-v7a
copy $armv7 ${armv7##*/} Yoga/$armv7path
iospath=Assets/Plugins/iOS
copy $ios ${ios##*/} Yoga/$iospath
libs="$armv7path/${armv7##*/} $iospath/${ios##*/}"
scripts=Yoga/Assets/Facebook.Yoga/Scripts/Facebook.Yoga
mkdir -p $scripts
(cd ../Facebook.Yoga; tar cf - *.cs)|tar -C $scripts -xf -
tests=Yoga/Assets/Facebook.Yoga/Editor/Facebook.Yoga.Tests
mkdir -p $tests
(cd ../tests/Facebook.Yoga; tar cf - *.cs)|tar -C $tests -xf -
function onerror {
local xml=Yoga/EditorTestResults.xml
if [ -f $xml ]; then cat $xml|grep 'success="False"'; fi
}
trap onerror EXIT
Unity -quit -batchMode -projectPath `pwd`/Yoga -runEditorTests
pkg="`pwd`/yoga.unitypackage"
Unity -quit -batchMode -projectPath `pwd`/Yoga -exportPackage Assets/Facebook.Yoga $libs $pkg
echo "Success: $pkg"

2
csharp/Unity/win.bat Executable file
View File

@@ -0,0 +1,2 @@
"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" ..\Yoga\Yoga.vcxproj /p:configuration=Release /property:Platform=x64
xcopy "..\Yoga\x64\Release\yoga.dll" %~dp0 /s /d /y

View File

@@ -21,6 +21,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{0446C86B-F47B-4C46-B673-C7AE0CFF35D5}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<ProjectName>yoga</ProjectName>
<RootNamespace>Yoga</RootNamespace>
<WindowsTargetPlatformVersion>10.0.14393.0</WindowsTargetPlatformVersion>
</PropertyGroup>

View File

@@ -454,5 +454,226 @@ namespace Facebook.Yoga
Assert.AreEqual(20f, root_child0_child0.LayoutHeight);
}
[Test]
public void Test_flex_grow_within_constrained_min_row()
{
YogaNode root = new YogaNode();
root.FlexDirection = YogaFlexDirection.Row;
root.MinWidth = 100f;
root.Height = 100f;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Width = 50f;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(50f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(50f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(50f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(0f, root_child1.LayoutY);
Assert.AreEqual(50f, root_child1.LayoutWidth);
Assert.AreEqual(100f, root_child1.LayoutHeight);
}
[Test]
public void Test_flex_grow_within_constrained_min_column()
{
YogaNode root = new YogaNode();
root.MinHeight = 100f;
YogaNode root_child0 = new YogaNode();
root_child0.FlexGrow = 1f;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 50f;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(0f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(0f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(0f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(0f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(0f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
}
[Test]
public void Test_flex_grow_within_constrained_max_row()
{
YogaNode root = new YogaNode();
root.Width = 200f;
YogaNode root_child0 = new YogaNode();
root_child0.FlexDirection = YogaFlexDirection.Row;
root_child0.MaxWidth = 100f;
root_child0.Height = 100f;
root.Insert(0, root_child0);
YogaNode root_child0_child0 = new YogaNode();
root_child0_child0.FlexShrink = 1f;
root_child0_child0.FlexBasis = 100f;
root_child0.Insert(0, root_child0_child0);
YogaNode root_child0_child1 = new YogaNode();
root_child0_child1.Width = 50f;
root_child0.Insert(1, root_child0_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(50f, root_child0_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
Assert.AreEqual(50f, root_child0_child1.LayoutX);
Assert.AreEqual(0f, root_child0_child1.LayoutY);
Assert.AreEqual(50f, root_child0_child1.LayoutWidth);
Assert.AreEqual(100f, root_child0_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(200f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(100f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0.LayoutHeight);
Assert.AreEqual(50f, root_child0_child0.LayoutX);
Assert.AreEqual(0f, root_child0_child0.LayoutY);
Assert.AreEqual(50f, root_child0_child0.LayoutWidth);
Assert.AreEqual(100f, root_child0_child0.LayoutHeight);
Assert.AreEqual(0f, root_child0_child1.LayoutX);
Assert.AreEqual(0f, root_child0_child1.LayoutY);
Assert.AreEqual(50f, root_child0_child1.LayoutWidth);
Assert.AreEqual(100f, root_child0_child1.LayoutHeight);
}
[Test]
public void Test_flex_grow_within_constrained_max_column()
{
YogaNode root = new YogaNode();
root.Width = 100f;
root.MaxHeight = 100f;
YogaNode root_child0 = new YogaNode();
root_child0.FlexShrink = 1f;
root_child0.FlexBasis = 100f;
root.Insert(0, root_child0);
YogaNode root_child1 = new YogaNode();
root_child1.Height = 50f;
root.Insert(1, root_child1);
root.StyleDirection = YogaDirection.LTR;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
root.StyleDirection = YogaDirection.RTL;
root.CalculateLayout();
Assert.AreEqual(0f, root.LayoutX);
Assert.AreEqual(0f, root.LayoutY);
Assert.AreEqual(100f, root.LayoutWidth);
Assert.AreEqual(100f, root.LayoutHeight);
Assert.AreEqual(0f, root_child0.LayoutX);
Assert.AreEqual(0f, root_child0.LayoutY);
Assert.AreEqual(100f, root_child0.LayoutWidth);
Assert.AreEqual(50f, root_child0.LayoutHeight);
Assert.AreEqual(0f, root_child1.LayoutX);
Assert.AreEqual(50f, root_child1.LayoutY);
Assert.AreEqual(100f, root_child1.LayoutWidth);
Assert.AreEqual(50f, root_child1.LayoutHeight);
}
}
}

View File

@@ -87,12 +87,12 @@ namespace Facebook.Yoga
padding: new Spacing(top: 13, bottom: 14, left: 15, right: 16),
border: new Spacing(top: 17, bottom: 18, left: 19, right: 20),
Width: 21,
Height: 22,
MinWidth: 23,
MinHeight: 24,
MaxWidth: 25,
MaxHeight: 26);
width: 21,
height: 22,
minWidth: 23,
minHeight: 24,
maxWidth: 25,
maxHeight: 26);
Assert.AreEqual(YogaDirection.RTL, node.StyleDirection);
Assert.AreEqual(YogaFlexDirection.RowReverse, node.FlexDirection);

View File

@@ -169,8 +169,8 @@ namespace Facebook.Yoga
return MeasureOutput.Make(123.4f, 81.7f);
});
node.CalculateLayout();
Assert.AreEqual(123, node.LayoutWidth);
Assert.AreEqual(81, node.LayoutHeight);
Assert.AreEqual(123.4f, node.LayoutWidth);
Assert.AreEqual(81.7f, node.LayoutHeight);
}
[Test]
@@ -228,7 +228,6 @@ namespace Facebook.Yoga
Assert.AreEqual(100, node0.MaxHeight);
}
#if !UNITY_EDITOR
private void ForceGC()
{
GC.Collect(GC.MaxGeneration);
@@ -356,6 +355,5 @@ namespace Facebook.Yoga
return MeasureOutput.Make(120, 130);
});
}
#endif
}
}

View File

@@ -1,16 +1,6 @@
#!/bin/sh
if clang --version >/dev/null 2>&1; then true; else
echo "ERROR: Can't execute clang. You need to install Xcode and command line tools."
exit 1
fi
if mcs --version >/dev/null 2>&1; then true; else
echo "ERROR: Can't execute mcs. You need to install Mono from http://www.mono-project.com/download/ and re-login to apply PATH environment."
exit 1
fi
if mono --version >/dev/null 2>&1; then true; else
echo "ERROR: Can't execute mono64. You need to install Mono from http://www.mono-project.com/download/ and re-login to apply PATH environment."
if mcs --version >/dev/null 2>&1 && mono --version >/dev/null 2>&1; then true; else
echo "ERROR: Need to install Mono (brew install mono, or http://www.mono-project.com/download/)"
exit 1
fi
@@ -28,6 +18,11 @@ if [ -d $NUNIT \
rm NUnit-2.6.4.zip
fi
clang -g -Wall -Wextra -dynamiclib -o libyoga.dylib -I../../.. ../../../yoga/*.c ../../Yoga/YGInterop.cpp
TARGET=//csharp:yoganet#default,shared
buck build $TARGET
ROOT=`buck root|tail -1`
DYLIB=`buck targets --show-output $TARGET|tail -1|awk '{print $2}'`
cp $ROOT/$DYLIB .
mcs -debug -t:library -r:$NUNIT/nunit.framework.dll -out:YogaTest.dll *.cs ../../../csharp/Facebook.Yoga/*cs
MONO_PATH=$NUNIT mono --arch=64 --debug $NUNIT/nunit-console.exe YogaTest.dll

6
docs/.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
_site/
.sass-cache/
.DS_STORE
*.swo
*.swp
*.psd

115
docs/CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,115 @@
This provides guidance on how to contribute various content to `your-site`.
## Getting started
You should only have to do these one time.
- Rename this file to `CONTRIBUTING.md`.
- Rename `EXAMPLE-README-FOR-RUNNING-DOCS.md` to `README.md` (replacing the existing `README.md` that came with the template).
- Rename `EXAMPLE-LICENSE` to `LICENSE`.
- Review the [template information](./TEMPLATE-INFORMATION.md).
- Review `./_config.yml`.
- Make sure you update `title`, `description`, `tagline` and `gacode` (Google Analytics) in `./_config.yml`.
## Basic Structure
Most content is written in markdown. You name the file `something.md`, then have a header that looks like this:
```
---
docid: getting-started
title: Getting started with ProjectName
layout: docs
permalink: /docs/getting-started.html
---
```
Customize these values for each document, blog post, etc.
> The filename of the `.md` file doesn't actually matter; what is important is the `docid` being unique and the `permalink` correct and unique too).
## Landing page
Modify `index.md` with your new or updated content.
If you want a `GridBlock` as part of your content, you can do so directly with HTML:
```
<div class="gridBlock">
<div class="blockElement twoByGridBlock alignLeft">
<div class="blockContent">
<h3>Your Features</h3>
<ul>
<li>The <a href="http://example.org/">Example</a></li>
<li><a href="http://example.com">Another Example</a></li>
</ul>
</div>
</div>
<div class="blockElement twoByGridBlock alignLeft">
<div class="blockContent">
<h3>More information</h3>
<p>
Stuff here
</p>
</div>
</div>
</div>
```
or with a combination of changing `./_data/features.yml` and adding some Liquid to `index.md`, such as:
```
{% include content/gridblocks.html data_source=site.data.features imagealign="bottom"%}
```
## Blog
To modify a blog post, edit the appopriate markdown file in `./_posts/`.
Adding a new blog post is a four-step process.
> Some posts have a `permalink` and `comments` in the blog post YAML header. You will not need these for new blog posts. These are an artifact of migrating the blog from Wordpress to gh-pages.
1. Create your blog post in `./_posts/` in markdown (file extension `.md` or `.markdown`). See current posts in that folder or `./doc-type-examples/2016-04-07-blog-post-example.md` for an example of the YAML format. **If the `./_posts` directory does not exist, create it**.
- You can add a `<!--truncate-->` tag in the middle of your post such that you show only the excerpt above that tag in the main `/blog` index on your page.
1. If you have not authored a blog post before, modify the `./_data/authors.yml` file with the `author` id you used in your blog post, along with your full name and Facebook ID to get your profile picture.
1. [Run the site locally](./README.md) to test your changes. It will be at `http://127.0.0.1/blog/your-new-blog-post-title.html`
1. Push your changes to GitHub.
## Docs
To modify docs, edit the appropriate markdown file in `./_docs/`.
To add docs to the site....
1. Add your markdown file to the `./_docs/` folder. See `./doc-type-examples/docs-hello-world.md` for an example of the YAML header format. **If the `./_docs/` directory does not exist, create it**.
- You can use folders in the `./_docs/` directory to organize your content if you want.
1. Update `_data/nav_docs.yml` to add your new document to the navigation bar. Use the `docid` you put in your doc markdown in as the `id` in the `_data/nav_docs.yml` file.
1. [Run the site locally](./README.md) to test your changes. It will be at `http://127.0.0.1/docs/your-new-doc-permalink.html`
1. Push your changes to GitHub.
## Header Bar
To modify the header bar, change `./_data/nav.yml`.
## Top Level Page
To modify a top-level page, edit the appropriate markdown file in `./top-level/`
If you want a top-level page (e.g., http://your-site.com/top-level.html) -- not in `/blog/` or `/docs/`....
1. Create a markdown file in the root `./top-level/`. See `./doc-type-examples/top-level-example.md` for more information.
1. If you want a visible link to that file, update `_data/nav.yml` to add a link to your new top-level document in the header bar.
> This is not necessary if you just want to have a page that is linked to from another page, but not exposed as direct link to the user.
1. [Run the site locally](./README.md) to test your changes. It will be at `http://127.0.0.1/your-top-level-page-permalink.html`
1. Push your changes to GitHub.
## Other Changes
- CSS: `./css/main.css` or `./_sass/*.scss`.
- Images: `./static/images/[docs | posts]/....`
- Main Blog post HTML: `./_includes/post.html`
- Main Docs HTML: `./_includes/doc.html`

2
docs/Gemfile Normal file
View File

@@ -0,0 +1,2 @@
source 'https://rubygems.org'
gem 'github-pages', '~> 104'

145
docs/Gemfile.lock Normal file
View File

@@ -0,0 +1,145 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (4.2.7)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.10.0)
colorator (1.1.0)
ethon (0.9.1)
ffi (>= 1.3.0)
execjs (2.7.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
ffi (1.9.14)
forwardable-extended (2.6.0)
gemoji (2.1.0)
github-pages (104)
activesupport (= 4.2.7)
github-pages-health-check (= 1.2.0)
jekyll (= 3.3.0)
jekyll-avatar (= 0.4.2)
jekyll-coffeescript (= 1.0.1)
jekyll-feed (= 0.8.0)
jekyll-gist (= 1.4.0)
jekyll-github-metadata (= 2.2.0)
jekyll-mentions (= 1.2.0)
jekyll-paginate (= 1.1.0)
jekyll-redirect-from (= 0.11.0)
jekyll-sass-converter (= 1.3.0)
jekyll-seo-tag (= 2.1.0)
jekyll-sitemap (= 0.12.0)
jekyll-swiss (= 0.4.0)
jemoji (= 0.7.0)
kramdown (= 1.11.1)
liquid (= 3.0.6)
listen (= 3.0.6)
mercenary (~> 0.3)
minima (= 2.0.0)
rouge (= 1.11.1)
terminal-table (~> 1.4)
github-pages-health-check (1.2.0)
addressable (~> 2.3)
net-dns (~> 0.8)
octokit (~> 4.0)
public_suffix (~> 1.4)
typhoeus (~> 0.7)
html-pipeline (2.4.2)
activesupport (>= 2)
nokogiri (>= 1.4)
i18n (0.7.0)
jekyll (3.3.0)
addressable (~> 2.4)
colorator (~> 1.0)
jekyll-sass-converter (~> 1.0)
jekyll-watch (~> 1.1)
kramdown (~> 1.3)
liquid (~> 3.0)
mercenary (~> 0.3.3)
pathutil (~> 0.9)
rouge (~> 1.7)
safe_yaml (~> 1.0)
jekyll-avatar (0.4.2)
jekyll (~> 3.0)
jekyll-coffeescript (1.0.1)
coffee-script (~> 2.2)
jekyll-feed (0.8.0)
jekyll (~> 3.3)
jekyll-gist (1.4.0)
octokit (~> 4.2)
jekyll-github-metadata (2.2.0)
jekyll (~> 3.1)
octokit (~> 4.0, != 4.4.0)
jekyll-mentions (1.2.0)
activesupport (~> 4.0)
html-pipeline (~> 2.3)
jekyll (~> 3.0)
jekyll-paginate (1.1.0)
jekyll-redirect-from (0.11.0)
jekyll (>= 2.0)
jekyll-sass-converter (1.3.0)
sass (~> 3.2)
jekyll-seo-tag (2.1.0)
jekyll (~> 3.3)
jekyll-sitemap (0.12.0)
jekyll (~> 3.3)
jekyll-swiss (0.4.0)
jekyll-watch (1.5.0)
listen (~> 3.0, < 3.1)
jemoji (0.7.0)
activesupport (~> 4.0)
gemoji (~> 2.0)
html-pipeline (~> 2.2)
jekyll (>= 3.0)
json (1.8.3)
kramdown (1.11.1)
liquid (3.0.6)
listen (3.0.6)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9.7)
mercenary (0.3.6)
mini_portile2 (2.1.0)
minima (2.0.0)
minitest (5.9.1)
multipart-post (2.0.0)
net-dns (0.8.0)
nokogiri (1.6.8.1)
mini_portile2 (~> 2.1.0)
octokit (4.4.1)
sawyer (~> 0.7.0, >= 0.5.3)
pathutil (0.14.0)
forwardable-extended (~> 2.6)
public_suffix (1.5.3)
rb-fsevent (0.9.8)
rb-inotify (0.9.7)
ffi (>= 0.5.0)
rouge (1.11.1)
safe_yaml (1.0.4)
sass (3.4.22)
sawyer (0.7.0)
addressable (>= 2.3.5, < 2.5)
faraday (~> 0.8, < 0.10)
terminal-table (1.7.3)
unicode-display_width (~> 1.1.1)
thread_safe (0.3.5)
typhoeus (0.8.0)
ethon (>= 0.8.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
unicode-display_width (1.1.1)
PLATFORMS
ruby
DEPENDENCIES
github-pages (~> 104)
BUNDLED WITH
1.13.1

385
docs/LICENSE Normal file
View File

@@ -0,0 +1,385 @@
Attribution 4.0 International
=======================================================================
Creative Commons Corporation ("Creative Commons") is not a law firm and
does not provide legal services or legal advice. Distribution of
Creative Commons public licenses does not create a lawyer-client or
other relationship. Creative Commons makes its licenses and related
information available on an "as-is" basis. Creative Commons gives no
warranties regarding its licenses, any material licensed under their
terms and conditions, or any related information. Creative Commons
disclaims all liability for damages resulting from their use to the
fullest extent possible.
Using Creative Commons Public Licenses
Creative Commons public licenses provide a standard set of terms and
conditions that creators and other rights holders may use to share
original works of authorship and other material subject to copyright
and certain other rights specified in the public license below. The
following considerations are for informational purposes only, are not
exhaustive, and do not form part of our licenses.
Considerations for licensors: Our public licenses are
intended for use by those authorized to give the public
permission to use material in ways otherwise restricted by
copyright and certain other rights. Our licenses are
irrevocable. Licensors should read and understand the terms
and conditions of the license they choose before applying it.
Licensors should also secure all rights necessary before
applying our licenses so that the public can reuse the
material as expected. Licensors should clearly mark any
material not subject to the license. This includes other CC-
licensed material, or material used under an exception or
limitation to copyright. More considerations for licensors:
wiki.creativecommons.org/Considerations_for_licensors
Considerations for the public: By using one of our public
licenses, a licensor grants the public permission to use the
licensed material under specified terms and conditions. If
the licensor's permission is not necessary for any reason--for
example, because of any applicable exception or limitation to
copyright--then that use is not regulated by the license. Our
licenses grant only permissions under copyright and certain
other rights that a licensor has authority to grant. Use of
the licensed material may still be restricted for other
reasons, including because others have copyright or other
rights in the material. A licensor may make special requests,
such as asking that all changes be marked or described.
Although not required by our licenses, you are encouraged to
respect those requests where reasonable. More_considerations
for the public:
wiki.creativecommons.org/Considerations_for_licensees
=======================================================================
Creative Commons Attribution 4.0 International Public License
By exercising the Licensed Rights (defined below), You accept and agree
to be bound by the terms and conditions of this Creative Commons
Attribution 4.0 International Public License ("Public License"). To the
extent this Public License may be interpreted as a contract, You are
granted the Licensed Rights in consideration of Your acceptance of
these terms and conditions, and the Licensor grants You such rights in
consideration of benefits the Licensor receives from making the
Licensed Material available under these terms and conditions.
Section 1 -- Definitions.
a. Adapted Material means material subject to Copyright and Similar
Rights that is derived from or based upon the Licensed Material
and in which the Licensed Material is translated, altered,
arranged, transformed, or otherwise modified in a manner requiring
permission under the Copyright and Similar Rights held by the
Licensor. For purposes of this Public License, where the Licensed
Material is a musical work, performance, or sound recording,
Adapted Material is always produced where the Licensed Material is
synched in timed relation with a moving image.
b. Adapter's License means the license You apply to Your Copyright
and Similar Rights in Your contributions to Adapted Material in
accordance with the terms and conditions of this Public License.
c. Copyright and Similar Rights means copyright and/or similar rights
closely related to copyright including, without limitation,
performance, broadcast, sound recording, and Sui Generis Database
Rights, without regard to how the rights are labeled or
categorized. For purposes of this Public License, the rights
specified in Section 2(b)(1)-(2) are not Copyright and Similar
Rights.
d. Effective Technological Measures means those measures that, in the
absence of proper authority, may not be circumvented under laws
fulfilling obligations under Article 11 of the WIPO Copyright
Treaty adopted on December 20, 1996, and/or similar international
agreements.
e. Exceptions and Limitations means fair use, fair dealing, and/or
any other exception or limitation to Copyright and Similar Rights
that applies to Your use of the Licensed Material.
f. Licensed Material means the artistic or literary work, database,
or other material to which the Licensor applied this Public
License.
g. Licensed Rights means the rights granted to You subject to the
terms and conditions of this Public License, which are limited to
all Copyright and Similar Rights that apply to Your use of the
Licensed Material and that the Licensor has authority to license.
h. Licensor means the individual(s) or entity(ies) granting rights
under this Public License.
i. Share means to provide material to the public by any means or
process that requires permission under the Licensed Rights, such
as reproduction, public display, public performance, distribution,
dissemination, communication, or importation, and to make material
available to the public including in ways that members of the
public may access the material from a place and at a time
individually chosen by them.
j. Sui Generis Database Rights means rights other than copyright
resulting from Directive 96/9/EC of the European Parliament and of
the Council of 11 March 1996 on the legal protection of databases,
as amended and/or succeeded, as well as other essentially
equivalent rights anywhere in the world.
k. You means the individual or entity exercising the Licensed Rights
under this Public License. Your has a corresponding meaning.
Section 2 -- Scope.
a. License grant.
1. Subject to the terms and conditions of this Public License,
the Licensor hereby grants You a worldwide, royalty-free,
non-sublicensable, non-exclusive, irrevocable license to
exercise the Licensed Rights in the Licensed Material to:
a. reproduce and Share the Licensed Material, in whole or
in part; and
b. produce, reproduce, and Share Adapted Material.
2. Exceptions and Limitations. For the avoidance of doubt, where
Exceptions and Limitations apply to Your use, this Public
License does not apply, and You do not need to comply with
its terms and conditions.
3. Term. The term of this Public License is specified in Section
6(a).
4. Media and formats; technical modifications allowed. The
Licensor authorizes You to exercise the Licensed Rights in
all media and formats whether now known or hereafter created,
and to make technical modifications necessary to do so. The
Licensor waives and/or agrees not to assert any right or
authority to forbid You from making technical modifications
necessary to exercise the Licensed Rights, including
technical modifications necessary to circumvent Effective
Technological Measures. For purposes of this Public License,
simply making modifications authorized by this Section 2(a)
(4) never produces Adapted Material.
5. Downstream recipients.
a. Offer from the Licensor -- Licensed Material. Every
recipient of the Licensed Material automatically
receives an offer from the Licensor to exercise the
Licensed Rights under the terms and conditions of this
Public License.
b. No downstream restrictions. You may not offer or impose
any additional or different terms or conditions on, or
apply any Effective Technological Measures to, the
Licensed Material if doing so restricts exercise of the
Licensed Rights by any recipient of the Licensed
Material.
6. No endorsement. Nothing in this Public License constitutes or
may be construed as permission to assert or imply that You
are, or that Your use of the Licensed Material is, connected
with, or sponsored, endorsed, or granted official status by,
the Licensor or others designated to receive attribution as
provided in Section 3(a)(1)(A)(i).
b. Other rights.
1. Moral rights, such as the right of integrity, are not
licensed under this Public License, nor are publicity,
privacy, and/or other similar personality rights; however, to
the extent possible, the Licensor waives and/or agrees not to
assert any such rights held by the Licensor to the limited
extent necessary to allow You to exercise the Licensed
Rights, but not otherwise.
2. Patent and trademark rights are not licensed under this
Public License.
3. To the extent possible, the Licensor waives any right to
collect royalties from You for the exercise of the Licensed
Rights, whether directly or through a collecting society
under any voluntary or waivable statutory or compulsory
licensing scheme. In all other cases the Licensor expressly
reserves any right to collect such royalties.
Section 3 -- License Conditions.
Your exercise of the Licensed Rights is expressly made subject to the
following conditions.
a. Attribution.
1. If You Share the Licensed Material (including in modified
form), You must:
a. retain the following if it is supplied by the Licensor
with the Licensed Material:
i. identification of the creator(s) of the Licensed
Material and any others designated to receive
attribution, in any reasonable manner requested by
the Licensor (including by pseudonym if
designated);
ii. a copyright notice;
iii. a notice that refers to this Public License;
iv. a notice that refers to the disclaimer of
warranties;
v. a URI or hyperlink to the Licensed Material to the
extent reasonably practicable;
b. indicate if You modified the Licensed Material and
retain an indication of any previous modifications; and
c. indicate the Licensed Material is licensed under this
Public License, and include the text of, or the URI or
hyperlink to, this Public License.
2. You may satisfy the conditions in Section 3(a)(1) in any
reasonable manner based on the medium, means, and context in
which You Share the Licensed Material. For example, it may be
reasonable to satisfy the conditions by providing a URI or
hyperlink to a resource that includes the required
information.
3. If requested by the Licensor, You must remove any of the
information required by Section 3(a)(1)(A) to the extent
reasonably practicable.
4. If You Share Adapted Material You produce, the Adapter's
License You apply must not prevent recipients of the Adapted
Material from complying with this Public License.
Section 4 -- Sui Generis Database Rights.
Where the Licensed Rights include Sui Generis Database Rights that
apply to Your use of the Licensed Material:
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
to extract, reuse, reproduce, and Share all or a substantial
portion of the contents of the database;
b. if You include all or a substantial portion of the database
contents in a database in which You have Sui Generis Database
Rights, then the database in which You have Sui Generis Database
Rights (but not its individual contents) is Adapted Material; and
c. You must comply with the conditions in Section 3(a) if You Share
all or a substantial portion of the contents of the database.
For the avoidance of doubt, this Section 4 supplements and does not
replace Your obligations under this Public License where the Licensed
Rights include other Copyright and Similar Rights.
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
c. The disclaimer of warranties and limitation of liability provided
above shall be interpreted in a manner that, to the extent
possible, most closely approximates an absolute disclaimer and
waiver of all liability.
Section 6 -- Term and Termination.
a. This Public License applies for the term of the Copyright and
Similar Rights licensed here. However, if You fail to comply with
this Public License, then Your rights under this Public License
terminate automatically.
b. Where Your right to use the Licensed Material has terminated under
Section 6(a), it reinstates:
1. automatically as of the date the violation is cured, provided
it is cured within 30 days of Your discovery of the
violation; or
2. upon express reinstatement by the Licensor.
For the avoidance of doubt, this Section 6(b) does not affect any
right the Licensor may have to seek remedies for Your violations
of this Public License.
c. For the avoidance of doubt, the Licensor may also offer the
Licensed Material under separate terms or conditions or stop
distributing the Licensed Material at any time; however, doing so
will not terminate this Public License.
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
License.
Section 7 -- Other Terms and Conditions.
a. The Licensor shall not be bound by any additional or different
terms or conditions communicated by You unless expressly agreed.
b. Any arrangements, understandings, or agreements regarding the
Licensed Material not stated herein are separate from and
independent of the terms and conditions of this Public License.
Section 8 -- Interpretation.
a. For the avoidance of doubt, this Public License does not, and
shall not be interpreted to, reduce, limit, restrict, or impose
conditions on any use of the Licensed Material that could lawfully
be made without permission under this Public License.
b. To the extent possible, if any provision of this Public License is
deemed unenforceable, it shall be automatically reformed to the
minimum extent necessary to make it enforceable. If the provision
cannot be reformed, it shall be severed from this Public License
without affecting the enforceability of the remaining terms and
conditions.
c. No term or condition of this Public License will be waived and no
failure to comply consented to unless expressly agreed to by the
Licensor.
d. Nothing in this Public License constitutes or may be interpreted
as a limitation upon, or waiver of, any privileges and immunities
that apply to the Licensor or You, including from the legal
processes of any jurisdiction or authority.
=======================================================================
Creative Commons is not a party to its public licenses.
Notwithstanding, Creative Commons may elect to apply one of its public
licenses to material it publishes and in those instances will be
considered the "Licensor." Except for the limited purpose of indicating
that material is shared under a Creative Commons public license or as
otherwise permitted by the Creative Commons policies published at
creativecommons.org/policies, Creative Commons does not authorize the
use of the trademark "Creative Commons" or any other trademark or logo
of Creative Commons without its prior written consent including,
without limitation, in connection with any unauthorized modifications
to any of its public licenses or any other arrangements,
understandings, or agreements concerning use of licensed material. For
the avoidance of doubt, this paragraph does not form part of the public
licenses.
Creative Commons may be contacted at creativecommons.org.

80
docs/README.md Normal file
View File

@@ -0,0 +1,80 @@
## User Documentation for Yoga
This directory will contain the user, feature and API documentation for Yoga. The documentation will be hosted on GitHub pages.
### Contributing
See [CONTRIBUTING.md](./CONTRIBUTING.md) for details on how to add or modify content.
### Run the Site Locally
The requirements for running a GitHub pages site locally is described in [GitHub help](https://help.github.com/articles/setting-up-your-github-pages-site-locally-with-jekyll/#requirements). The steps below summarize these steps.
> If you have run the site before, you can start with step 1 and then move on to step 5.
1. Ensure that you are in the same directory where this `README.md` exists (e.g., it could be in `yoga/docs` on `master`, in the root of a `gh-pages` branch, etc). The below RubyGems commands, etc. must be run from there.
1. Make sure you have Ruby and [RubyGems](https://rubygems.org/) installed.
> Ruby >= 2.2 is required for the gems. On the latest versions of Mac OS X, Ruby 2.0 is the
> default. Use [Homebrew](http://brew.sh) and the `brew install ruby` command (or your
> preferred upgrade mechanism) to install a newer version of Ruby for your Mac OS X system.
1. Make sure you have [Bundler](http://bundler.io/) installed.
```
# may require sudo
gem install bundler
```
1. Install the project's dependencies
```
# run this in the 'docs' directory
bundle install
```
> If you get an error when installing `nokogiri`, you may be running into the problem described
> in [this nokogiri issue](https://github.com/sparklemotion/nokogiri/issues/1483). You can
> either `brew uninstall xz` (and then `brew install xz` after the bundle is installed) or
> `xcode-select --install` (although this may not work if you have already installed command
> line tools).
1. Run Jekyll's server.
- On first runs or for structural changes to the documentation (e.g., new sidebar menu item), do a full build.
```
bundle exec jekyll serve
```
- For content changes only, you can use `--incremental` for faster builds.
```
bundle exec jekyll serve --incremental
```
> We use `bundle exec` instead of running straight `jekyll` because `bundle exec` will always use the version of Jekyll from our `Gemfile`. Just running `jekyll` will use the system version and may not necessarily be compatible.
- To run using an actual IP address, you can use `--host=0.0.0.0`
```
bundle exec jekyll serve --host=0.0.0.0
```
This will allow you to use the IP address associated with your machine in the URL. That way you could share it with other people.
e.g., on a Mac, you can your IP address with something like `ifconfig | grep "inet " | grep -v 127.0.0.1`.
1. Either of commands in the previous step will serve up the site on your local device at http://127.0.0.1:4000/ or http://localhost:4000.
### Updating the Bundle
The site depends on Github Pages and the installed bundle is based on the `github-pages` gem.
Occasionally that gem might get updated with new or changed functionality. If that is the case,
you can run:
```
bundle update
```
to get the latest packages for the installation.

View File

@@ -0,0 +1,17 @@
## Template Details
First, go through `_config.yml` and adjust the available settings to your project's standard. When you make changes here, you'll have to kill the `jekyll serve` instance and restart it to see those changes, but that's only the case with the config file.
Next, update some image assets - you'll want to update `favicon.png`, `logo.svg`, and `og_image.png` (used for Like button stories and Shares on Facbeook) in the `static` folder with your own logos.
Next, if you're going to have docs on your site, keep the `_docs` and `docs` folders, if not, you can safely remove them (or you can safely leave them and not include them in your navigation - Jekyll renders all of this before a client views the site anyway, so there's no performance hit from just leaving it there for a future expansion).
Same thing with a blog section, either keep or delete the `_posts` and `blog` folders.
You can customize your homepage in three parts - the first in the homepage header, which is mostly automatically derived from the elements you insert into your config file. However, you can also specify a series of 'promotional' elements in `_data/promo.yml`. You can read that file for more information.
The second place for your homepage is in `index.md` which contains the bulk of the main content below the header. This is all markdown if you want, but you can use HTML and Jekyll's template tags (called Liquid) in there too. Checkout this folder's index.md for an example of one common template tag that we use on our sites called gridblocks.
The third and last place is in the `_data/powered_by.yml` and `_data/powered_by_highlight.yml` files. Both these files combine to create a section on the homepage that is intended to show a list of companies or apps that are using your project. The `powered_by_highlight` file is a list of curated companies/apps that you want to show as a highlight at the top of this section, including their logos in whatever format you want. The `powered_by` file is a more open list that is just text links to the companies/apps and can be updated via Pull Request by the community. If you don't want these sections on your homepage, just empty out both files and leave them blank.
The last thing you'll want to do is setup your top level navigation bar. You can do this by editing `nav.yml` and keeping the existing title/href/category structure used there. Although the nav is responsive and fairly flexible design-wise, no more than 5 or 6 nav items is recommended.

85
docs/_config.yml Normal file
View File

@@ -0,0 +1,85 @@
# Site settings
permalink: /blog/:year/:month/:day/:title.html
title: YOGA
tagline: A cross-platform layout engine
fbappid: "1615782811974223"
gacode: "UA-12345-6"
# baseurl determines the subpath of your site. For example if you're using an
# organisation.github.io/reponame/ basic site URL, then baseurl would be set
# as "/reponame" but leave blank if you have a top-level domain URL as it is
# now set to "" by default as discussed in:
# http://jekyllrb.com/news/2016/10/06/jekyll-3-3-is-here/
baseurl: "/yoga"
# the base hostname & protocol for your site
# If baseurl is set, then the absolute url for your site would be url/baseurl
# This was also be set to the right thing automatically for local development
# https://github.com/blog/2277-what-s-new-in-github-pages-with-jekyll-3-3
# http://jekyllrb.com/news/2016/10/06/jekyll-3-3-is-here/
url: "https://facebook.github.io"
# Note: There are new filters in Jekyll 3.3 to help with absolute and relative urls
# absolute_url
# relative_url
# So you will see these used throughout the Jekyll code in this template.
# no more need for | prepend: site.url | prepend: site.baseurl
# http://jekyllrb.com/news/2016/10/06/jekyll-3-3-is-here/
#https://github.com/blog/2277-what-s-new-in-github-pages-with-jekyll-3-3
# The GitHub repo for your project
ghrepo: "facebook/yoga"
# Use these color settings to determine your colour scheme for the site.
color:
# primary should be a vivid color that reflects the project's brand
primary: "#97dccf"
# secondary should be a subtle light or dark color used on page backgrounds
secondary: "#ffffff"
# Use the following to specify whether the previous two colours are 'light'
# or 'dark' and therefore what colors can be overlaid on them
primary-overlay: "light"
secondary-overlay: "light"
#Uncomment this if you want to enable Algolia doc search with your own values
searchconfig:
apikey: "48f81041f782ed6463719d8d98c94f38"
indexname: "yoga"
# Blog posts are built into Jekyll by default, with the `_posts` directory.
# Here you can specify other types of documentation. The names here are `docs`
# and `top-level`. This means their content will be in `_docs` and `_top-level`.
# The permalink format is also given.
# http://ben.balter.com/2015/02/20/jekyll-collections/
collections:
docs:
output: true
permalink: /docs/:name/
top-level:
output: true
permalink: :name.html
# DO NOT ADJUST BELOW THIS LINE UNLESS YOU KNOW WHAT YOU ARE CHANGING
markdown: kramdown
kramdown:
input: GFM
syntax_highlighter: rouge
syntax_highlighter_opts:
css_class: 'rougeHighlight'
span:
line_numbers: false
block:
line_numbers: true
start_line: 1
sass:
style: :compressed
redcarpet:
extensions: [with_toc_data]
# Exclude these from the sites directory
exclude: ['README.md', 'TEMPLATE-INFORMATION.md', 'CONTRIBUTING.md', 'Gemfile', 'Gemfile.lock']

4
docs/_data/authors.yml Normal file
View File

@@ -0,0 +1,4 @@
exampleauthor:
full_name: Example Author
fbid: 1234

2
docs/_data/features.yml Normal file
View File

@@ -0,0 +1,2 @@
# Add features here if you are using:
# {% include content/gridblocks.html data_source=site.data.features align="center" %}

10
docs/_data/nav.yml Normal file
View File

@@ -0,0 +1,10 @@
- title: Documentation
href: docs/
category: api
- title: GitHub
href: https://github.com/facebook/yoga
category: external
# Use external for external links not associated with the paths of the current site.
# If a category is external, site urls, for example, are not prepended to the href, etc..

24
docs/_data/nav_docs.yml Normal file
View File

@@ -0,0 +1,24 @@
- title: Quick Start
items:
- id: getting-started
- id: learn-more
- title: Flexbox concepts
items:
- id: flex-direction
- id: justify-content
- id: flex-wrap
- id: alignment
- id: flex
- id: absolute-position
- id: min-max-dimen
- id: margin-padding-border
- title: Yoga additions
items:
- id: aspect-ratio
- id: rtl
- title: API
items:
- id: c
- id: objc
- id: java
- id: csharp

View File

@@ -0,0 +1 @@
# For non-highlighted projects. See format in powered_by_highlight.yml

View File

@@ -0,0 +1,6 @@
# React Native uses Yoga now. We can add a highlight later when other projects use it.
#- title: Who Uses This Project?
# items:
# - name: React Native
# url: https://facebook.github.io/react-native
# img: static/images/react-native.png

11
docs/_data/promo.yml Normal file
View File

@@ -0,0 +1,11 @@
# This file determines the list of promotional elements added to the header of \
# your site's homepage.
- type: plugin_row
children:
- type: button
href: docs/getting-started/
text: Get Started
- type: button
href: docs/learn-more/
text: Learn More

74
docs/_docs/api/c.md Normal file
View File

@@ -0,0 +1,74 @@
---
docid: c
title: C
layout: docs
permalink: /docs/api/c/
---
`YGNodeRef` is the main object you will be interfacing with when using Yoga in C. `YGNodeRef` is a pointer to an internal `YGNode` struct.
### Lifecycle
The following functions control the lifecycle of a `YGNodeRef`.
<script src="https://gist.github.com/emilsjolander/99e454d04df4765147f407bde131feca.js"></script>
- `YGNodeReset` will reset a node to its initial state so it can be re-used without needing to re-allocate a new node.
- `YGNodeFreeRecursive` is mostly used for testing and will free not only the node itself but also its children.
### Children
The following functions help manage the children of a node.
<script src="https://gist.github.com/emilsjolander/7e162314294087bb78817c064d345afb.js"></script>
### Style getters & setters
The large part of Yoga's API consists of setters and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
<script src="https://gist.github.com/emilsjolander/74913a3326d952ff5a65dabe5ce4baf8.js"></script>
### Layout results
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `YGNodeCalculateLayout` with the desired width and height or `YGUndefined` to perform the layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
<script src="https://gist.github.com/emilsjolander/7c7c9c61b69daff5b925719065fb0dc9.js"></script>
### Custom measurements
Certain nodes need to ability to measure themselves, the most common example is nodes which represent text. Text has an intrinsic size and requires measuring itself to determine that size. This is not something Yoga can do as it requires relying on the host system's text rendering engine.
- Call `YGNodeMarkDirty` if a node with a custom text measurement function needs to be re-measured during the next layout pass.
> A measure function can only be attached to a leaf node in the hierarchy.
<script src="https://gist.github.com/emilsjolander/73f9118d8bd27f9cb3744c08f1e53a32.js"></script>
### Context
Context is important when integrating Yoga into another layout system. Context allows you to associate another object with a `YGNodeRef`. This context can then be retrieved from a `YGNodeRef` when for example its measure function is called. This is what enables Yoga to rely on the Android and iOS system implementations of text measurement in React Native.
<script src="https://gist.github.com/emilsjolander/c3d23a1b880d59627e959f3447a9511b.js"></script>
### Logging
Yoga will by default log to stdout and stderr. You may however customize this to instead log to your own logger.
<script src="https://gist.github.com/emilsjolander/b538718ffd7a55efc80845468e0f063e.js"></script>
### Experiments
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
<script src="https://gist.github.com/emilsjolander/002516a55e10947e4bdcf5484eee8745.js"></script>
### Custom allocators
You may want to swap out the allocator used in Yoga. These functions allow that.
<script src="https://gist.github.com/emilsjolander/f45053d4f09a9faaf94a8fc071f0224f.js"></script>
### Printing
Yoga has some hooks to print debug information while calculating layout. With the printing APIs you can add additional information to a node when it is printed.
<script src="https://gist.github.com/emilsjolander/c9fbaba914d699ecc91841f4f5515f20.js"></script>

53
docs/_docs/api/csharp.md Normal file
View File

@@ -0,0 +1,53 @@
---
docid: csharp
title: C#
layout: docs
permalink: /docs/api/csharp/
---
`YogaNode` is the main object you will be interfacing with when using Yoga in .NET. `YogaNode` is a thin [P/Invoke](https://msdn.microsoft.com/en-us/library/aa446536.aspx) wrapper around the core Yoga library.
### Lifecycle
Create a `YogaNode` via its default constructor or the static `Create()` builder method and use `Reset` if you want to pool and re-use nodes. The native memory of a `YogaNode` will automatically be freed when the node is garbage collected.
<script src="https://gist.github.com/emilsjolander/ce73212ee5fdb543d463822c3dd172b4.js"></script>
### Children
The following methods help manage the children of a node.
<script src="https://gist.github.com/emilsjolander/2b0ea738d3c24644fa98910b276620e4.js"></script>
### Style getters & setters
The large part of Yoga's API consists of properties, setters, and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
<script src="https://gist.github.com/emilsjolander/a84208768e0006b8421a322c40f98539.js"></script>
### Layout results
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `CalculateLayout()` perform layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
<script src="https://gist.github.com/emilsjolander/b50acf9fc0877affeb0fc3e55b5c6b4c.js"></script>
### Custom measurements
Certain nodes need to ability to measure themselves, the most common example is nodes which represent text. Text has an intrinsic size and requires measuring itself to determine that size. This is not something Yoga can do as it requires relying on the host system's text rendering engine.
- Call `MarkDirty()` if a node with a custom text measurement function needs to be re-measured during the next layout pass.
> A measure function can only be attached to a leaf node in the hierarchy.
<script src="https://gist.github.com/emilsjolander/57178307f515e5ea1ccfbedc05df429b.js"></script>
### Data
Data is important when integrating Yoga into another layout system. Data allows you to associate another object with a `YogaNode`. This data can then be retrieved from a `YogaNode` when for example its measure function is called. This is what enables Yoga to rely on the Android system implementations of text measurement in React Native.
<script src="https://gist.github.com/emilsjolander/c099f826623d70fd6bf7dece14e76700.js"></script>
### Experiments
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
<script src="https://gist.github.com/emilsjolander/97b2500918687826cdfe9429638f2d57.js"></script>

59
docs/_docs/api/java.md Normal file
View File

@@ -0,0 +1,59 @@
---
docid: java
title: Java
layout: docs
permalink: /docs/api/java/
---
`YogaNode` is the main object you will be interfacing with when using Yoga in Java. `YogaNode` is a thin [JNI](https://en.wikipedia.org/wiki/Java_Native_Interface) wrapper around the core Yoga library.
### Lifecycle
Create a `YogaNode` via its default constructor and use `reset` if you want to pool and re-use nodes. The native memory of a `YogaNode` will automatically be freed when the node is garbage collected.
<script src="https://gist.github.com/emilsjolander/8775de8c778eb99a05a38e8257f0b4a7.js"></script>
### Children
The following methods help manage the children of a node.
<script src="https://gist.github.com/emilsjolander/5d1c64d8d3be7f7942435c4f5bec45a5.js"></script>
### Style getters & setters
The large part of Yoga's API consists of setters and getters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
<script src="https://gist.github.com/emilsjolander/f94ca2aa69441a3060a7c9f5126f202f.js"></script>
### Layout results
Once you have set up a tree of nodes with styles you will want to get the result of a layout calculation. Call `calculateLayout()` perform layout calculation. Once this function returns the results of the layout calculation is stored on each node. Traverse the tree and retrieve the values from each node.
<script src="https://gist.github.com/emilsjolander/613a80ae11abce423a4806521e1e315b.js"></script>
### Custom measurements
Certain nodes need to ability to measure themselves, the most common example is nodes which represent text. Text has an intrinsic size and requires measuring itself to determine that size. This is not something Yoga can do as it requires relying on the host system's text rendering engine.
- Call `dirty()` if a node with a custom text measurement function needs to be re-measured during the next layout pass.
> A measure function can only be attached to a leaf node in the hierarchy.
<script src="https://gist.github.com/emilsjolander/70fd958b87647abbba604956709a9026.js"></script>
### Data
Data is important when integrating Yoga into another layout system. Data allows you to associate another object with a `YogaNode`. This data can then be retrieved from a `YogaNode` when for example its measure function is called. This is what enables Yoga to rely on the Android system implementations of text measurement in React Native.
<script src="https://gist.github.com/emilsjolander/3f10f3fa91120960b71783780f528973.js"></script>
### Logging
Yoga will by default log to stdout and stderr (or logcat on Android). You may however customize this to instead log to your own logger.
<script src="https://gist.github.com/emilsjolander/6d012f5d48be0e98b7f9c2225c358f6e.js"></script>
### Experiments
Yoga has the concept of experiments. An experiment is a feature which is not yet stable. To enable a feature use the following functions. Once a feature has been tested and is ready to be released as a stable API we will remove its feature flag.
<script src="https://gist.github.com/emilsjolander/97b2500918687826cdfe9429638f2d57.js"></script>

38
docs/_docs/api/objc.md Normal file
View File

@@ -0,0 +1,38 @@
---
docid: objc
title: Objective-C
layout: docs
permalink: /docs/api/objc/
---
> The Objective-C API is very new and still in rapid development. Please use it and [report issues, bugs or feedback](https://github.com/facebook/yoga/issues). We hope to stabilize the API over the next couple weeks / months.
Yoga for Objective-C is implemented as a [category](https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/Category.html) on [UIView](https://developer.apple.com/reference/uikit/uiview). We try to rely on the existing `UIView` properties and initializers where possible, making the Yoga API smaller for Objective-C than for other languages.
### Lifecycle
As with any `UIView` instantiate it using `-(instancetype)initWithFrame:(CGRect)frame`. With Yoga for Objective-C the frame is actually how you set the width and the height of the Yoga node, just like any other `UIView`.
Because Yoga is implemented as a category we need some way to mark the view as using Yoga as you might not want Yoga to control layout of your whole app, this is especially important if you are migrating an existing app to use Yoga. The property decides during layout/sizing whether or not `yg_*` properties should be applied. Defaults to `NO`.
<script src="https://gist.github.com/emilsjolander/b95467f51b945e906d39b66e44999806.js"></script>
### Children
Yoga relies on `UIView` subviews to build up its internal layout tree. However using properties such as `yg_includeInLayout` a View can exclude itself from layout. Therefor we provide the following method to query the number of children which are laid out using Yoga.
<script src="https://gist.github.com/emilsjolander/253d69b12bef2ee1ec899ace81b768a6.js"></script>
### Style setters
The large part of Yoga's API consists of setters for styles. These all follow the same general structure. Bellow are the function and enums used to control the various styles. For an in depth guide to how each style works see the getting started guide.
<script src="https://gist.github.com/emilsjolander/e7c7732b9465173335d2e019a6bc5941.js"></script>
### Layout
- `yg_includeInLayout` decides if we should include this view when calculating layout. Defaults to `YES`.
- `yg_intrinsicSize` returns the size of the view if no constraints were given. This is equivalent to calling `[view sizeThatFits:CGSizeMake(CGFLOAT_MAX, CGFLOAT_MAX)]`.
- `yg_applyLayout` performs layout calculation and update the frames of the views in the hierarchy with the results.
- `yg_resolvedDirection` returns the resolved layout direction of this view. Either `YGDirectionRTL` or `YGDirectionLTR`.
<script src="https://gist.github.com/emilsjolander/437661e872c1f9106b728419d5ea49e9.js"></script>

View File

@@ -0,0 +1,38 @@
---
docid: absolute-position
title: Absolute positioning
layout: docs
permalink: /docs/absolute-position/
---
The `Position` property tells Flexbox how you want your item to be positioned within its parent. There are 2 options:
* `Relative` (default)
* `Absolute`
An item marked with `Position = Absolute` is positioned absolutely in regards to its parent. This is done through 6 properties:
* `Left` - controls the distance a child's left edge is from the parent's left edge
* `Top` - controls the distance a child's top edge is from the parent's top edge
* `Right` - controls the distance a child's right edge is from the parent's right edge
* `Bottom` - controls the distance a child's bottom edge is from the parent's bottom edge
* `Start` - controls the distance a child's start edge is from the parent's start edge
* `End` - controls the distance a child's end edge is from the parent's end edge
Using these options you can control the size and position of an absolute item within its parent. Because absolutely positioned children don't effect their siblings layout `Position = Absolute` can be used to create overlays and stack children in the Z axis.
#### Position = Absolute; Start = 0; Top = 0; Width = 50; Height = 50;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; width: 300px; height: 300px;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; left: 0px; top: 0px; position: absolute;"></div>
</div>
</div>
#### Position = Absolute; Start = 10; Top = 10; End = 10; Bottom = 10;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; width: 300px; height: 300px;">
<div class="yoga" style="background-color: #303846; left: 10px; top: 10px; bottom: 10px; right: 10px; position: absolute;"></div>
</div>
</div>

View File

@@ -0,0 +1,92 @@
---
docid: alignment
title: Alignment
layout: docs
permalink: /docs/alignment/
---
### AlignItems
The `AlignItems` property describes how to align children along the cross axis of their container. `AlignItems` is very similar to `JustifyContent` but instead of applying to the main axis, it applies to the cross axis. There are 4 options for `AlignItems`:
* `Stretch` (default)
* `FlexStart`
* `FlexEnd`
* `Center`
The only non-obvious option of the four is `Stretch`. With `AlignItems = Stretch` you instruct children to match the size of their container in the cross axis.
#### AlignItems = Stretch
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px; height: 200px;">
<div class="yoga" style="background-color: #303846; width: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; "></div>
</div>
</div>
#### AlignItems = FlexStart
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px; height: 200px; align-items: flex-start;">
<div class="yoga" style="background-color: #303846; height: 50px; width: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; height: 50px; width: 50px; "></div>
</div>
</div>
#### AlignItems = FlexEnd
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px; height: 200px; align-items: flex-end;">
<div class="yoga" style="background-color: #303846; height: 50px; width: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; height: 50px; width: 50px; "></div>
</div>
</div>
#### AlignItems = Center
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px; height: 200px; align-items: center;">
<div class="yoga" style="background-color: #303846; height: 50px; width: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; height: 50px; width: 50px; "></div>
</div>
</div>
### AlignSelf
The `AlignSelf` property has the same options and effect as `AlignItems` but instead of affecting the children within a container, you can apply this property to a single child to change its alignment within its parent.
This property overrides any option set by the parent via the `AlignItems` property.
#### AlignItems = FlexEnd; AlignSelf = FlexStart;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px; height: 200px; align-items: flex-end;">
<div class="yoga" style="background-color: #303846; height: 50px; width: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; height: 50px; width: 50px; align-self: flex-start;"></div>
</div>
</div>
### AlignContent
The `AlignContent` property is used to control how multiple lines of content are aligned within a container which uses `FlexWrap = wrap`. There are 6 options:
* `FlexStart` (default)
* `FlexEnd`
* `Center`
* `Stretch`
* `SpaceBetween`
* `SpaceAround`
#### AlignContent = FlexEnd
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 300px; flex-wrap: wrap; height: 300px; align-content: flex-end;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px; margin-bottom: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px; margin-bottom: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px; margin-bottom: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
</div>
</div>

View File

@@ -0,0 +1,47 @@
---
docid: flex-direction
title: Flex direction
layout: docs
permalink: /docs/flex-direction/
---
The `FlexDirection` property controls the direction in which children are laid out. There are 4 options, of which 2 are commonly used:
* `Column` (default)
* `Row`
* `ColumnReverse`
* `RowReverse`
The `Column` option stacks children horizontally from top to bottom, and the `Row` option stacks children from left to right. The `Reverse` variants of the options reverse the order. If your layout supports right-to-left direction, Yoga will automatically toggle between `Row` and `RowReverse` as necessary.
`FlexDirection` introduces another important aspect of Flexbox, the main and cross axes. This is important as other properties will reference which axis they operate on. Simply put, the main axis follows the `FlexDirection` and the cross axis crosses the main axis at a 90 degree angle.
#### FlexDirection = Row
In this example the main axis goes from the left to the right. The cross axis goes from the top to the bottom.
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
</div>
</div>
#### FlexDirection = Column
In this example the main axis goes from the top to the bottom. The cross axis goes from the left to the right.
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-bottom: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-bottom: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-bottom: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-bottom: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-bottom: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
</div>
</div>

View File

@@ -0,0 +1,39 @@
---
docid: flex-wrap
title: Flex wrap
layout: docs
permalink: /docs/flex-wrap/
---
The `FlexWrap` property is set on containers and controls what happens when children overflow the size of the container along the main axis. There are 2 options:
* `Nowrap` (default)
* `Wrap`
If a container specifies `FlexWrap = Wrap` then its children will wrap to the next line instead of overflowing. The next line will have the same `FlexDirection` as the first line and will appear next to the first line along the cross axis -- below it if using `FlexDirection = Column` and to the right if using `FlexDirection = Row`.
#### FlexWrap = Nowrap
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 300px;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
</div>
</div>
#### FlexWrap = Wrap
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 300px; flex-wrap: wrap;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px; margin-bottom: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px; margin-bottom: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px; margin-bottom: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
</div>
</div>

100
docs/_docs/flexbox/flex.md Normal file
View File

@@ -0,0 +1,100 @@
---
docid: flex
title: Flex
layout: docs
permalink: /docs/flex/
---
### FlexGrow
The `FlexGrow` property describes how any space within a container should be distributed among its children along the main axis. After laying out its children, a container will distribute any remaining space according to the `FlexGrow` values specified by its children.
`FlexGrow` accepts any floating point value >= 0, with 0 being the default value. A container will distribute any remaining space among its children weighted by the child's `FlexGrow` value.
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
</div>
</div>
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; flex-grow: 1;">
<span><span>FlexGrow = 1</span></span>
</div>
</div>
</div>
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px; flex-grow: 1;">
<span><span>FlexGrow = 1</span></span>
</div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; flex-grow: 1;">
<span><span>FlexGrow = 1</span></span>
</div>
</div>
</div>
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px; flex-grow: 1;">
<span><span>FlexGrow = 1</span></span>
</div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; flex-grow: 2;">
<span><span>FlexGrow = 2</span></span>
</div>
</div>
</div>
### FlexShrink
The `FlexShrink` property describes how to shrink children along the main axis in the case that the total size of the children overflow the size of the container on the main axis.
`FlexShrink` is very similar to `FlexGrow` and can be thought of in the same way if any overflowing size is considered to be negative remaining space. These two properties also work well together by allowing children to grow and shrink as needed.
`FlexShrink` accepts any floating point value >= 0, with 0 being the default value. A container will shrink its children weighted by the child's `FlexShrink` value.
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px;">
<div class="yoga" style="background-color: #303846; width: 300px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 300px; height: 50px;"></div>
</div>
</div>
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px;">
<div class="yoga" style="background-color: #303846; width: 300px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 300px; height: 50px; flex-shrink: 1;">
<span><span>FlexShrink = 1</span></span>
</div>
</div>
</div>
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px;">
<div class="yoga" style="background-color: #303846; width: 300px; height: 50px; margin-right: 20px; flex-shrink: 1;">
<span><span>FlexShrink = 1</span></span>
</div>
<div class="yoga" style="background-color: #303846; width: 300px; height: 50px; flex-shrink: 1;">
<span><span>FlexShrink = 1</span></span>
</div>
</div>
</div>
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px;">
<div class="yoga" style="background-color: #303846; width: 300px; height: 50px; margin-right: 20px; flex-shrink: 1;">
<span><span>FlexShrink = 1</span></span>
</div>
<div class="yoga" style="background-color: #303846; width: 300px; height: 50px; flex-shrink: 2;">
<span><span>FlexShrink = 2</span></span>
</div>
</div>
</div>
### FlexBasis
The `FlexBasis` property is an axis-independent way of providing the default size of an item on the main axis. Setting the `FlexBasis` of a child is similar to setting the `Width` of that child if its parent is a container with `FlexDirection = row` or setting the `Height` of a child if its parent is a container with `FlexDirection = column`. The `FlexBasis` of an item is the default size of that item, the size of the item before any `FlexGrow` and `FlexShrink` calculations are performed.

View File

@@ -0,0 +1,61 @@
---
docid: justify-content
title: Justify content
layout: docs
permalink: /docs/justify-content/
---
The `JustifyContent` property describes how to align children within the main axis of a container. For example, you can use this property to center a child horizontally within a container with `FlexDirection = Row` or vertically within a container with `FlexDirection = Column`.
`JustifyContent` accepts 1 of the following 5 options:
* `FlexStart` (default)
* `FlexEnd`
* `Center`
* `SpaceBetween`
* `SpaceAround`
#### JustifyContent = FlexStart
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
</div>
</div>
#### JustifyContent = FlexEnd
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px; justify-content: flex-end;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
</div>
</div>
#### JustifyContent = Center
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px; justify-content: center;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
</div>
</div>
#### JustifyContent = SpaceBetween
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px; justify-content: space-between;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
</div>
</div>
#### JustifyContent = SpaceAround
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px; justify-content: space-around;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px;"></div>
</div>
</div>

View File

@@ -0,0 +1,58 @@
---
docid: margin-padding-border
title: Margin, Padding, Border
layout: docs
permalink: /docs/margin-padding-border/
---
`Margin`, `Padding` are similar but have some important differences. By applying `Margin` to an item you specify the offset a certain edge of the item should have from it's closest sibling or parent. With `Padding` on the other hand you specify the offset children should have from a certain edge on the parent. `Border` behaves nearly identically to `Padding` and is only separate from `Padding` to make it easier to implement border effect such as color. In the below illustrations the green box is a child of the dark gray box.
#### MarginStart = 50;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; width: 300px; height: 300px;">
<div class="yoga" style="background-color: #303846; flex: 1; margin-left: 50px;">
<div style="width: 50px; height: 50px; background-color: #97dccf;"></div>
</div>
</div>
</div>
#### MarginEnd = 50;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; width: 300px; height: 300px;">
<div class="yoga" style="background-color: #303846; flex: 1; margin-right: 50px;">
<div style="width: 50px; height: 50px; background-color: #97dccf;"></div>
</div>
</div>
</div>
#### MarginAll = 50;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; width: 300px; height: 300px;">
<div class="yoga" style="background-color: #303846; flex: 1; margin: 50px;">
<div style="width: 50px; height: 50px; background-color: #97dccf;"></div>
</div>
</div>
</div>
#### PaddingAll = 50;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; width: 300px; height: 300px;">
<div class="yoga" style="background-color: #303846; flex: 1; padding: 50px;">
<div style="width: 50px; height: 50px; background-color: #97dccf;"></div>
</div>
</div>
</div>
#### BorderWidth = 50;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; width: 300px; height: 300px;">
<div class="yoga" style="background-color: #303846; flex: 1; border-width: 50px; border-color: transparent;">
<div style="width: 50px; height: 50px; background-color: #97dccf;"></div>
</div>
</div>
</div>

View File

@@ -0,0 +1,34 @@
---
docid: min-max-dimen
title: Min & Max dimensions
layout: docs
permalink: /docs/min-max-dimen/
---
Using `MinWidth`, `MinHeight`, `MaxWidth`, and `MaxHeight` gives you increased control over the final size of items in a layout. By mixing these properties with `FlexGrow`, `FlexShrink`, and `AlignItems = Stretch`, you are able to have items with dynamic size within a range which you control.
An example of when `Max` properties can be useful is if you are using `AlignItems = Stretch` but your know that your item won't look good after it increases past a certain point. In this case, your item will stretch to the size of its parent or until it is as big as specified in the `Max` property.
Same goes for the `Min` properties when using `FlexShrink`. For example, you may want children of a container to shrink to fit on one row, but if you specify a minimum width, they will break to the next line after a certain point (if you are using `FlexWrap = Wrap`).
Another case where `Min` and `Max` dimension constraints are useful is when using `AspectRatio`.
#### FlexGrow = 1; MaxWidth = 200;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px;">
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; height: 50px; flex-grow: 1; max-width: 200px;">
<span><span>FlexGrow = 1</span></span>
</div>
</div>
</div>
#### AlignItems = Stretch; MaxHeight: 100;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; padding: 20px; flex-direction: row; width: 500px; height: 200px;">
<div class="yoga" style="background-color: #303846; width: 50px; margin-right: 20px;"></div>
<div class="yoga" style="background-color: #303846; width: 50px; max-height: 100px;"></div>
</div>
</div>

View File

@@ -0,0 +1,28 @@
---
docid: getting-started
title: Getting Started
layout: docs
permalink: /docs/getting-started/
---
## Installation
Installation of Yoga is currently a manual process. We have plans on bringing Yoga to the many available package management systems (e.g., [Yarn](https://yarnpkg.com/), [Gradle](https://gradle.org/), [Cocoapods](https://cocoapods.org/)), but we do not have a target date at this time. We would greatly appreciate [community contributions here](https://github.com/facebook/yoga/pulls).
### Getting the Code
For now we recommend including Yoga as a [git submodule](https://git-scm.com/docs/git-submodule) in your project. Once done, you can either build Yoga using Buck (detailed [below](#building-with-buck)) or integrate it into your existing build system by including the C library from the [root `yoga` directory](https://github.com/facebook/yoga/tree/master/yoga) as well as the [language bindings](https://github.com/facebook/yoga) (e.g., Java, C#) you wish to use.
### Running the Example
Yoga ships with an [iOS example](https://github.com/facebook/yoga/tree/master/YogaKit/YogaKitSample). To get it running:
<script src="https://gist.github.com/emilsjolander/903b16185b24c957acc4cd250c6e73d9.js"></script>
### Building with Buck
Yoga uses [Buck](https://buckbuild.com/) as its build system. Buck is not required for using Yoga, but, if you already use Buck, then integrating Yoga is very simple.
If you are using Buck all you need to do is reference the language bindings you want to use in your `BUCK` file.
<script src="https://gist.github.com/emilsjolander/895b4ec79425882b8d4676b6545d6943.js"></script>

42
docs/_docs/learn-more.md Normal file
View File

@@ -0,0 +1,42 @@
---
docid: learn-more
title: Learn More
layout: docs
permalink: /docs/learn-more/
---
Yoga is an open-source, cross-platform layout library that implements Flexbox. Yoga's focus is on creating an expressive ***layout*** library, not implementing all of CSS. Therefore, there are no plans to include support for tables, floats, or similar CSS concepts. Yoga also does not support styling properties that have no impact on layout, such as color or background properties.
### Yoga vs Flexbox
Yoga aims to be compatible with Flexbox according to the [w3 specification](https://www.w3.org/TR/css3-flexbox). However, Yoga was not developed to strictly adhere to the specification; thus, there are aspects where Yoga differs.
#### Default values
Yoga has chosen to change the default values of some properties to better fit mobile layout use cases. The following CSS block describes the differences in default values from the [Flexbox w3 specification](https://www.w3.org/TR/css3-flexbox).
<script src="https://gist.github.com/emilsjolander/f9b3981cab44c51afa9ac446b8fdb60c.js"></script>
We have set up a [JSFiddle](https://jsfiddle.net/emilsjolander/jckmwztt/) so you can see these default values in action.
#### Right-to-Left
We believe that Right-to-Left (RTL) should be a first class citizen when it comes to layout. Therefore, Yoga implements non-standard RTL support for margin, padding, border, and position properties. This enables specifying these properties as `start` instead of `left` and `end` instead of `right`.
<div class="pluginWrapper buttonWrapper">
<a
class="button"
href="/yoga/docs/rtl/"
>Learn More about RTL</a>
</div>
#### Yoga-specific properties
The goal of Yoga is to be a library which makes layout easy. Of course, implementing Flexbox, a common and well-liked system, helps meet this goal. However, there are areas where we think Yoga can evolve beyond Flexbox and provide developers with tools not included in the [Flexbox w3 specification](https://www.w3.org/TR/css3-flexbox). Currently Yoga has added one such property, `AspectRatio`, to solve a common problem we saw in many UIs.
<div class="pluginWrapper buttonWrapper">
<a
class="button"
href="/yoga/docs/aspect-ratio/"
>Learn More about Aspect Ratio</a>
</div>

View File

@@ -0,0 +1,47 @@
---
docid: aspect-ratio
title: Aspect ratio
layout: docs
permalink: /docs/aspect-ratio/
---
`AspectRatio` is a property introduced by Yoga. `AspectRatio` solves the problem of knowing one dimension of an element and an aspect ratio, this is very common when it comes to videos, images, and other media types. `AspectRatio` accepts any floating point value > 0, the default is undefined. `AspectRatio` can apply to either the width or the height of an item, it depends on which dimension is fixed. `AspectRatio` Also respects the `Min` and `Max` dimensions of an item.
- If an item has a `Width` set then `AspectRatio` controls the item's height.
- If an item has a `Height` set then `AspectRatio` controls the item's width.
- If an item has a `FlexBasis` set then `AspectRatio` controls the item's cross axis dimension.
- If an item's alignment is `Stretch` and its main axis is undefined then `AspectRatio` controls the item's main axis dimension.
- If an item has `FlexGrow` or `FlexShrink` set then `AspectRatio` controls the item's cross axis dimension if it is undefined.
- If both dimensions of an item are fixed then `AspectRatio` is ignored.
#### Width = 100; AspectRatio = 2;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; width: 300px; height: 300px;">
<div class="yoga" style="background-color: #303846; width: 100px; height: 200px;"></div>
</div>
</div>
#### Width = 100; AspectRatio = 0.5;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; width: 300px; height: 300px;">
<div class="yoga" style="background-color: #303846; width: 100px; height: 50px;"></div>
</div>
</div>
#### FlexDirection = Row; FlexGrow = 1; AspectRatio = 0.5;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; width: 300px; height: 300px; flex-direction: row;">
<div class="yoga" style="background-color: #303846; flex-grow: 1; height: 150px;"></div>
</div>
</div>
#### FlexDirection = Row; AlignItems = Stretch; AspectRatio = 0.5;
<div class="yoga" style="align-items: flex-start;">
<div class="yoga sample" style="background-color: white; width: 300px; height: 300px; flex-direction: row;">
<div class="yoga" style="background-color: #303846; width: 150px;"></div>
</div>
</div>

15
docs/_docs/yoga/rtl.md Normal file
View File

@@ -0,0 +1,15 @@
---
docid: rtl
title: RTL
layout: docs
permalink: /docs/rtl/
---
The web has limited support for Right-to-Left (RTL) layouts. It does a pretty good job when it comes to text alignment and text rendering, but lacks the features needed to build fully RTL compatible UIs. Therefore, Yoga has adopted `Start` and `End` values for `Margin`, `Padding`, `Border`, and `Position` properties.
## Direction
With `Start` and `End`, you can specify these properties in your UI without having to think about whether your item will show up on the left or the right side of the screen (depending on the person's language setting). Yoga automatically handles this for you.
The `Direction` property controls this behavior. `Direction` defaults to `Inherit` on all nodes except the root which defaults to `LTR`. It is up to you to detect the user's preferred direction (most platforms have a standard way of doing this) and setting this direction on the root of your layout tree.

View File

@@ -0,0 +1,28 @@
<!-- Pagination links - copied from http://jekyllrb.com/docs/pagination/ -->
{% if paginator.total_pages > 1 %}
<br />
<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path | relative_url | replace: '//', '/' }}">&laquo; Prev</a>
{% else %}
<span>&laquo; Prev</span>
{% endif %}
{% for page in (1..paginator.total_pages) %}
{% if page == paginator.page %}
<em>{{ page }}</em>
{% elsif page == 1 %}
<a href="{{ '/blog' | relative_url }}">{{ page }}</a>
{% else %}
<a href="{{ site.paginate_path | relative_url | replace: '//', '/' | replace: ':num', page }}">{{ page }}</a>
{% endif %}
{% endfor %}
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path | relative_url | replace: '//', '/' }}">Next &raquo;</a>
{% else %}
<span>Next &raquo;</span>
{% endif %}
</div>
<br />
{% endif %}

View File

@@ -0,0 +1,5 @@
<div class="gridBlock">
{% for item in {{include.data_source}} %}
{% include content/items/gridblock.html item=item layout=include.layout imagealign=include.imagealign align=include.align %}
{% endfor %}
</div>

View File

@@ -0,0 +1,37 @@
{% if include.layout == "fourColumn" %}
{% assign layout = "fourByGridBlock" %}
{% else %}
{% assign layout = "twoByGridBlock" %}
{% endif %}
{% if include.imagealign == "side" %}
{% assign imagealign = "imageAlignSide" %}
{% else %}
{% if item.image %}
{% assign imagealign = "imageAlignTop" %}
{% else %}
{% assign imagealign = "" %}
{% endif %}
{% endif %}
{% if include.align == "right" %}
{% assign align = "alignRight" %}
{% elsif include.align == "center" %}
{% assign align = "alignCenter" %}
{% else %}
{% assign align = "alignLeft" %}
{% endif %}
<div class="blockElement {{ layout }} {{ imagealign }} {{ align }}">
{% if item.image %}
<div class="blockImage">
<img src="/static/{{ item.image }}" alt="{{ item.title }}" title="{{ item.title }}" />
</div>
{% endif %}
<div class="blockContent">
<h3>{{ item.title }}</h3>
{% if item.text %}
{{ item.text | markdownify }}
{% endif %}
</div>
</div>

25
docs/_includes/doc.html Normal file
View File

@@ -0,0 +1,25 @@
<div class="post">
<header class="post-header">
<h1 class="post-title">{% if include.truncate %}<a href="{{ page.url | absolute_url }}">{{ page.title }}</a>{% else %}{{ page.title }}{% endif %}</h1>
</header>
<article class="post-content">
{% if include.truncate %}
{% if page.content contains '<!--truncate-->' %}
{{ page.content | split:'<!--truncate-->' | first }}
<div class="read-more">
<a href="{{ page.url | absolute_url }}" >
...Read More
</a>
</div>
{% else %}
{{ page.content }}
{% endif %}
{% else %}
{{ content }}
{% endif %}
</article>
{% include doc_paging.html %}
</div>

View File

View File

@@ -0,0 +1,33 @@
<div class="footerContainer">
<div id="footer_wrap" class="wrapper footerWrapper">
<div class="footerBlocks">
<div id="fb_oss" class="footerSection fbOpenSourceFooter">
<svg class="facebookOSSLogoSvg" viewBox="0 0 1133.9 1133.9" x="0px" y="0px">
<g>
<path class="logoRing outerRing" d="M 498.3 3.7 c 153.6 88.9 307.3 177.7 461.1 266.2 c 7.6 4.4 10.3 9.1 10.3 17.8 c -0.3 179.1 -0.2 358.3 0 537.4 c 0 8.1 -2.4 12.8 -9.7 17.1 c -154.5 88.9 -308.8 178.1 -462.9 267.5 c -9 5.2 -15.5 5.3 -24.6 0.1 c -153.9 -89.2 -307.9 -178 -462.1 -266.8 C 3 838.8 0 833.9 0 825.1 c 0.3 -179.1 0.2 -358.3 0 -537.4 c 0 -8.6 2.6 -13.6 10.2 -18 C 164.4 180.9 318.4 92 472.4 3 C 477 -1.5 494.3 -0.7 498.3 3.7 Z M 48.8 555.3 c 0 79.9 0.2 159.9 -0.2 239.8 c -0.1 10 3 15.6 11.7 20.6 c 137.2 78.8 274.2 157.8 411 237.3 c 9.9 5.7 17 5.7 26.8 0.1 c 137.5 -79.8 275.2 -159.2 412.9 -238.5 c 7.4 -4.3 10.5 -8.9 10.5 -17.8 c -0.3 -160.2 -0.3 -320.5 0 -480.7 c 0 -8.8 -2.8 -13.6 -10.3 -18 C 772.1 218 633.1 137.8 494.2 57.4 c -6.5 -3.8 -11.5 -4.5 -18.5 -0.5 C 336.8 137.4 197.9 217.7 58.8 297.7 c -7.7 4.4 -10.2 9.2 -10.2 17.9 C 48.9 395.5 48.8 475.4 48.8 555.3 Z" />
<path class="logoRing middleRing" d="M 184.4 555.9 c 0 -33.3 -1 -66.7 0.3 -100 c 1.9 -48 24.1 -86 64.7 -110.9 c 54.8 -33.6 110.7 -65.5 167 -96.6 c 45.7 -25.2 92.9 -24.7 138.6 1 c 54.4 30.6 108.7 61.5 162.2 93.7 c 44 26.5 67.3 66.8 68 118.4 c 0.9 63.2 0.9 126.5 0 189.7 c -0.7 50.6 -23.4 90.7 -66.6 116.9 c -55 33.4 -110.8 65.4 -167.1 96.5 c -43.4 24 -89 24.2 -132.3 0.5 c -57.5 -31.3 -114.2 -64 -170 -98.3 c -41 -25.1 -62.9 -63.7 -64.5 -112.2 C 183.5 621.9 184.3 588.9 184.4 555.9 Z M 232.9 556.3 c 0 29.5 0.5 59.1 -0.1 88.6 c -0.8 39.2 16.9 67.1 50.2 86.2 c 51.2 29.4 102.2 59.2 153.4 88.4 c 31.4 17.9 63.6 18.3 95 0.6 c 53.7 -30.3 107.1 -61.2 160.3 -92.5 c 29.7 -17.5 45 -44.5 45.3 -78.8 c 0.6 -61.7 0.5 -123.5 0 -185.2 c -0.3 -34.4 -15.3 -61.5 -44.9 -79 C 637.7 352.6 583 320.8 527.9 290 c -27.5 -15.4 -57.2 -16.1 -84.7 -0.7 c -56.9 31.6 -113.4 64 -169.1 97.6 c -26.4 15.9 -40.7 41.3 -41.1 72.9 C 232.6 491.9 232.9 524.1 232.9 556.3 Z" />
<path class="logoRing innerRing" d="M 484.9 424.4 c 69.8 -2.8 133.2 57.8 132.6 132 C 617 630 558.5 688.7 484.9 689.1 c -75.1 0.4 -132.6 -63.6 -132.7 -132.7 C 352.1 485 413.4 421.5 484.9 424.4 Z M 401.3 556.7 c -3.4 37.2 30.5 83.6 83 84.1 c 46.6 0.4 84.8 -37.6 84.9 -84 c 0.1 -46.6 -37.2 -84.4 -84.2 -84.6 C 432.2 472.1 397.9 518.3 401.3 556.7 Z" />
</g>
</svg>
<h2>Facebook Open Source</h2>
</div>
<div class="footerSection">
<a class="footerLink" href="https://code.facebook.com/projects/" target="_blank">Open Source Projects</a>
<a class="footerLink" href="https://github.com/facebook/" target="_blank">GitHub</a>
<a class="footerLink" href="https://twitter.com/fbOpenSource" target="_blank">Twitter</a>
</div>
<div class="footerSection rightAlign">
<a class="footerLink" href="https://github.com/{{ site.ghrepo }}" target="_blank">Contribute to this project on GitHub</a>
</div>
</div>
</div>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '{{ site.gacode }}', 'auto');
ga('send', 'pageview');
</script>

23
docs/_includes/head.html Normal file
View File

@@ -0,0 +1,23 @@
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:url" content="{{ page.url | replace:'index.html','' | absolute_url }}" />
<meta property="og:site_name" content="{{ site.title }}"/>
<meta property="og:title" content="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}" />
<meta property="og:image" content="{{ 'static/og_image.png' | absolute_url }}" />
<meta property="og:description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}" />
<link rel="stylesheet" href="{{ '/css/main.css' | relative_url }}" media="screen">
<link rel="icon" href="{{ '/static/favicon.png' | relative_url }}" type="image/x-icon">
{% if site.searchconfig %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.css" />
{% endif %}
<title>{% if page.title %}{{ page.title }} | {{ site.title }}{% else %}{{ site.title }}{% endif %}</title>
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
<link rel="canonical" href="{{ page.url | replace:'index.html','' | absolute_url }}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ '/feed.xml' | absolute_url }}" />
</head>

View File

@@ -0,0 +1,19 @@
<div class="headerContainer">
<div id="header_wrap" class="wrapper headerWrapper">
<div class="inner">
<img class="projectLogo" src="{{ '/static/logo.svg' | relative_url }}" alt="{{ site.title }}" title="{{ site.title }}" />
<h1 id="project_title">{{ site.title }}</h1>
<h2 id="project_tagline" class="fbossFontLight">{{ site.tagline }}</h2>
<section id="intro">
<p>{% if page.excerpt %}{{ page.excerpt | strip_html }}{% else %}{{ site.description }}{% endif %}</p>
</section>
<div id="promo" class="section promoSection">
{% for promo in site.data.promo %}
{% include plugins/{{promo.type}}.html button_href=promo.href button_text=promo.text %}
<div class="gridClear"></div>
{% endfor %}
</div>
</div>
</div>
</div>

0
docs/_includes/hero.html Normal file
View File

View File

@@ -0,0 +1,31 @@
<div class="homeContainer">
<div class="homeSplashFade">
<div id="home_wrap" class="wrapper homeWrapper">
<div id="inner">
<h2 id="project_tagline">{{ site.tagline }}</h2>
<section id="intro">
<!--<p>{% if page.excerpt %}{{ page.excerpt | strip_html }}{% else %}{{ site.description }}{% endif %}</p>-->
<p>
Yoga is a cross-platform layout engine enabling maximum collaboration within your team by implementing an API familiar to many designers and opening it up to developers across different platforms.
</p>
<ul>
<li>Do you already know Flexbox? Then you already know Yoga.</li>
<li>Write code in a language familiar to you - Java, C#, Objective-C, C.</li>
<li>C under the hood so your code moves fast.</li>
<li>Battle tested in popular frameworks like React Native.</li>
</ul>
</section>
<div id="promo" class="section promoSection">
{% for promo in site.data.promo %}
<div class="promoRow">
{% include plugins/{{promo.type}}.html href=promo.href text=promo.text children=promo.children %}
</div>
{% endfor %}
</div>
</div>
<div class="projectLogo">
<img src="{{ '/static/logo.svg' | relative_url }}" alt="{{ site.title }}">
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,3 @@
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.2.0/katex.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.2.0/katex.min.js"></script>

View File

@@ -0,0 +1,210 @@
<script type="text/javascript">
/* global katex */
var findEndOfMath = function(delimiter, text, startIndex) {
// Adapted from
// https://github.com/Khan/perseus/blob/master/src/perseus-markdown.jsx
var index = startIndex;
var braceLevel = 0;
var delimLength = delimiter.length;
while (index < text.length) {
var character = text[index];
if (braceLevel <= 0 &&
text.slice(index, index + delimLength) === delimiter) {
return index;
} else if (character === "\\") {
index++;
} else if (character === "{") {
braceLevel++;
} else if (character === "}") {
braceLevel--;
}
index++;
}
return -1;
};
var splitAtDelimiters = function(startData, leftDelim, rightDelim, display) {
var finalData = [];
for (var i = 0; i < startData.length; i++) {
if (startData[i].type === "text") {
var text = startData[i].data;
var lookingForLeft = true;
var currIndex = 0;
var nextIndex;
nextIndex = text.indexOf(leftDelim);
if (nextIndex !== -1) {
currIndex = nextIndex;
finalData.push({
type: "text",
data: text.slice(0, currIndex)
});
lookingForLeft = false;
}
while (true) {
if (lookingForLeft) {
nextIndex = text.indexOf(leftDelim, currIndex);
if (nextIndex === -1) {
break;
}
finalData.push({
type: "text",
data: text.slice(currIndex, nextIndex)
});
currIndex = nextIndex;
} else {
nextIndex = findEndOfMath(
rightDelim,
text,
currIndex + leftDelim.length);
if (nextIndex === -1) {
break;
}
finalData.push({
type: "math",
data: text.slice(
currIndex + leftDelim.length,
nextIndex),
rawData: text.slice(
currIndex,
nextIndex + rightDelim.length),
display: display
});
currIndex = nextIndex + rightDelim.length;
}
lookingForLeft = !lookingForLeft;
}
finalData.push({
type: "text",
data: text.slice(currIndex)
});
} else {
finalData.push(startData[i]);
}
}
return finalData;
};
var splitWithDelimiters = function(text, delimiters) {
var data = [{type: "text", data: text}];
for (var i = 0; i < delimiters.length; i++) {
var delimiter = delimiters[i];
data = splitAtDelimiters(
data, delimiter.left, delimiter.right,
delimiter.display || false);
}
return data;
};
var renderMathInText = function(text, delimiters) {
var data = splitWithDelimiters(text, delimiters);
var fragment = document.createDocumentFragment();
for (var i = 0; i < data.length; i++) {
if (data[i].type === "text") {
fragment.appendChild(document.createTextNode(data[i].data));
} else {
var span = document.createElement("span");
var math = data[i].data;
try {
katex.render(math, span, {
displayMode: data[i].display
});
} catch (e) {
if (!(e instanceof katex.ParseError)) {
throw e;
}
console.error(
"KaTeX auto-render: Failed to parse `" + data[i].data +
"` with ",
e
);
fragment.appendChild(document.createTextNode(data[i].rawData));
continue;
}
fragment.appendChild(span);
}
}
return fragment;
};
var renderElem = function(elem, delimiters, ignoredTags) {
for (var i = 0; i < elem.childNodes.length; i++) {
var childNode = elem.childNodes[i];
if (childNode.nodeType === 3) {
// Text node
var frag = renderMathInText(childNode.textContent, delimiters);
i += frag.childNodes.length - 1;
elem.replaceChild(frag, childNode);
} else if (childNode.nodeType === 1) {
// Element node
var shouldRender = ignoredTags.indexOf(
childNode.nodeName.toLowerCase()) === -1;
if (shouldRender) {
renderElem(childNode, delimiters, ignoredTags);
}
}
// Otherwise, it's something else, and ignore it.
}
};
var defaultOptions = {
delimiters: [
{left: "$$", right: "$$", display: true},
{left: "\\[", right: "\\]", display: true},
{left: "\\(", right: "\\)", display: false}
// LaTeX uses this, but it ruins the display of normal `$` in text:
// {left: "$", right: "$", display: false}
],
ignoredTags: [
"script", "noscript", "style", "textarea", "pre", "code"
]
};
var extend = function(obj) {
// Adapted from underscore.js' `_.extend`. See LICENSE.txt for license.
var source, prop;
for (var i = 1, length = arguments.length; i < length; i++) {
source = arguments[i];
for (prop in source) {
if (Object.prototype.hasOwnProperty.call(source, prop)) {
obj[prop] = source[prop];
}
}
}
return obj;
};
var renderMathInElement = function(elem, options) {
if (!elem) {
throw new Error("No element provided to render");
}
options = extend({}, defaultOptions, options);
renderElem(elem, options.delimiters, options.ignoredTags);
};
renderMathInElement(document.body);
</script>

32
docs/_includes/nav.html Normal file
View File

@@ -0,0 +1,32 @@
<div id="fixed_header" class="fixedHeaderContainer{% if include.alwayson %} visible{% endif %}">
<div class="headerWrapper wrapper">
<header>
<a href="{{ '/' | absolute_url }}">
<img src="{{ '/static/logo.svg' | relative_url }}">
<h2>{{ site.title }}</h2>
</a>
<div class="navigationWrapper navigationFull" id="flat_nav">
<nav class="navigation">
<ul>
{% for item in site.data.nav %}
<li class="navItem{% if page.collection == item.category or page.category == item.category %} navItemActive{% endif %}">
{% if item.category == "external" %}
<a href="{{ item.href }}">{{ item.title }}</a>
{% else %}
<a href="{{ item.href | relative_url }}">{{ item.title }}</a>
{% endif %}
</li>
{% endfor %}
{% if site.searchconfig %}
{% include nav_search.html inputselector="search_input" %}
{% endif %}
</ul>
</nav>
</div>
<div class="navigationWrapper navigationSlider" id="navigation_wrap">
{% include nav/header_nav.html %}
</div>
</header>
</div>
</div>

View File

@@ -0,0 +1,54 @@
<div class="docsNavContainer">
<nav class="toc" id="doc_nav">
<div class="toggleNav" id="collection_nav">
<section class="navWrapper wrapper">
<div class="navBreadcrumb wrapper">
<div class="navToggle" id="collection_nav_toggler">
<i></i>
</div>
<h2>
<a href="{{ include.sectionpath }}">{{ include.sectiontitle }}</a>
{% if include.currentgroup %}
<i></i>
<span>{{ include.currentgroup }}</span>
{% endif %}
</h2>
</div>
<div class="navGroups">
{% if include.type == "blog" %}
{% assign grouptitle = "All Posts" %}
{% assign groupitems = include.navdata %}
{% include nav/collection_nav_group.html %}
{% else %}
{% for group in include.navdata %}
{% assign grouptitle = group.title %}
{% for item in group.items %}
{% if item.id == page.docid %}
{% assign currentselected = item.id %}
{% assign currentgroup = group %}
{% endif %}
{% endfor %}
{% include nav/collection_nav_group.html %}
{% endfor %}
{% endif %}
</div>
</section>
</div>
</nav>
</div>
<script>
var docsevent = document.createEvent('Event');
docsevent.initEvent('docs_slide', true, true);
document.addEventListener('docs_slide', function (e) {
document.body.classList.toggle('docsSliderActive');
}, false);
var collectionNav = document.getElementById('collection_nav');
var collectionNavToggler =
document.getElementById('collection_nav_toggler');
collectionNavToggler.addEventListener('click', function(e) {
collectionNav.classList.toggle('toggleNavActive');
document.dispatchEvent(docsevent);
});
</script>

View File

@@ -0,0 +1,19 @@
<div class="navGroup navGroupActive navGroupCurrent">
<h3><span>{{ grouptitle }}</span></h3>
<ul>
{% if include.data_collection %}
{% for item in group.items %}
{% for collectionitem in include.data_collection %}
{% if collectionitem.docid == item.id %}
{% assign groupitem = collectionitem %}
{% include nav/collection_nav_group_item.html %}
{% endif %}
{% endfor %}
{% endfor %}
{% else %}
{% for groupitem in groupitems %}
{% include nav/collection_nav_group_item.html %}
{% endfor %}
{% endif %}
</ul>
</div>

View File

@@ -0,0 +1 @@
<li class="navListItem"><a class="navItem {% if item.id == currentselected %}navItemActive{% endif %}" href="{{ groupitem.url | relative_url }}">{{ groupitem.title }}</a></li>

View File

@@ -0,0 +1,34 @@
<div id="header_nav">
<div class="navSlideout">
<i class="menuExpand" id="header_nav_expander"><span></span><span></span><span></span></i>
</div>
<nav class="slidingNav">
<ul>
{% for item in site.data.nav %}
<li class="navItem">
{% if item.category == "external" %}
<a href="{{ item.href }}" target="_blank">{{ item.title }}</a>
{% else %}
<a href="{{ item.href | relative_url }}">{{ item.title }}</a>
{% endif %}
</li>
{% endfor %}
{% if site.searchconfig %}
{% include nav_search.html inputselector="search_input_react" %}
{% endif %}
</ul>
</nav>
</div>
<script>
var event = document.createEvent('Event');
event.initEvent('slide', true, true);
document.addEventListener('slide', function (e) {
document.body.classList.toggle('sliderActive');
}, false);
var headerNav = document.getElementById('header_nav');
var headerNavExpander = document.getElementById('header_nav_expander');
headerNavExpander.addEventListener('click', function(e) {
headerNav.classList.toggle('navSlideoutActive');
document.dispatchEvent(event);
}, false);
</script>

View File

@@ -0,0 +1,15 @@
<li class="navSearchWrapper">
<input id="{{ include.inputselector }}" type="search" />
</li>
<script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/1/docsearch.min.js"></script>
<script>
// For Algolia search
(function() {
// Algolia
docsearch({
apiKey: '{{ site.searchconfig.apikey }}',
indexName: '{{ site.searchconfig.indexname }}',
inputSelector: '#{{ include.inputselector }}',
});
}());
</script>

View File

@@ -0,0 +1,3 @@
<div class="pluginBlock allShareBlock">
{% include plugins/like_button.html %}{% include plugins/twitter_share.html %}{% include plugins/google_share.html %}
</div>

View File

@@ -0,0 +1,2 @@
<div class="ascii-cinema pluginBlock"></div>
<script type="text/javascript" src="https://asciinema.org/a/{{ include.href }}.js" id="asciicast-{{ include.href }}" async data-autoplay="true" data-loop="true" data-speed="2" data-t="23"></script>

View File

@@ -0,0 +1,6 @@
<div class="pluginWrapper buttonWrapper">
<a
class="button"
href="{{ include.href }}"
>{{ include.text }}</a>
</div>

View File

@@ -0,0 +1,4 @@
<div class="pluginWrapper ghStarWrapper">
<a aria-label="Star {{ site.ghrepo }} on GitHub" data-count-aria-label="# stargazers on GitHub" data-count-api="/repos/{{ site.ghrepo }}#stargazers_count" data-count-href="/{{ site.ghrepo }}/stargazers" data-style="mega" data-icon="octicon-star" href="https://github.com/{{ site.ghrepo }}" class="github-button">Star</a>
</div>
<script async defer id="github-bjs" src="https://buttons.github.io/buttons.js"></script>

View File

@@ -0,0 +1,4 @@
<div class="pluginWrapper ghWatchWrapper">
<a aria-label="Watch {{ site.ghrepo }} on GitHub" data-count-aria-label="# watchers on GitHub" data-count-api="/repos/{{ site.ghrepo }}#subscribers_count" data-count-href="/{{ site.ghrepo }}/watchers" data-style="mega" data-icon="octicon-eye" href="https://github.com/{{ site.ghrepo }}" class="github-button">Watch</a>
</div>
<script async defer id="github-bjs" src="https://buttons.github.io/buttons.js"></script>

View File

@@ -0,0 +1,5 @@
<div class="pluginBlock">
<div class="g-plusone" data-size="medium"></div>
</div>
<script src="https://apis.google.com/js/platform.js" async defer></script>

View File

@@ -0,0 +1,6 @@
<div class="iframeContent">
<iframe class="pluginIframe" src="{{ include.href }}" seamless></iframe>
</div>
<div class="iframePreview">
{% include plugins/button.html href=include.href text=include.text %}
</div>

View File

@@ -0,0 +1,18 @@
<div class="fb-like pluginWrapper likeButtonWrapper" data-layout="button_count" data-action="like" data-show-faces="true" data-share="true"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '{{ site.fbappid }}',
xfbml : true,
version : 'v2.3'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>

View File

@@ -0,0 +1,6 @@
<div class="pluginRowBlock">
{% for child in include.children %}
{% include plugins/{{child.type}}.html href=child.href text=child.text %}
<div style="width: 20px;"></div>
{% endfor %}
</div>

View File

@@ -0,0 +1,34 @@
<div class="postSocialPlugins">
<a
href="https://twitter.com/share"
class="twitter-share-button"
data-url="{{ page.url | replace:'index.html','' | absolute_url }}"
data-text="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}"
data-hashtags="flowtype">Tweet</a>
<div
class="fb-like"
data-href="{{ page.url | replace:'index.html','' | absolute_url }}"
data-layout="button_count"
data-action="like"
data-show-faces="false"
data-share="true"></div>
</div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '{{ site.fbappid }}',
xfbml : true,
version : 'v2.2'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

View File

@@ -0,0 +1,88 @@
<div class="slideshowBlock pluginWrapper" id="slideshow"></div>
<script>
var slideshowData = [
{% for image in site.data.slideshow %}
{
id : "{{ image.id }}",
imagesrc : "{{ image.src }}",
tooltip : "{{ image.tooltip }}",
href : "{{ image.link }}",
},
{% endfor %}
];
</script>
<script src="http://fb.me/react-with-addons-0.13.1.min.js"></script>
<script type="text/javascript">
var Slideshow = React.createClass({displayName: "Slideshow",
getInitialState: function() {
return {
currentSlide: 0,
};
},
getDefaultProps: function() {
return {
data: slideshowData,
};
},
handleSelect: function(id) {
var index = this.props.data.map(function (el, elIndex) {
return (
elIndex
);
});
var currentIndex = index.indexOf(id);
this.setState({
currentSlide: currentIndex,
});
},
render: function() {
return (
React.createElement("div", {className: "slideshow"},
React.createElement("div", {className: "slides"},
this.props.data.map(this.renderSlide)
),
React.createElement("div", {className: "pagination"},
this.props.data.map(this.renderPager)
)
)
);
},
renderSlide: function(child, index) {
var classes = React.addons.classSet({
'slide': true,
'slideActive': this.state.currentSlide === index,
});
if (child.href) {
return (
React.createElement("div", {key: index, className: classes},
React.createElement("a", {href: child.href, alt: child.tooltip, title: child.tooltip},
React.createElement("img", {src: child.imagesrc, alt: child.tooltip, title: child.tooltip})
)
)
);
}
return (
React.createElement("div", {key: index, className: classes},
React.createElement("img", {src: child.imagesrc, alt: child.tooltip})
)
);
},
renderPager: function(child, index) {
var classes = React.addons.classSet({
'pager': true,
'pagerActive': this.state.currentSlide === index,
});
return (
React.createElement("span", {key: index, className: classes, onClick: this.handleSelect.bind(this, index)})
);
},
});
function render(slideshowData) {
React.render(
React.createElement(Slideshow, {data: slideshowData}),
document.getElementById('slideshow')
);
}
render(slideshowData);
</script>

View File

@@ -0,0 +1,5 @@
<div class="pluginBlock">
<a href="https://twitter.com/{{ include.href }}" class="twitter-follow-button pluginBlock" data-show-count="false">Follow @{{ include.href }}</a>
</div>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

View File

@@ -0,0 +1,4 @@
<div class="pluginWrapper twitterSharePlugin">
<a href="https://twitter.com/share" class="twitter-share-button" data-hashtags="{{ site.title| replace: ' ', '' }}">Tweet</a>
</div>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

35
docs/_includes/post.html Normal file
View File

@@ -0,0 +1,35 @@
<div class="post">
{% assign author = site.data.authors[page.author] %}
<header class="post-header">
{% if author.fbid %}
<div class="authorPhoto">
<img src="http://graph.facebook.com/{{ author.fbid }}/picture/" alt="{{ author.fullname }}" title="{{ author.fullname }}" />
</div>
{% endif %}
{% if author.full_name %}
<p class="post-authorName">{{ author.full_name }}</p>
{% endif %}
<h1 class="post-title">{% if include.truncate %}<a href="{{ page.url | absolute_url }}">{{ page.title }}</a>{% else %}{{ page.title }}{% endif %}</h1>
<p class="post-meta">Posted {{ page.date | date: '%B %d, %Y' }}{% if page.meta %} • {{ page.meta }}{% endif %}</p>
</header>
<article class="post-content">
{% if include.truncate %}
{% if page.content contains '<!--truncate-->' %}
{{ page.content | split:'<!--truncate-->' | first | markdownify }}
<div class="read-more">
<a href="{{ page.url | absolute_url}}" >
Read More
</a>
</div>
{% else %}
{{ page.content | markdownify }}
{% endif %}
{% else %}
{{ content }}
{% endif %}
{% unless include.truncate %}
{% include plugins/all_share.html %}
{% endunless %}
</article>
</div>

View File

@@ -0,0 +1,28 @@
{% if site.data.powered_by.first.items or site.data.powered_by_highlight.first.items %}
<div class="poweredByContainer">
<div class="wrapper mainWrapper poweredByWrapper">
{% if site.data.powered_by_highlight.first.title %}
<h2>{{ site.data.powered_by_highlight.first.title }}</h2>
{% else %}
<h2>{{ site.data.powered_by.first.title }}</h2>
{% endif %}
{% if site.data.powered_by_highlight.first.items %}
<div class="poweredByItems">
{% for item in site.data.powered_by_highlight.first.items %}
<div class="poweredByItem itemLarge">
<a href="{{ item.url }}" target="_blank"><img src="{{ item.img }}" alt="{{ item.name }}" /></a>
</div>
{% endfor %}
</div>
{% endif %}
<div class="poweredByItems">
{% for item in site.data.powered_by.first.items %}
<div class="poweredByItem itemSmall">
<a href="{{ item.url }}" target="_blank">{{ item.name }}</a>
</div>
{% endfor %}
</div>
<div class="poweredByMessage">Does your app use {{ site.title }}? Add it to this list with <a href="https://github.com/{{ site.ghrepo }}/edit/gh-pages/_data/powered_by.yml" target="_blank">a pull request!</a></div>
</div>
</div>
{% endif %}

View File

@@ -0,0 +1,24 @@
<a
href="https://twitter.com/share"
class="twitter-share-button"
data-url="http://facebook.github.io/fresco{{ page.url }}"
data-text="Fresco | {{ page.title }}"
data-hashtags="fresco">Tweet</a>
<div
class="fb-like"
data-href="http://facebook.github.io/fresco{{ page.url }}"
data-layout="standard"
data-action="like"
data-show-faces="true"
data-share="true"></div>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

View File

@@ -0,0 +1 @@
<span class="buttonWrap {{ include.align }}"><a class="button blockButton fbossFontLight pluginBlock margin{{ include.margin }}" target="{{ include.button_target }}" href="{{ include.button_href }}">{{ include.button_text }}</a></span>

12
docs/_layouts/basic.html Normal file
View File

@@ -0,0 +1,12 @@
---
layout: doc_default
---
<div class="mainContainer blogContainer postContainer">
<div id="main_wrap" class="wrapper mainWrapper">
<div class="post basicPost">
{{ content }}
</div>
</div>
</div>

11
docs/_layouts/blog.html Normal file
View File

@@ -0,0 +1,11 @@
---
category: blog
layout: blog_default
---
<div class="mainContainer blogContainer postContainer">
<div id="main_wrap" class="wrapper mainWrapper">
{{ content }}
</div>
</div>

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
{% include head.html %}
<body class="docsNavVisible">
{% include nav.html alwayson=true %}
<div class="navPusher">
<div class="docMainWrapper wrapper">
{% include nav/collection_nav.html navdata=site.posts type="blog" sectionpath="/blog/" sectiontitle="Blog" %}
{{ content }}
</div>
{% include footer.html %}
</div>
</body>
</html>

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
{% include head.html %}
<body>
{% include nav.html alwayson=true %}
<div class="navPusher">
{{ content }}
{% include footer.html %}
</div>
</body>
</html>

View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
{% include head.html %}
<body class="docsNavVisible">
{% include nav.html alwayson=true %}
<div class="navPusher">
<div class="docMainWrapper wrapper">
{% include nav/collection_nav.html navdata=site.data.nav_docs type="docs" sectionpath="/yoga/docs/" sectiontitle="Docs" data_collection=site.docs %}
{{ content }}
</div>
{% include footer.html %}
</div>
</body>
</html>

View File

@@ -0,0 +1,10 @@
---
layout: doc_default
---
<div class="mainContainer documentContainer postContainer">
<div id="main_wrap" class="wrapper mainWrapper">
{{ content }}
</div>
</div>

Some files were not shown because too many files have changed in this diff Show More