Skip to content

Commit

Permalink
⬆️ Upgrade "framer-motion" to "motion"
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelGesenhues committed Feb 10, 2025
1 parent a9fb537 commit 9156036
Show file tree
Hide file tree
Showing 76 changed files with 4,355 additions and 2,867 deletions.
6,848 changes: 4,166 additions & 2,682 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/code-highlighter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
},
"peerDependencies": {
"chayns-api": ">=2.0.0",
"framer-motion": ">=10.18.0",
"motion": ">=12.4.1",
"react": ">=18.0.0",
"react-dom": ">=18.0.0",
"styled-components": ">=5.3.11"
Expand Down
2 changes: 1 addition & 1 deletion packages/color-picker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
},
"peerDependencies": {
"chayns-api": ">=2.0.0",
"framer-motion": ">=10.18.0",
"motion": ">=12.4.1",
"react": ">=18.0.0",
"react-dom": ">=18.0.0",
"styled-components": ">=5.3.11"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { motion } from 'framer-motion';
import { motion } from 'motion/react';
import styled from 'styled-components';

export const StyledColorArea = styled.div`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {

import { hsvToHex } from '@chayns/colors';
import { setRefreshScrollEnabled } from 'chayns-api';
import { useDragControls, useMotionValue } from 'framer-motion';
import { useDragControls, useMotionValue } from 'motion/react';
import type { Scale } from '../../../types/colorPicker';
import {
extractRgbValues,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
},
"peerDependencies": {
"chayns-api": ">=2.0.0",
"framer-motion": ">=10.18.0",
"motion": ">=12.4.1",
"react": ">=18.0.0",
"react-dom": ">=18.0.0",
"styled-components": ">=5.3.11"
Expand Down
109 changes: 55 additions & 54 deletions packages/core/src/components/accordion/Accordion.styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {motion} from 'framer-motion';
import styled, {css} from 'styled-components';
import type {WithTheme} from '../color-scheme-provider/ColorSchemeProvider';
import { motion } from 'motion/react';
import styled, { css } from 'styled-components';
import type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';

type StyledMotionAccordionProps = WithTheme<{
$isOpen: boolean;
Expand All @@ -14,44 +14,45 @@ type StyledMotionAccordionProps = WithTheme<{

export const StyledMotionAccordion = styled(motion.div)<StyledMotionAccordionProps>`
${({
$isOpen,
$isWrapped,
$shouldForceBackground,
$shouldHideBackground,
theme,
}: StyledMotionAccordionProps) =>
($isOpen || $shouldForceBackground) &&
!$isWrapped &&
!$shouldHideBackground &&
css`
background-color: rgba(${theme['100-rgb']}, ${theme.cardBackgroundOpacity});
border-radius: ${theme.cardBorderRadius}px;
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, ${theme.cardShadow});
`}
$isOpen,
$isWrapped,
$shouldForceBackground,
$shouldHideBackground,
theme,
}: StyledMotionAccordionProps) =>
($isOpen || $shouldForceBackground) &&
!$isWrapped &&
!$shouldHideBackground &&
css`
background-color: rgba(${theme['100-rgb']}, ${theme.cardBackgroundOpacity});
border-radius: ${theme.cardBorderRadius}px;
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, ${theme.cardShadow});
`}
${({theme}: StyledMotionAccordionProps) =>
theme.accordionLines &&
css`
border-bottom: 1px solid transparent;
`}
${({ theme }: StyledMotionAccordionProps) =>
theme.accordionLines &&
css`
border-bottom: 1px solid transparent;
`}
margin-bottom: ${({$isOpen, $isWrapped}: StyledMotionAccordionProps) =>
$isOpen && !$isWrapped ? '30px' : '0px'};
transition: background-color 0.3s ease,
border-bottom-color 0.3s ease,
border-radius 0.3s ease,
box-shadow 0.3s ease,
margin-bottom 0.3s ease;
margin-bottom: ${({ $isOpen, $isWrapped }: StyledMotionAccordionProps) =>
$isOpen && !$isWrapped ? '30px' : '0px'};
transition:
background-color 0.3s ease,
border-bottom-color 0.3s ease,
border-radius 0.3s ease,
box-shadow 0.3s ease,
margin-bottom 0.3s ease;
will-change: unset !important;
${({
$isOpen,
$isWrapped,
$shouldForceBackground,
$shouldShowLines,
$shouldHideBottomLine,
theme,
}: StyledMotionAccordionProps) => {
$isOpen,
$isWrapped,
$shouldForceBackground,
$shouldShowLines,
$shouldHideBottomLine,
theme,
}: StyledMotionAccordionProps) => {
if ($shouldForceBackground || $shouldHideBottomLine) return undefined;
if (theme.accordionLines) {
Expand All @@ -70,22 +71,22 @@ export const StyledMotionAccordion = styled(motion.div)<StyledMotionAccordionPro
return undefined;
}}
${({$isParentWrapped}: StyledMotionAccordionProps) =>
$isParentWrapped &&
css`
padding-left: 17px;
`}
${({$isWrapped}: StyledMotionAccordionProps) =>
!$isWrapped &&
css`
margin-top: 10px;
`}
${({$isWrapped, $shouldHideBackground, theme}: StyledMotionAccordionProps) =>
!$isWrapped &&
!$shouldHideBackground &&
css`
&:hover {
background-color: rgba(${theme['100-rgb']}, ${theme.cardBackgroundOpacity});
}
`};
${({ $isParentWrapped }: StyledMotionAccordionProps) =>
$isParentWrapped &&
css`
padding-left: 17px;
`}
${({ $isWrapped }: StyledMotionAccordionProps) =>
!$isWrapped &&
css`
margin-top: 10px;
`}
${({ $isWrapped, $shouldHideBackground, theme }: StyledMotionAccordionProps) =>
!$isWrapped &&
!$shouldHideBackground &&
css`
&:hover {
background-color: rgba(${theme['100-rgb']}, ${theme.cardBackgroundOpacity});
}
`};
`;
92 changes: 46 additions & 46 deletions packages/core/src/components/accordion/Accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AnimatePresence, MotionConfig} from 'framer-motion';
import { AnimatePresence, MotionConfig } from 'motion/react';
import React, {
ChangeEventHandler,
FC,
Expand All @@ -13,14 +13,14 @@ import React, {
type CSSProperties,
type MouseEventHandler,
} from 'react';
import {useUuid} from '../../hooks/uuid';
import {AreaContext} from '../area-provider/AreaContextProvider';
import type {InputProps} from '../input/Input';
import { useUuid } from '../../hooks/uuid';
import { AreaContext } from '../area-provider/AreaContextProvider';
import type { InputProps } from '../input/Input';
import AccordionBody from './accordion-body/AccordionBody';
import {AccordionGroupContext} from './accordion-group/AccordionGroup';
import { AccordionGroupContext } from './accordion-group/AccordionGroup';
import AccordionHead from './accordion-head/AccordionHead';
import {AccordionWrappedContext} from './accordion-provider/AccordionContextProvider';
import {StyledMotionAccordion} from './Accordion.styles';
import { AccordionWrappedContext } from './accordion-provider/AccordionContextProvider';
import { StyledMotionAccordion } from './Accordion.styles';

export const AccordionContext = React.createContext<{ isWrapped?: boolean }>({
isWrapped: undefined,
Expand Down Expand Up @@ -148,45 +148,45 @@ export type AccordionProps = {
};

const Accordion: FC<AccordionProps> = ({
bodyMaxHeight,
children,
icon,
isDefaultOpen = false,
isDisabled = false,
isFixed = false,
isOpened,
isTitleGreyed = false,
onBodyScroll,
onClose,
onHoverEnd,
onHoverStart,
onOpen,
onSearchChange,
rightElement,
searchPlaceholder,
searchValue,
shouldForceBackground = false,
shouldHideBackground = false,
shouldRenderClosed = false,
shouldRotateIcon = true,
shouldHideBottomLine = false,
title,
titleElement,
onTitleInputChange,
titleInputProps,
titleColor,
onBodyAnimationComplete,
}) => {
bodyMaxHeight,
children,
icon,
isDefaultOpen = false,
isDisabled = false,
isFixed = false,
isOpened,
isTitleGreyed = false,
onBodyScroll,
onClose,
onHoverEnd,
onHoverStart,
onOpen,
onSearchChange,
rightElement,
searchPlaceholder,
searchValue,
shouldForceBackground = false,
shouldHideBackground = false,
shouldRenderClosed = false,
shouldRotateIcon = true,
shouldHideBottomLine = false,
title,
titleElement,
onTitleInputChange,
titleInputProps,
titleColor,
onBodyAnimationComplete,
}) => {
const {
isWrapped: groupIsWrapped,
openAccordionUuid,
accordionGroupUuid,
accordionUuids,
updateOpenAccordionUuid,
} = useContext(AccordionGroupContext);
const {isWrapped: isParentWrapped} = useContext(AccordionContext);
const { isWrapped: isParentWrapped } = useContext(AccordionContext);

const {isWrapped: contextIsWrapped} = useContext(AccordionWrappedContext);
const { isWrapped: contextIsWrapped } = useContext(AccordionWrappedContext);
const isWrapped = useMemo(
() => groupIsWrapped ?? contextIsWrapped,
[contextIsWrapped, groupIsWrapped],
Expand Down Expand Up @@ -254,7 +254,7 @@ const Accordion: FC<AccordionProps> = ({
useEffect(() => {
if (isDefaultOpen) {
if (typeof updateOpenAccordionUuid === 'function') {
updateOpenAccordionUuid(uuid, {shouldOnlyOpen: true});
updateOpenAccordionUuid(uuid, { shouldOnlyOpen: true });
} else {
setIsAccordionOpen(true);
}
Expand All @@ -272,20 +272,20 @@ const Accordion: FC<AccordionProps> = ({
}, [isOpened, updateOpenAccordionUuid, uuid]);

const accordionContextProviderValue = useMemo(
() => ({isWrapped: isWrapped === true}),
() => ({ isWrapped: isWrapped === true }),
[isWrapped],
);

const areaContextProviderValue = useMemo(() => ({shouldChangeColor: true}), []);
const areaContextProviderValue = useMemo(() => ({ shouldChangeColor: true }), []);

const accordionWrappedContextProviderValue = useMemo(() => ({isWrapped: true}), []);
const accordionWrappedContextProviderValue = useMemo(() => ({ isWrapped: true }), []);
return (
<StyledMotionAccordion
animate={{height: 'auto', opacity: 1}}
animate={{ height: 'auto', opacity: 1 }}
data-uuid={`${accordionGroupUuid ?? ''}---${uuid}`}
className="beta-chayns-accordion"
exit={{height: 0, opacity: 0}}
initial={{height: 0, opacity: 0}}
exit={{ height: 0, opacity: 0 }}
initial={{ height: 0, opacity: 0 }}
$isOpen={isOpen}
$shouldShowLines={!isLastAccordion || !isWrapped}
$isParentWrapped={isParentWrapped}
Expand All @@ -297,7 +297,7 @@ const Accordion: FC<AccordionProps> = ({
onMouseLeave={onHoverEnd}
>
<AccordionContext.Provider value={accordionContextProviderValue}>
<MotionConfig transition={{type: 'tween'}}>
<MotionConfig transition={{ type: 'tween' }}>
<AccordionHead
uuid={uuid}
icon={icon}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { motion } from 'framer-motion';
import { motion } from 'motion/react';
import styled, { css } from 'styled-components';
import { BrowserName } from '../../../types/chayns';
import type { WithTheme } from '../../color-scheme-provider/ColorSchemeProvider';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnimatePresence, MotionConfig } from 'framer-motion';
import { AnimatePresence, MotionConfig } from 'motion/react';
import React, {
Dispatch,
FC,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { motion } from 'framer-motion';
import { motion } from 'motion/react';
import type { CSSProperties } from 'react';
import styled, { css } from 'styled-components';
import type {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnimatePresence, LayoutGroup } from 'framer-motion';
import { AnimatePresence, LayoutGroup } from 'motion/react';
import React, {
ChangeEvent,
ChangeEventHandler,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { motion } from 'framer-motion';
import { motion } from 'motion/react';
import styled, { css } from 'styled-components';
import type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';
import type { DisplayState } from './AmountControl';
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/amount-control/AmountControl.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnimatePresence } from 'framer-motion';
import { AnimatePresence } from 'motion/react';
import React, {
ChangeEvent,
FC,
Expand Down Expand Up @@ -124,7 +124,7 @@ const AmountControl: FC<AmountControlProps> = ({
* Function that sets the amountValue to the amount
*/
useEffect(() => {
if (typeof amount !== "number") {
if (typeof amount !== 'number') {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/button/Button.styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { motion } from 'framer-motion';
import { motion } from 'motion/react';
import styled, { css } from 'styled-components';
import type { FramerMotionBugFix, WithTheme } from '../color-scheme-provider/ColorSchemeProvider';

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx';
import { AnimatePresence } from 'framer-motion';
import { AnimatePresence } from 'motion/react';
import React, { FC, MouseEventHandler, ReactNode, useMemo } from 'react';
import { useTheme } from 'styled-components';
import type { Theme } from '../color-scheme-provider/ColorSchemeProvider';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/combobox/ComboBox.styles.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { motion } from 'framer-motion';
import { motion } from 'motion/react';
import type { CSSProperties } from 'react';
import styled, { css } from 'styled-components';
import { BrowserName } from '../../types/chayns';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/combobox/ComboBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useDevice, useFunctions, useValues } from 'chayns-api';
import { AnimatePresence } from 'framer-motion';
import { AnimatePresence } from 'motion/react';
import React, {
ChangeEventHandler,
FC,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/context-menu/ContextMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createDialog, DialogType } from 'chayns-api';
import { AnimatePresence } from 'framer-motion';
import { AnimatePresence } from 'motion/react';
import React, {
forwardRef,
MouseEvent,
Expand Down
Loading

0 comments on commit 9156036

Please sign in to comment.