→ I’m generally dimensioning things so if there was a way to apply a dimension to a specific object, regardless of its nesting position, that would help!
it does work but it doesn’t update when the state of the icon changes. It has two states, one, “Dense” makes the icon 16px. The other one is Normal and it makes the icon 20px. That was what I needed. Sorry, I completely forgot to mention that.
Well the bottom one is definitely the funkier implementation with a live update of the dim value. How cool is that! I will look at the code. I tried until 0100am last night to get this to work.
THANK YOU!
The next thing is I need the margin to be adjusted so the leader line does not overlap the icon container border. I tried to amalgamate two scripts from previous cases but something is not right. I think it is the way that I try to use the variable “margin” inside the css?
// adjust margin according to button size
let DIM = targetCells[0];
let measureElement = targetCells[1].DOMElement;
// this function measures the measureElement and updates the DIM Margin
const updateMargin = () => {
let rect = measureElement.getBoundingClientRect();
let width = Math.round(rect.width);
let margin = 20 + width + 'px'
let state = DIM.widget.states.find(s => s.name == "Right");
at.cellSetPropertyInState(targetCells[0], "customCSS", "margin: margin;", state);
}
// add a resize-observer to update the margin:
const ro = new ResizeObserver(entries => {
updateMargin();
});
ro.observe(measureElement);
// we want the correct value on load:
updateMargin();
It is not the correct value but I wanted to try if this script had any effect. Alas, no
Is the way that I reference the variable the problem?
the problem is this parameter. You have basically two possibilities to concat two strings: "margin:" + margin + ";" or use the back-tick “`”: `margin: ${margin};`