0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-21 23:12:35 -05:00
penpot-exporter-figma-plugin/ui-src/parser/creators/symbols/symbolTouched.ts

36 lines
1.1 KiB
TypeScript
Raw Normal View History

import { SyncGroups } from '@ui/lib/types/utils/syncGroups';
import { componentProperties } from '@ui/parser';
import { ComponentPropertyReference } from '@ui/types';
export const symbolTouched = (
visible: boolean | undefined,
characters: string | undefined,
touched: SyncGroups[] | undefined,
componentPropertyReferences: ComponentPropertyReference | undefined
): SyncGroups[] | undefined => {
if (!componentPropertyReferences) {
return touched;
}
const propertyReferenceVisible = componentPropertyReferences.visible;
const propertyReferenceCharacters = componentPropertyReferences.characters;
if (
propertyReferenceVisible &&
visible !== componentProperties.get(propertyReferenceVisible)?.defaultValue &&
!touched?.includes(':visibility-group')
) {
touched?.push(':visibility-group');
}
if (
propertyReferenceCharacters &&
characters !== componentProperties.get(propertyReferenceCharacters)?.defaultValue &&
!touched?.includes(':content-group')
) {
touched?.push(':content-group');
}
return touched;
};