1
0
Fork 0
mirror of synced 2024-07-03 05:20:32 +12:00

Mark individual styles as changed if they have been changed

This commit is contained in:
Andrew Kingston 2021-01-05 11:59:19 +00:00
parent 57d69d1c9a
commit 207eaed27b

View file

@ -10,25 +10,27 @@
export let onStyleChanged = () => {}
export let open = false
const hasPropChanged = prop => {
if (prop.initialValue !== undefined) {
return style[prop.key] !== prop.initialValue
}
return style[prop.key] != null && style[prop.key] !== ""
}
$: style = componentInstance["_styles"][styleCategory] || {}
$: changed = properties.some(
prop =>
style[prop.key] != null &&
style[prop.key] !== "" &&
style[prop.key] !== prop.initialValue
)
$: changed = properties.some(prop => hasPropChanged(prop))
</script>
<DetailSummary name={`${name}${changed ? ' *' : ''}`} on:open show={open} thin>
<div>
{#each properties as props}
{#each properties as prop}
<PropertyControl
label={props.label}
control={props.control}
key={props.key}
value={style[props.key]}
label={`${prop.label}${hasPropChanged(prop) ? ' *' : ''}`}
control={prop.control}
key={prop.key}
value={style[prop.key]}
onChange={(key, value) => onStyleChanged(styleCategory, key, value)}
props={{ ...excludeProps(props, ['control', 'label']) }} />
props={{ ...excludeProps(prop, ['control', 'label']) }} />
{/each}
</div>
</DetailSummary>