-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from simpleweb/issue-44
Layout fixes
- Loading branch information
Showing
2 changed files
with
82 additions
and
54 deletions.
There are no files selected for viewing
104 changes: 56 additions & 48 deletions
104
generators/base/templates/App/Components/Layout/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,66 @@ | ||
// @flow | ||
import * as React from 'react'; | ||
|
||
import { FullView, CenterView, ScrollView, PaddedView } from './styles'; | ||
import * as React from "react"; | ||
import { | ||
View, | ||
CenterVerticallyView, | ||
FullView, | ||
CenterView, | ||
ScrollView, | ||
PaddedView, | ||
} from "./styles"; | ||
|
||
type Props = { | ||
children: React.Node, | ||
style?: any, | ||
}; | ||
|
||
function Full(props: Props): React.Node { | ||
const { children, style } = props; | ||
|
||
return ( | ||
<FullView style={ style }> | ||
{children} | ||
</FullView> | ||
); | ||
} | ||
|
||
function Center(props: Props): React.Node { | ||
const { children, style } = props; | ||
|
||
return ( | ||
<CenterView style={ style }> | ||
{children} | ||
</CenterView> | ||
); | ||
} | ||
|
||
function Scroll(props: Props): React.Node { | ||
const { children, style } = props; | ||
|
||
return ( | ||
<ScrollView style={ style }> | ||
{children} | ||
</ScrollView> | ||
); | ||
} | ||
|
||
function Padded(props: Props): React.Node { | ||
const { children, style } = props; | ||
|
||
return ( | ||
<PaddedView style={ style }> | ||
{children} | ||
</PaddedView> | ||
); | ||
} | ||
|
||
const Layout: Object = { | ||
Full, | ||
Center, | ||
Scroll, | ||
Padded, | ||
type FullProps = Props & { | ||
align?: "top" | "bottom", | ||
header?: boolean, | ||
footer?: boolean, | ||
}; | ||
|
||
type ScrollProps = Props & { | ||
header?: boolean, | ||
footer?: boolean, | ||
}; | ||
|
||
type CenterProps = Props & {}; | ||
|
||
type CenterVerticallyProps = Props & {}; | ||
|
||
type PaddedProps = Props & {}; | ||
|
||
const Layout = ({ children, ...rest }: Props): React.Node => ( | ||
<View {...rest}>{children}</View> | ||
); | ||
|
||
Layout.Full = ({ children, ...rest }: FullProps): React.Node => ( | ||
<FullView {...rest}>{children}</FullView> | ||
); | ||
Layout.Full.displayName = "Layout.Full"; | ||
|
||
Layout.Center = ({ children, ...rest }: CenterProps): React.Node => ( | ||
<CenterView {...rest}>{children}</CenterView> | ||
); | ||
Layout.Center.displayName = "Layout.Center"; | ||
|
||
Layout.Scroll = ({ children, ...rest }: ScrollProps): React.Node => ( | ||
<ScrollView {...rest}>{children}</ScrollView> | ||
); | ||
Layout.Scroll.displayName = "Layout.Scroll"; | ||
|
||
Layout.Padded = ({ children, ...rest }: PaddedProps): React.Node => ( | ||
<PaddedView {...rest}>{children}</PaddedView> | ||
); | ||
Layout.Padded.displayName = "Layout.Padded"; | ||
|
||
Layout.CenterVertically = ({ | ||
children, | ||
...rest | ||
}: CenterVerticallyProps): React.Node => ( | ||
<CenterVerticallyView {...rest}>{children}</CenterVerticallyView> | ||
); | ||
Layout.CenterVertically.displayName = "Layout.CenterVertically"; | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters