-
Notifications
You must be signed in to change notification settings - Fork 563
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
58 changed files
with
957 additions
and
62 deletions.
There are no files selected for viewing
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,15 @@ | ||
name: PR Conventional Commit Validation | ||
|
||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, edited] | ||
|
||
jobs: | ||
validate-pr-title: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: PR Conventional Commit Validation | ||
uses: ytanikin/PRConventionalCommits@1.1.0 | ||
with: | ||
task_types: '["feat","fix","docs","test","ci","refactor","perf","chore","revert"]' | ||
custom_labels: '{"feat": "feature", "fix": "fix", "docs": "documentation", "test": "test", "ci": "CI/CD", "refactor": "refactor", "perf": "performance", "chore": "chore", "revert": "revert"}' |
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
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
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
99 changes: 99 additions & 0 deletions
99
apps/renderer/src/components/ui/lottie-container/index.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,99 @@ | ||
import type { DotLottie } from "@lottiefiles/dotlottie-react" | ||
import { DotLottieReact } from "@lottiefiles/dotlottie-react" | ||
import { atom, useAtomValue } from "jotai" | ||
import type { FC, ReactNode, RefCallback } from "react" | ||
import { useEffect, useState } from "react" | ||
|
||
import { jotaiStore } from "~/lib/jotai" | ||
|
||
import { RootPortal } from "../portal" | ||
|
||
const portalElementsAtom = atom([] as ReactNode[]) | ||
|
||
export function LottieRenderContainer() { | ||
const elements = useAtomValue(portalElementsAtom, { store: jotaiStore }) | ||
|
||
return ( | ||
<RootPortal> | ||
<div className="pointer-events-none fixed z-[999]" data-testid="lottie-render-container"> | ||
{elements.map((element) => element)} | ||
</div> | ||
</RootPortal> | ||
) | ||
} | ||
|
||
type LottieOptions = { | ||
once?: boolean | ||
|
||
x: number | ||
y: number | ||
|
||
height?: number | ||
width?: number | ||
className?: string | ||
|
||
onComplete?: () => void | ||
|
||
speed?: number | ||
} | ||
export const mountLottie = (url: string, options: LottieOptions) => { | ||
const { once = true, height, width, x, y, className, speed } = options | ||
|
||
const Lottie: FC = () => { | ||
const [dotLottie, setDotLottie] = useState<DotLottie | null>(null) | ||
|
||
useEffect(() => { | ||
function onComplete() { | ||
if (once) { | ||
unmount() | ||
} | ||
|
||
options.onComplete?.() | ||
} | ||
|
||
if (dotLottie) { | ||
dotLottie.addEventListener("complete", onComplete) | ||
} | ||
|
||
return () => { | ||
if (dotLottie) { | ||
dotLottie.removeEventListener("complete", onComplete) | ||
} | ||
} | ||
}, [dotLottie]) | ||
|
||
const dotLottieRefCallback: RefCallback<DotLottie> = (dotLottie) => { | ||
setDotLottie(dotLottie) | ||
} | ||
|
||
return ( | ||
<DotLottieReact | ||
speed={speed} | ||
dotLottieRefCallback={dotLottieRefCallback} | ||
src={url} | ||
autoplay | ||
loop={false} | ||
height={height} | ||
width={width} | ||
style={{ | ||
height, | ||
width, | ||
position: "fixed", | ||
|
||
left: 0, | ||
top: 0, | ||
transform: `translate(${x}px, ${y}px)`, | ||
}} | ||
className={className} | ||
/> | ||
) | ||
} | ||
|
||
const element = <Lottie /> | ||
const unmount = () => { | ||
jotaiStore.set(portalElementsAtom, (prev) => prev.filter((e) => e !== element)) | ||
} | ||
|
||
jotaiStore.set(portalElementsAtom, (prev) => [...prev, element]) | ||
return unmount | ||
} |
Oops, something went wrong.