Skip to content

Commit cacf66e

Browse files
CSS Grid 1/9: Grid style types and public API
Summary: - Add foundational data types, enums, style properties, and C API for expressing CSS Grid layouts - Includes `GridLine.h`, `GridTrack.h`, `GridTrackType.h`, `Display::Grid`, new alignment enums (`Align::Start/End`, `Justify::Auto/Stretch/Start/End`) - C API: `YGGridTrackList.h/cpp`, `YGNodeStyle` grid setters/getters - Layout helper updates, `Node.h` `relativePosition` made public Split from facebook/yoga#1865. Part of the CSS Grid implementation series. X-link: facebook/yoga#1893 Differential Revision: D94867121 Pulled By: NickGerleman
1 parent 7516d74 commit cacf66e

5 files changed

Lines changed: 16 additions & 6 deletions

File tree

packages/react-native/React/Views/RCTLayout.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,12 @@ RCTDisplayType RCTReactDisplayTypeFromYogaDisplayType(YGDisplay displayType)
128128
{
129129
switch (displayType) {
130130
case YGDisplayFlex:
131+
case YGDisplayContents:
132+
case YGDisplayGrid:
131133
return RCTDisplayTypeFlex;
132134
case YGDisplayNone:
133135
return RCTDisplayTypeNone;
134-
case YGDisplayContents:
135-
RCTAssert(NO, @"YGDisplayContents cannot be converted to RCTDisplayType value.");
136-
return RCTDisplayTypeNone;
136+
default:
137+
return RCTDisplayTypeFlex;
137138
}
138139
}

packages/react-native/ReactCommon/react/renderer/components/view/conversions.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ inline DisplayType displayTypeFromYGDisplay(YGDisplay display)
133133
return DisplayType::Contents;
134134
case YGDisplayFlex:
135135
return DisplayType::Flex;
136+
case YGDisplayGrid:
137+
return DisplayType::Grid;
136138
}
137139
}
138140

packages/react-native/ReactCommon/react/renderer/core/LayoutMetrics.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,11 @@ std::vector<DebugStringConvertibleObject> getDebugProps(
4444
",bottom:" + getDebugDescription(object.overflowInset.bottom, {}) +
4545
",left:" + getDebugDescription(object.overflowInset.left, {}) + "}"},
4646
{.name = "displayType",
47-
.value = object.displayType == DisplayType::None
48-
? "None"
49-
: (object.displayType == DisplayType::Flex ? "Flex" : "Inline")},
47+
.value = object.displayType == DisplayType::None ? "None"
48+
: object.displayType == DisplayType::Flex ? "Flex"
49+
: object.displayType == DisplayType::Grid ? "Grid"
50+
: object.displayType == DisplayType::Contents ? "Contents"
51+
: "Unknown"},
5052
{.name = "layoutDirection",
5153
.value = object.layoutDirection == LayoutDirection::Undefined
5254
? "Undefined"

packages/react-native/ReactCommon/react/renderer/core/LayoutPrimitives.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ enum class DisplayType {
2020
None = 0,
2121
Flex = 1,
2222
Contents = 2,
23+
Grid = 3,
2324
};
2425

2526
enum class PositionType {

packages/react-native/ReactCommon/react/renderer/core/conversions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ inline int toInt(const DisplayType &displayType)
4444
return 1;
4545
case DisplayType::Contents:
4646
return 2;
47+
case DisplayType::Grid:
48+
return 3;
4749
}
4850
}
4951

@@ -56,6 +58,8 @@ inline std::string toString(const DisplayType &displayType)
5658
return "flex";
5759
case DisplayType::Contents:
5860
return "contents";
61+
case DisplayType::Grid:
62+
return "grid";
5963
}
6064
}
6165

0 commit comments

Comments
 (0)