Skip to content
This repository was archived by the owner on Feb 19, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions demo/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ class App extends Component {
style={{
background: colors.shade1
}}
constraints={[
constrain.subview("note").centerX.to.equal.superview.centerX,
constrain.subview("note").centerY.to.equal.superview.centerY
]}
>
<AutoDOM.p
name="note"
style={{...styles.box, fontSize: "16px", border: 0}}
intrinsicWidth={300}
intrinsicHeight={45}
constraints={[
constrain.subview("note").centerX.to.equal.superview.centerX,
constrain.subview("note").centerY.to.equal.superview.centerY
]}
>
Worst clock ever! Resize the window for full effect.
</AutoDOM.p>
Expand Down
9 changes: 7 additions & 2 deletions src/superview.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
import type { SubView } from "autolayout";
import type { Element } from "react";
import type LayoutClient from "./layout-client";
import type ConstraintBuilder from "./constraint-builder";

import { Component, PropTypes, createElement } from "react";
import UUID from "./uuid";
import extractLayoutProps from "./extract-layout-props";

type Props = {
name: string,
constraints: ?Array<ConstraintBuilder>,
container: ReactClass,
children: ReactPropTypes.node,
width: number,
Expand Down Expand Up @@ -48,13 +50,16 @@ class Superview extends Component {

componentDidMount() {
const {
container, children, name, width, height, spacing
constraints, container, children, name, width, height, spacing
} = this.props;
const size = { width, height };
const { client } = this.context;

const element = createElement(container, null, children);
const layoutProps = extractLayoutProps(element);
const layoutProps = extractLayoutProps(element)
.concat(constraints ? {
constraints: constraints.map((c) => c.build())
} : []);

client.registerView(name, size, spacing, () => {
client.run("initializeSubviews", {
Expand Down