Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Added background view with flexible color and offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Abe committed Jan 26, 2020
1 parent 7a05753 commit 4874bc8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/components/Box/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ const Box = ({ children, setup }) => {
width,
height,
margin,
backgroundColor = '#fff',
backgroundOffset = {},
N = { id: 'N' },
S = { id: 'S' },
E = { id: 'E' },
Expand Down Expand Up @@ -40,10 +42,14 @@ const Box = ({ children, setup }) => {
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#fff',
borderRadius: 4,
borderWidth: 0.5,
borderColor: '#000',
},
background: {
backgroundColor: backgroundColor || undefined,
position: 'absolute',
top: backgroundOffset.top ?? 0,
right: backgroundOffset.right ?? 0,
bottom: backgroundOffset.bottom ?? 0,
left: backgroundOffset.left ?? 0,
},
posN: {
...base.pos,
Expand Down Expand Up @@ -107,6 +113,7 @@ const Box = ({ children, setup }) => {

return (
<View style={styles.boxOuter}>
<View style={styles.background} />
{
[N, E, S, W, NE, NW, SE, SW].map((loc) => (
<View
Expand Down
1 change: 1 addition & 0 deletions src/scenes/ScenePlayground.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const setupOffset = {
width: 280,
height: 160,
margin: 0,
backgroundColor: '#ddd',
N: {
id: 'N',
height: 20,
Expand Down

0 comments on commit 4874bc8

Please sign in to comment.