Git Product home page Git Product logo

Comments (3)

kitschpatrol avatar kitschpatrol commented on June 6, 2024

Hi, thanks for using the library and contributing this idea for a new feature!

First I just want to make sure components like <List> and <RadioGrid> are on your radar, since they make it easy to create select and radio button controls, for example:

<script lang="ts">
	import { List, RadioGrid } from 'svelte-tweakpane-ui';
	let value: string;
</script>

<List bind:value options={{ 'Alpha Label': 'alpha', 'Beta Label': 'beta' }} />
<RadioGrid bind:value values={['alpha', 'beta']} />

The <AutoObject> (and <AutoValue>) components trade configurability for convenience, since they use the same object or value to both define the structure of the UI and react to control changes. Because of this, the tricky thing here would be how to separate defining the list options from the state value representing the active selection:

// Hypothetical, not currently implemented!
<script lang="ts">
	import { AutoObject } from 'svelte-tweakpane-ui';
	let object = {
	  myKey: ['alpha', 'beta']
	};
</script>

<AutoObject bind:object >
{object.myKey} // ???

The only ways that I can think of to disambiguate state from configuration are:

A. Add a prop with additional configuration to define the list, at which point I think it makes more sense to use the more specific components like <List> that already have props for this.

B. Come up with a special object shape that puts the selected value state alongside the list definition. I guess <AutoObject> could look for a type like { [key: string]: { value: T; options: T[] }; }, so the example above would become:

// Hypothetical, not currently implemented!
<script lang="ts">
	import { AutoObject } from 'svelte-tweakpane-ui';
	let object = { 
		myKey: { value: 'alpha', options: ['alpha', 'beta'] }
	};
</script>

<AutoObject bind:object >
{object.myKey.value} // alpha

There's some precedent for this kind of magic control inference in vanilla Tweakpane, and that's mirrored in how <AutoObject> infers color and point controls based on object shape... but for lists, I think vanilla Tweakpane always separates the list options from the bound value, like in this example, so I'm not sure if a special object shape would end up creating more confusion than convenience. (Though we might have some room for magic in a component with "Auto" in its name...)

Open to your ideas — it would be great to hear a bit more info on how you envisioned binding working. I could be missing something obvious.

from svelte-tweakpane-ui.

m4nh avatar m4nh commented on June 6, 2024

Thank you very much for the response. I hadn't grasped the concept of Value Binding; indeed, it only makes sense when Value and UI Configuration coincide, so it's complex with Lists, and anyway, it would undermine the utility of AutoObject.

We will try to use the components separately for our application. However, if I come up with an elegant idea to solve the problem, I'll propose it to you :)

from svelte-tweakpane-ui.

kitschpatrol avatar kitschpatrol commented on June 6, 2024

Sounds good, thanks for the discussion and good luck with your project.

from svelte-tweakpane-ui.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.