Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/studio/src/lib/editor/engine/style/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ export class StyleManager {
update(style: string, value: string) {
const styleObj = { [style]: value };
const action = this.getUpdateStyleAction(styleObj);

if (!value) {
const updatedTargets = action.targets.map((target) => ({
...target,
change: {
...target.change,
update: {
[style]: {
value: '',
type: StyleChangeType.Value,
},
},
},
}));
action.targets = updatedTargets;
}
this.editorEngine.action.run(action);
this.updateStyleNoAction(styleObj);
}
Expand Down
6 changes: 4 additions & 2 deletions apps/studio/src/lib/editor/engine/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,8 @@ export class ThemeManager {

// Refresh colors after deletion
this.scanConfig();

await this.editorEngine.webviews.reloadWebviews();
} catch (error) {
console.error('Error deleting color:', error);
}
Expand Down Expand Up @@ -376,10 +378,10 @@ export class ThemeManager {
});

// Refresh colors after update
this.scanConfig();
await this.scanConfig();

// Force a theme refresh for all frames
await this.editorEngine.webviews.reloadWebviews();
this.editorEngine.webviews.reloadWebviews();
}
} catch (error) {
console.error('Error updating color:', error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ const ColorInput = observer(

// Update color state when getColor changes
const [color, setColor] = useState(getColor);

useEffect(() => {
const styles = editorEngine.style.selectedStyle?.styles || {};
const currentValue = elementStyle.getValue(styles);

if (currentValue && !currentValue.startsWith('#')) {
const colorExists = editorEngine.theme.getColorByName(currentValue);

if (!colorExists) {
const defaultColor = Color.from(elementStyle.defaultValue);
sendStyleUpdate(defaultColor);
}
}
}, [editorEngine.theme.colorGroups, editorEngine.theme.colorDefaults]);

useEffect(() => {
if (!isFocused) {
setColor(getColor);
Expand Down