File tree Expand file tree Collapse file tree 6 files changed +28
-4
lines changed
Expand file tree Collapse file tree 6 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,6 @@ export class Codegen {
8282 const assetNode = checkAssetNode ( node )
8383 if ( assetNode ) {
8484 const props = await getProps ( node )
85- console . log ( 'props' , props )
8685 props . src = `/${ assetNode === 'svg' ? 'icons' : 'images' } /${ node . name } .${ assetNode } `
8786 if ( assetNode === 'svg' ) {
8887 const maskColor = await checkSameColor ( node )
Original file line number Diff line number Diff line change @@ -22,7 +22,6 @@ import { getVisibilityProps } from './visibility'
2222export async function getProps (
2323 node : SceneNode ,
2424) : Promise < Record < string , unknown > > {
25- console . log ( 'getProps' , getLayoutProps ( node ) )
2625 return {
2726 ...getAutoLayoutProps ( node ) ,
2827 ...getMinMaxProps ( node ) ,
Original file line number Diff line number Diff line change 11import { addPx } from '../utils/add-px'
2+ import { checkAssetNode } from '../utils/check-asset-node'
23import { isPageRoot } from '../utils/is-page-root'
34
45export function isFreelayout ( node : BaseNode & ChildrenMixin ) {
@@ -105,6 +106,7 @@ export function getPositionProps(
105106 }
106107 if (
107108 'children' in node &&
109+ ! checkAssetNode ( node ) &&
108110 ( node . children . some (
109111 ( child ) =>
110112 'layoutPositioning' in child && child . layoutPositioning === 'ABSOLUTE' ,
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { canBeAbsolute } from './position'
44export function getTransformProps (
55 node : SceneNode ,
66) : Record < string , boolean | string | number | undefined | null > | undefined {
7- if ( 'rotation' in node && node . rotation !== 0 )
7+ if ( 'rotation' in node && Math . abs ( node . rotation ) > 0.01 )
88 return {
99 transform : `rotate(${ fmtPct ( - node . rotation ) } deg)` ,
1010 transformOrigin : canBeAbsolute ( node ) ? 'top left' : undefined ,
Original file line number Diff line number Diff line change @@ -57,7 +57,6 @@ export class ResponsiveCodegen {
5757 const tree = await codegen . getTree ( )
5858 breakpointTrees . set ( bp , tree )
5959 }
60- console . log ( 'breakpointTrees' , breakpointTrees )
6160
6261 // Merge trees and generate code.
6362 return this . generateMergedCode ( breakpointTrees , 0 )
Original file line number Diff line number Diff line change 1+ function hasSmartAnimateReaction ( node : BaseNode | null ) : boolean {
2+ if ( ! node || node . type === 'DOCUMENT' || node . type === 'PAGE' ) return false
3+ if (
4+ 'reactions' in node &&
5+ node . reactions ?. some ( ( reaction ) =>
6+ reaction . actions ?. some (
7+ ( action ) =>
8+ action . type === 'NODE' && action . transition ?. type === 'SMART_ANIMATE' ,
9+ ) ,
10+ )
11+ )
12+ return true
13+ return false
14+ }
15+
16+ function isAnimationTarget ( node : SceneNode ) : boolean {
17+ // Check if node itself has SMART_ANIMATE
18+ if ( hasSmartAnimateReaction ( node ) ) return true
19+ // Check if parent has SMART_ANIMATE (node is animation target as child)
20+ if ( node . parent && hasSmartAnimateReaction ( node . parent ) ) return true
21+ return false
22+ }
23+
124export function checkAssetNode ( node : SceneNode ) : 'svg' | 'png' | null {
225 if ( node . type === 'TEXT' || node . type === 'COMPONENT_SET' ) return null
26+ // if node is an animation target (has keyframes), it should not be treated as an asset
27+ if ( isAnimationTarget ( node ) ) return null
328 // vector must be svg
429 if ( [ 'VECTOR' , 'STAR' , 'POLYGON' ] . includes ( node . type ) ) return 'svg'
530 // ellipse with inner radius must be svg
You can’t perform that action at this time.
0 commit comments