Skip to content

Commit c90fad3

Browse files
authored
fix: update react lottie library (Sofie-Automation#1659)
* fix: downgrade lottie * fix: switch to lottie-react This library is better maintained and is vastly more popular Funnily, this is the reverse of Sofie-Automation@34b59ba
1 parent fe14565 commit c90fad3

5 files changed

Lines changed: 47 additions & 34 deletions

File tree

packages/webui/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"license-validate": "run -T sofie-licensecheck"
3131
},
3232
"dependencies": {
33-
"@crello/react-lottie": "0.0.11",
3433
"@fortawesome/fontawesome-free": "^7.1.0",
3534
"@fortawesome/fontawesome-svg-core": "^7.1.0",
3635
"@fortawesome/free-solid-svg-icons": "^7.1.0",
@@ -52,7 +51,7 @@
5251
"i18next-browser-languagedetector": "^8.2.0",
5352
"i18next-http-backend": "^3.0.2",
5453
"immutability-helper": "^3.1.1",
55-
"lottie-web": "^5.13.0",
54+
"lottie-react": "^2.4.1",
5655
"moment": "^2.30.1",
5756
"motion": "^12.31.0",
5857
"promise.allsettled": "^1.0.7",

packages/webui/src/client/lib/LottieButton.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react'
22

3-
import { Lottie } from '@crello/react-lottie'
3+
import Lottie, { LottieComponentProps } from 'lottie-react'
44

55
interface IProps {
66
inAnimation?: any
@@ -26,8 +26,8 @@ export class LottieButton extends React.Component<React.PropsWithChildren<IProps
2626
}
2727

2828
// Setup in `buildAnimationObjects`
29-
overAnimation!: { animationData: object } & object
30-
outAnimation!: { animationData: object } & object
29+
overAnimation!: LottieComponentProps
30+
outAnimation!: LottieComponentProps
3131

3232
constructor(props: IProps) {
3333
super(props)
@@ -77,7 +77,7 @@ export class LottieButton extends React.Component<React.PropsWithChildren<IProps
7777
onClick={this.onClick}
7878
tabIndex={0}
7979
>
80-
<Lottie config={this.state.hover ? this.overAnimation : this.outAnimation} />
80+
<Lottie {...(this.state.hover ? this.overAnimation : this.outAnimation)} />
8181
{this.props.children}
8282
<div
8383
style={{ position: 'absolute', top: '0', left: '0', right: '0', bottom: '0' }}

packages/webui/src/client/lib/ui/icons/looping.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { JSX } from 'react'
2-
import * as loopAnimation from './icon-loop.json'
3-
import { Lottie } from '@crello/react-lottie'
1+
import React, { JSX, useEffect, useRef } from 'react'
2+
import loopAnimation from './icon-loop.json'
3+
import Lottie, { LottieComponentProps, LottieRefCurrentProps } from 'lottie-react'
44

55
export function LoopingIcon(props?: Readonly<React.SVGProps<SVGSVGElement>>): JSX.Element {
66
return (
@@ -25,19 +25,34 @@ export function LoopingIcon(props?: Readonly<React.SVGProps<SVGSVGElement>>): JS
2525
export function LoopingPieceIcon({
2626
className,
2727
playing,
28-
}: Readonly<{ className?: string; playing: boolean }>): JSX.Element {
28+
}: Readonly<{ className?: string; playing?: boolean }>): JSX.Element {
29+
const lottieRef = useRef<LottieRefCurrentProps>(null)
30+
31+
useEffect(() => {
32+
if (!lottieRef.current) return
33+
if (playing) {
34+
lottieRef.current.play()
35+
} else {
36+
lottieRef.current.stop()
37+
}
38+
}, [playing])
39+
2940
return (
3041
<div className={`${className} label-icon label-loop-icon`}>
31-
<Lottie config={LOOPING_PIECE_ICON} width="24px" height="24px" playingState={playing ? 'playing' : 'stopped'} />
42+
<Lottie lottieRef={lottieRef} {...LOOPING_PIECE_ICON} autoplay={playing} />
3243
</div>
3344
)
3445
}
3546

36-
const LOOPING_PIECE_ICON = {
47+
const LOOPING_PIECE_ICON: LottieComponentProps = {
3748
loop: true,
3849
autoplay: false,
3950
animationData: loopAnimation,
4051
rendererSettings: {
4152
preserveAspectRatio: 'xMidYMid slice',
4253
},
54+
style: {
55+
width: '24px',
56+
height: '24px',
57+
},
4358
}

packages/webui/src/client/ui/RundownView/RundownRightHandControls.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
} from '@sofie-automation/corelib/dist/dataModel/Studio'
88
import { RewindAllSegmentsIcon } from '../../lib/ui/icons/rewindAllSegmentsIcon.js'
99

10-
import { Lottie } from '@crello/react-lottie'
10+
import Lottie, { LottieComponentProps } from 'lottie-react'
1111
import { NotificationCenterPanelToggle } from '../../lib/notifications/NotificationCenterPanel.js'
1212

13-
import * as On_Air_MouseOut from './On_Air_MouseOut.json'
14-
import * as On_Air_MouseOver from './On_Air_MouseOver.json'
13+
import On_Air_MouseOut from './On_Air_MouseOut.json'
14+
import On_Air_MouseOver from './On_Air_MouseOver.json'
1515
import { SupportPopUpToggle } from '../SupportPopUp.js'
1616
import classNames from 'classnames'
1717
import { NoticeLevel } from '../../lib/notifications/notifications.js'
@@ -54,7 +54,7 @@ interface IProps {
5454
hideRundownHeader?: boolean
5555
}
5656

57-
const ANIMATION_TEMPLATE = {
57+
const ANIMATION_TEMPLATE: LottieComponentProps = {
5858
loop: false,
5959
autoplay: true,
6060
animationData: {},
@@ -63,11 +63,11 @@ const ANIMATION_TEMPLATE = {
6363
},
6464
}
6565

66-
const ONAIR_OUT = {
66+
const ONAIR_OUT: LottieComponentProps = {
6767
...ANIMATION_TEMPLATE,
6868
animationData: On_Air_MouseOut,
6969
}
70-
const ONAIR_OVER = {
70+
const ONAIR_OVER: LottieComponentProps = {
7171
...ANIMATION_TEMPLATE,
7272
animationData: On_Air_MouseOver,
7373
}
@@ -195,7 +195,7 @@ export function RundownRightHandControls(props: Readonly<IProps>): JSX.Element {
195195
tabIndex={0}
196196
aria-label={t('Go to On Air Segment')}
197197
>
198-
{onAirHover ? <Lottie config={ONAIR_OVER} /> : <Lottie config={ONAIR_OUT} />}
198+
{onAirHover ? <Lottie {...ONAIR_OVER} /> : <Lottie {...ONAIR_OUT} />}
199199
</button>
200200
)}
201201
</div>

packages/yarn.lock

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2221,18 +2221,6 @@ __metadata:
22212221
languageName: node
22222222
linkType: hard
22232223

2224-
"@crello/react-lottie@npm:0.0.11":
2225-
version: 0.0.11
2226-
resolution: "@crello/react-lottie@npm:0.0.11"
2227-
dependencies:
2228-
lottie-web: "npm:^5.7.3"
2229-
peerDependencies:
2230-
react: ~16.9.0
2231-
react-dom: ~16.9.0
2232-
checksum: 10/23629b6cdd5b703f936ef4263696feecaadf3b642d6442afae94043c4bc0e4c4a98e249257a277812c9214ebca4363c37466fba1c9c7dee951ade50c31e02737
2233-
languageName: node
2234-
linkType: hard
2235-
22362224
"@cspotcode/source-map-support@npm:^0.8.0":
22372225
version: 0.8.1
22382226
resolution: "@cspotcode/source-map-support@npm:0.8.1"
@@ -7272,7 +7260,6 @@ __metadata:
72727260
resolution: "@sofie-automation/webui@workspace:webui"
72737261
dependencies:
72747262
"@babel/preset-env": "npm:^7.29.0"
7275-
"@crello/react-lottie": "npm:0.0.11"
72767263
"@fortawesome/fontawesome-free": "npm:^7.1.0"
72777264
"@fortawesome/fontawesome-svg-core": "npm:^7.1.0"
72787265
"@fortawesome/free-solid-svg-icons": "npm:^7.1.0"
@@ -7312,7 +7299,7 @@ __metadata:
73127299
i18next-browser-languagedetector: "npm:^8.2.0"
73137300
i18next-http-backend: "npm:^3.0.2"
73147301
immutability-helper: "npm:^3.1.1"
7315-
lottie-web: "npm:^5.13.0"
7302+
lottie-react: "npm:^2.4.1"
73167303
moment: "npm:^2.30.1"
73177304
motion: "npm:^12.31.0"
73187305
promise.allsettled: "npm:^1.0.7"
@@ -19899,7 +19886,19 @@ asn1@evs-broadcast/node-asn1:
1989919886
languageName: node
1990019887
linkType: hard
1990119888

19902-
"lottie-web@npm:^5.13.0, lottie-web@npm:^5.7.3":
19889+
"lottie-react@npm:^2.4.1":
19890+
version: 2.4.1
19891+
resolution: "lottie-react@npm:2.4.1"
19892+
dependencies:
19893+
lottie-web: "npm:^5.10.2"
19894+
peerDependencies:
19895+
react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
19896+
react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
19897+
checksum: 10/d1c54c3d90e322db988ea1dc92900a122e699e1d833368b8a817f4bd2ccc6d5600ab3cd0f34aa6e0bcbab28425f6de514b6d567e13164693cbde2c82af08fa06
19898+
languageName: node
19899+
linkType: hard
19900+
19901+
"lottie-web@npm:^5.10.2":
1990319902
version: 5.13.0
1990419903
resolution: "lottie-web@npm:5.13.0"
1990519904
checksum: 10/ccc65b91ddc569c874de265252ef41cb546798515dd63c5ee366844efd1e10335c080c483ce4305faba0cebd54c4afd6bb918fd0d6f4394dcc284fc0c3944941

0 commit comments

Comments
 (0)