astro-ui icon indicating copy to clipboard operation
astro-ui copied to clipboard

Added in-line styling for XElement

Open lostra01 opened this issue 3 years ago • 1 comments
trafficstars

Added in-line styling options for XElement that eliminates the need of manually setting the style from JS.

Create a templated style - with variables if needed, then pass it into define:style (in the same manner as define:vars works)

eg:

---
const Height = Astro.props.Height;
const Color = Astro.props.Color;
const divStyle = `
    background-color: ${Color};
    height: ${Height};
    width: 100%;
`;
---

<XElement define:style={{divStyle}} />

lostra01 avatar Jan 21 '22 10:01 lostra01

Following our conversation regaring having define:styles into @styles Moved the logic of the code into the correct place, just need to test this,

aFuzzyBear avatar Jan 21 '22 14:01 aFuzzyBear