Skip to content

Commit 5846a10

Browse files
committed
Meh
1 parent a0dc4ff commit 5846a10

File tree

2 files changed

+10
-5
lines changed
  • apps/scene-ui-examples/src
  • packages/hmans-scene-ui/src/components

2 files changed

+10
-5
lines changed

apps/scene-ui-examples/src/App.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import "r3f-stage/styles.css"
22
import { Application } from "r3f-stage"
33
import * as UI from "@hmans/scene-ui"
4+
import { RectProps } from "@hmans/scene-ui"
45

56
export const App = () => {
67
return (
78
<Application>
89
<UI.Canvas width={8} height={4} debug>
9-
<UI.Rect left={"50%"} top={"100%"} bottom={0} right={"50%"}>
10-
<UI.Rect top={-1.25} bottom={0.25} left={2} right={2} />
11-
</UI.Rect>
10+
<BottomCenter>
11+
<UI.Rect bottom={1.5} width={4} height={1} />
12+
</BottomCenter>
1213
</UI.Canvas>
1314
</Application>
1415
)
1516
}
17+
18+
const BottomCenter = (props: RectProps) => (
19+
<UI.Rect left={"50%"} top={"100%"} bottom={0} right={"50%"} {...props} />
20+
)

packages/hmans-scene-ui/src/components/Rect.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ export const Rect = ({
7272
const bottom = resolveRatio(_bottom, parent.height)
7373
const left = resolveRatio(_left, parent.width)
7474

75-
const width = parent.width - left - right
76-
const height = parent.height - top - bottom
75+
const width = _width ? _width : parent.width - left - right
76+
const height = _height ? _height : parent.height - top - bottom
7777

7878
return (
7979
<group {...props}>

0 commit comments

Comments
 (0)