-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Knob valueTemplate="{value}" too limited #1027
Knob valueTemplate="{value}" too limited #1027
Comments
I know but it is SVG so slot cannot be supported. |
I also tried simply changing the innerhtml but it also didn't budge :/ I will fork and see if it maybe works by including a foreignobject tag |
Just a quick example of foreign object implementation, let me know what you think of this or if any issues might occur using this. foreign.vue <template>
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<polygon points="5,5 195,10 185,185 10,195" />
<foreignObject
:x="foreignobjdata.x"
:y="foreignobjdata.y"
:width="foreignobjdata.width"
:height="foreignobjdata.height"
>
<div xmlns="http://www.w3.org/1999/xhtml">
<p>{{ textobj }}</p>
<slot></slot>
<p>
{{ outsidetext }}
</p>
</div>
</foreignObject>
{{ foreignobjdata }}
</svg>
</template>
<script>
import { computed, reactive, ref, toRefs } from "vue";
export default {
props: {
outsidetext: {
type: String,
},
},
setup(props) {
const foreignobjdata = reactive({
x: 20,
z: 20,
width: 160,
height: 160,
});
const textobj = ref("helloworld");
const { outsidetext } = toRefs(props);
return {
textobj,
outsidetext,
foreignobjdata,
};
},
};
</script>
<style scoped>
div {
color: white;
font: 18px serif;
height: 100%;
overflow: auto;
}
</style> app.vue <template>
<div>
<foreign outsidetext="🔥prop from parent🔥">
<p>{{ slottext }}</p>
</foreign>
</div>
<input v-model="slottext" type="text" />
</template>
<script>
import { ref } from "vue";
import foreign from "./components/foreign.vue";
export default {
name: "App",
components: {
foreign,
},
setup() {
const slottext = ref("hello");
return {
slottext,
};
},
};
</script>
|
Fixed #1027 - Knob: Allow a label function for greater flexibility
In the case where I would want the value template to be something other than the value.
Say for example a computed property where it changes the numeric value to a date.
At the moment we are limited to only
{value}x
Perhaps a
slot
would be better for a custom value?The text was updated successfully, but these errors were encountered: