Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Passing Circle's inn as children does not work correctly with the layout #43

Open
TheKnarf opened this issue Nov 20, 2023 · 2 comments
Open

Comments

@TheKnarf
Copy link

Example code:

import { createSignal } from 'solid-js'
import { Bluefish, Group, StackH, StackV, Circle, Text, Ref, Background, Arrow, Align, Distribute, Rect } from "@bluefish-js/solid";

const Table = ({ children, name }) => {
	return (
		<>
			<Background padding={20}>
				<StackV spacing={50}>
				<Text name="label">{name}</Text>
				{ children }
				{/* <Planets /> Passing inn plannets directly works, but doing it as the children variable does not*/}
				</StackV>
			</Background>
		</>
	)
};

const Planets = () => {
	return (
		<>
			<Circle name="mercury" r={15} fill="#EBE3CF" stroke-width={3} stroke="black" />
			<Circle name="venus" r={36} fill="#DC933C" stroke-width={3} stroke="black" />
			<Circle name="earth" r={38} fill="#179DD7" stroke-width={3} stroke="black" />
			<Circle name="mars" r={21} fill="#F1CF8E" stroke-width={3} stroke="black" />
		</>
	)
};

const App = () => {
	return (
		<>
			<div>
				<Bluefish>
					<Table name="users">
						<Planets /> {/* passing it inn as children does not work... */}
					</Table>
				</Bluefish>
			</div>
		</>
	);
};

export default App;

Example repo.

Expected behavior:

Screenshot 2023-11-20 at 19 26 51

Actual behavior:

Screenshot 2023-11-20 at 19 26 37

@joshpoll
Copy link
Contributor

This seems to be a gotcha with solidjs props destructuring:

https://playground.solidjs.com/anonymous/fa811837-def3-497a-938c-f6424acf2f1b

Changing Table to this seems to work:
Screenshot 2023-11-20 at 4 03 20 PM

See also: https://www.solidjs.com/tutorial/props_defaults

@joshpoll
Copy link
Contributor

Another note: It's not documented yet on the site, but when you make new components you should wrap them in withBluefish if you want to be able to name them.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants