Skip to content

Commit

Permalink
fix: framer-motion breaking change
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Apr 29, 2022
1 parent 489ce19 commit 659b001
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/components/AppLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { css } from 'twin.macro'

type AppLinkProps = {
index: number
category: string
app: {
name: string
desc?: string
Expand Down Expand Up @@ -35,7 +36,7 @@ const offsetStyle = css`
grid-row: span 4 / span 4 !important;
`

const AppLink = ({ index, app }: AppLinkProps): React.ReactElement => {
const AppLink = ({ index, category, app }: AppLinkProps): React.ReactElement => {
if (!app.name)
return <motion.div transition={spring} variants={item}></motion.div>

Expand All @@ -46,6 +47,7 @@ const AppLink = ({ index, app }: AppLinkProps): React.ReactElement => {
<motion.a
variants={item}
transition={spring}
id={category}
whileHover={{ scale: 1.075, rotate: Math.random() > 0.4 ? -1 : 1 }}
whileTap={{ scale: 0.95 }}
tw="hover:(ring-4 ring-opacity-20) focus-within:(ring-4 ring-opacity-20) relative flex items-start justify-between p-8 h-full bg-gray-900 rounded-xl focus:outline-none shadow-lg overflow-hidden transition-shadow duration-500 ring-newtelco-500"
Expand All @@ -56,7 +58,7 @@ const AppLink = ({ index, app }: AppLinkProps): React.ReactElement => {
: 'grid-row: span 5 / span 4; min-width: 250px;',
]}
href={url}
rel="noopener noreferer"
rel="noopener noreferrer"
target="_blank"
>
<div tw="flex flex-col justify-between h-full">
Expand Down
12 changes: 8 additions & 4 deletions src/components/AppList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react'
import { motion, AnimateSharedLayout } from 'framer-motion'
import { motion, LayoutGroup } from 'framer-motion'
import { AppLink } from '@/components/index'

type AppListProps = {
Expand All @@ -9,11 +9,16 @@ type AppListProps = {
const list = {
hidden: {
opacity: 0,
transition: {
staggerChildren: 0.1,
staggerDirection: -1
},
},
visible: {
opacity: 1,
transition: {
staggerChildren: 0.1,
delayChildren: 0.1,
},
},
}
Expand All @@ -39,20 +44,19 @@ const AppList: React.FC<AppListProps> = ({ category }): React.ReactElement => {

return (
<div tw="px-2 sm:px-4 w-full max-h-full overflow-y-scroll md:w-1/2">
<AnimateSharedLayout>
<motion.div
initial="hidden"
layoutId={category}
animate="visible"
variants={list}
key={category}
tw="grid gap-8 grid-cols-1 p-0 sm:px-2 sm:py-4 xl:grid-cols-2"
css="grid-template-rows: repeat(12, 20px)"
>
{activeApps?.map((app, index) => (
<AppLink index={index} key={index} app={app} />
<AppLink index={index} category={category} key={`${category}-${index}`} app={app} />
))}
</motion.div>
</AnimateSharedLayout>
</div>
)
}
Expand Down

0 comments on commit 659b001

Please sign in to comment.