Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support dashed attributes #41

Closed
kevinresol opened this issue May 19, 2020 · 3 comments
Closed

Support dashed attributes #41

kevinresol opened this issue May 19, 2020 · 3 comments

Comments

@kevinresol
Copy link
Member

kevinresol commented May 19, 2020

https://github.com/react-spring/react-three-fiber/blob/master/api.md#piercing-into-nested-properties

<mesh rotation-x={1} />

I vaguely recall that hxx supports dotted attributes e.g. <mesh rotation.x={1}/> could we exploit that and make it generate dashes? Edit: ignore this, as dot syntax has its own semantics

@kevinresol
Copy link
Member Author

And this drills down to some nasty dynamic typings. For example, the following code modifies the opacity field of material, but only some material types (e.g. StandardMeshMaterial) would have that field.

<mesh material-opacity={0.5} />

perhaps it is easier to just allow untyped in hxx, though not sure what the syntax should be...

<mesh untyped material-opacity={0.5} />

@kevinresol
Copy link
Member Author

kevinresol commented May 19, 2020

Currently I hacked the custom attribute regex with this:

class Setup {
	public static function all() {
		var NAMELESS = '';
		var def = macro class BaseAttr {
			@:hxxCustomAttributes(~/(.*-.*)/)
			@:optional var $NAMELESS:Dynamic;
		}
		def.pack = ['react', 'three_fiber'];
		def.kind = TDStructure;
		Context.defineType(def);
	}
}

and extending this BaseAttr would do what I needed

@back2dos
Copy link
Member

Moved to coconut.react-core

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

No branches or pull requests

2 participants