-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
320 additions
and
158 deletions.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
...builder/app/builder/features/settings-panel/props-section/animation/animation-section.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,87 @@ | ||
import { | ||
Grid, | ||
theme, | ||
Select, | ||
Label, | ||
Separator, | ||
Box, | ||
toast, | ||
} from "@webstudio-is/design-system"; | ||
import { useIds } from "~/shared/form-utils"; | ||
import type { PropAndMeta } from "../use-props-logic"; | ||
import type { AnimationAction } from "@webstudio-is/sdk"; | ||
import { toPascalCase } from "~/builder/features/style-panel/shared/keyword-utils"; | ||
import { animationActionSchema } from "@webstudio-is/sdk"; | ||
|
||
const animationTypes = [ | ||
"scroll", | ||
"view", | ||
] as const satisfies AnimationAction["type"][]; | ||
|
||
const animationTypeDescription: Record<AnimationAction["type"], string> = { | ||
scroll: | ||
"Scroll-based animations are triggered and controlled by the user’s scroll position.", | ||
view: "View-based animations occur when an element enters or exits the viewport. They rely on the element’s visibility rather than the scroll position.", | ||
}; | ||
|
||
const defaultActionValue: AnimationAction = { | ||
type: "scroll", | ||
animations: [], | ||
}; | ||
|
||
export const AnimateSection = ({ | ||
animationAction, | ||
onChange, | ||
}: { | ||
animationAction: PropAndMeta; | ||
onChange: (value: AnimationAction) => void; | ||
}) => { | ||
const fieldIds = useIds(["type"] as const); | ||
|
||
const { prop } = animationAction; | ||
|
||
const value: AnimationAction = | ||
prop?.type === "animationAction" ? prop.value : defaultActionValue; | ||
|
||
return ( | ||
<Grid | ||
css={{ | ||
paddingBottom: theme.panel.paddingBlock, | ||
}} | ||
> | ||
<Box css={{ height: theme.panel.paddingBlock }} /> | ||
<Separator /> | ||
<Box css={{ height: theme.panel.paddingBlock }} /> | ||
<Grid gap={1} css={{ paddingInline: theme.panel.paddingInline }}> | ||
<Label htmlFor={fieldIds.type}>Animation Type</Label> | ||
<Select | ||
options={animationTypes} | ||
// getValue={(docType: (typeof documentTypes)[number]) => docType} | ||
getLabel={(animationType: AnimationAction["type"]) => | ||
toPascalCase(animationType) | ||
} | ||
value={value.type} | ||
getDescription={(animationType: AnimationAction["type"]) => ( | ||
<Box | ||
css={{ | ||
width: theme.spacing[28], | ||
}} | ||
> | ||
{animationTypeDescription[animationType]} | ||
</Box> | ||
)} | ||
onChange={(typeValue) => { | ||
const newValue = { ...value, type: typeValue }; | ||
const parsedValue = animationActionSchema.safeParse(newValue); | ||
if (parsedValue.success) { | ||
onChange(parsedValue.data); | ||
return; | ||
} | ||
|
||
toast.error("Schemas are incompatible, try fix"); | ||
}} | ||
/> | ||
</Grid> | ||
</Grid> | ||
); | ||
}; |
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
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
Submodule private-src
updated
from a8a2f1 to 5a1c40
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
140 changes: 0 additions & 140 deletions
140
packages/sdk-components-animation/src/shared/animation-types.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.