-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
can toggle selected artboard version layer from resource route
- Loading branch information
Showing
3 changed files
with
154 additions
and
37 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
app/components/templates/panel/dashboard-entity-panel.actions.toggle-selected.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { memo, useCallback } from 'react' | ||
import { type IArtboardVersion } from '#app/models/artboard-version/artboard-version.server' | ||
import { type ILayer } from '#app/models/layer/layer.server' | ||
import { ArtboardVersionLayerToggleSelected } from '#app/routes/resources+/api.v1+/artboard-version.layer.update.selected' | ||
import { | ||
type entityParentTypeEnum, | ||
type entityTypeEnum, | ||
type IEntityParentType, | ||
type IEntitySelectable, | ||
EntityType, | ||
EntityParentType, | ||
} from '#app/schema/entity' | ||
import { type IDashboardPanelSelectEntityStrategy } from '#app/strategies/component/dashboard-panel/select-entity.strategy' | ||
|
||
interface ToggleSelectedChildEntityFormProps { | ||
entityType: entityTypeEnum | ||
parentType?: entityParentTypeEnum | ||
entity: IEntitySelectable | ||
parent: IEntityParentType | ||
} | ||
|
||
const ArtboardVersionToggleSelectedChildEntityForm = memo( | ||
({ entityType, entity, parent }: ToggleSelectedChildEntityFormProps) => { | ||
switch (entityType) { | ||
case EntityType.LAYER: | ||
return ( | ||
<ArtboardVersionLayerToggleSelected | ||
layer={entity as ILayer} | ||
version={parent as IArtboardVersion} | ||
/> | ||
) | ||
default: | ||
console.log('unknown artboard version entity type', entityType) | ||
return null | ||
} | ||
}, | ||
) | ||
ArtboardVersionToggleSelectedChildEntityForm.displayName = | ||
'ArtboardVersionToggleSelectedChildEntityForm' | ||
|
||
const ToggleSelectedEntityForm = memo( | ||
({ | ||
parentType, | ||
entityType, | ||
entity, | ||
parent, | ||
}: ToggleSelectedChildEntityFormProps) => { | ||
switch (parentType) { | ||
case EntityParentType.ARTBOARD_VERSION: | ||
return ( | ||
<ArtboardVersionToggleSelectedChildEntityForm | ||
entityType={entityType} | ||
entity={entity} | ||
parent={parent} | ||
/> | ||
) | ||
default: | ||
console.log('unknown parent type', parentType) | ||
return null | ||
} | ||
}, | ||
) | ||
ToggleSelectedEntityForm.displayName = 'ToggleSelectedEntityForm' | ||
|
||
export const PanelEntityToggleSelectedAction = ({ | ||
entity, | ||
parent, | ||
strategyEntitySelect, | ||
}: { | ||
entity: IEntitySelectable | ||
parent: IEntityParentType | ||
strategyEntitySelect: IDashboardPanelSelectEntityStrategy | ||
}) => { | ||
const { entityType, parentType } = strategyEntitySelect | ||
|
||
const toggleSelectedEntityForm = useCallback( | ||
() => ( | ||
<ToggleSelectedEntityForm | ||
parentType={parentType} | ||
entityType={entityType} | ||
entity={entity} | ||
parent={parent} | ||
/> | ||
), | ||
[parentType, entityType, entity, parent], | ||
) | ||
|
||
return toggleSelectedEntityForm() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters