Auto shrink / grow on text values

When we all start to code in Wix we as developers do not see the effects on when I query a data collection and I just set the buttons label to a value from the data collection.

This means that if a designer have designed a button, text they depend on that being that size and they don’t want me as a developer to f**k that up.

So I want a function where a designer can click “LOCK SIZE” on those elements that have text inside. If that’s the case the amount of text sent to that element should be automatically shrunk or grown to fit that element.

Do you understand?

It will make work between coders and designers super.

2 Likes

Hey Andreas,

You could do this in code. First you’d read the text from the collection, then you’d cut out the first x number of characters, and finally you’d assign that the new label for the button.

How would that code look like? I have tried this

$w.onReady(function () {
 // set how many characters to display on the button
     const textLength = 12;
     $w("#dynamicDataset").onReady(function () {
         // set the originalText variable to be the contents from the collection
         let originalText = $w("#dynamicDataset").getCurrentItem().textField;
         // set the button label to be the first textLength characters of the text from the collection
         $w('#buttonID').label = originalText.substr(0, textLength);
    });
});

Ah you misunderstood me, I want to dynamically change font size to that any value from dc fits.