astro-ui
astro-ui copied to clipboard
Added in-line styling for XElement
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}} />
Following our conversation regaring having define:styles into @styles
Moved the logic of the code into the correct place, just need to test this,