Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): integrate framer-motion #1583

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { capitalize } from 'lodash-es'
import moment from 'moment'

import { DEFAULT_ANIMTATION } from '@/lib/constants'
import { LicenseInfo, LicenseType } from '@/lib/gql/generates/graphql'
import { useLicense } from '@/lib/hooks/use-license'
import { Skeleton } from '@/components/ui/skeleton'
Expand Down Expand Up @@ -31,6 +32,7 @@ export default function Subscription() {
</SubHeader>
<div className="flex flex-col gap-8">
<LoadingWrapper
animate={DEFAULT_ANIMTATION}
loading={fetching}
fallback={
<div className="grid grid-cols-3">
Expand Down
7 changes: 5 additions & 2 deletions ee/tabby-ui/components/loading-wrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
'use client'

import React from 'react'
import { AnimationProps, motion } from 'framer-motion'

interface LoadingWrapperProps {
loading?: boolean
children?: React.ReactNode
fallback?: React.ReactNode
animate?: AnimationProps
}

export const LoadingWrapper: React.FC<LoadingWrapperProps> = ({
loading,
fallback,
children
children,
animate
}) => {
const [loaded, setLoaded] = React.useState(!loading)

Expand All @@ -24,7 +27,7 @@ export const LoadingWrapper: React.FC<LoadingWrapperProps> = ({
if (!loaded) {
return fallback
} else {
return children
return <motion.div {...animate}>{children}</motion.div>
}
}

Expand Down
21 changes: 21 additions & 0 deletions ee/tabby-ui/lib/constants/animation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { AnimationProps } from 'framer-motion'

const DEFAULT_VARIANTS = {
hidden: { opacity: 0, y: 10 },
visible: {
opacity: 1,
y: 0,
transition: {
type: 'spring',
duration: 0.3
}
}
}

const DEFAULT_ANIMTATION: AnimationProps = {
initial: 'hidden',
animate: 'visible',
variants: DEFAULT_VARIANTS
}

export { DEFAULT_ANIMTATION, DEFAULT_VARIANTS }
3 changes: 3 additions & 0 deletions ee/tabby-ui/lib/constants/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const PLACEHOLDER_EMAIL_FORM = 'name@yourcompany.com'

export const DEFAULT_PAGE_SIZE = 20
5 changes: 2 additions & 3 deletions ee/tabby-ui/lib/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export const PLACEHOLDER_EMAIL_FORM = 'name@yourcompany.com'

export const DEFAULT_PAGE_SIZE = 20
export * from './common'
export * from './animation'
1 change: 1 addition & 0 deletions ee/tabby-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"copy-to-clipboard": "^3.3.3",
"downshift": "^8.2.2",
"focus-trap-react": "^10.1.1",
"framer-motion": "^11.0.7",
"graphql": "^16.8.1",
"humanize-duration": "^3.31.0",
"jwt-decode": "^4.0.0",
Expand Down
21 changes: 21 additions & 0 deletions ee/tabby-ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,18 @@
anser "^2.1.1"
escape-carriage "^1.3.1"

"@emotion/is-prop-valid@^0.8.2":
version "0.8.8"
resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz#db28b1c4368a259b60a97311d6a952d4fd01ac1a"
integrity sha512-u5WtneEAr5IDG2Wv65yhunPSMLIpuKsbuOktRojfrEiEvRyC85LgPMZI63cr7NUqT8ZIGdSVg8ZKGxIug4lXcA==
dependencies:
"@emotion/memoize" "0.7.4"

"@emotion/memoize@0.7.4":
version "0.7.4"
resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.7.4.tgz#19bf0f5af19149111c40d98bb0cf82119f5d9eeb"
integrity sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw==

"@eslint-community/eslint-utils@^4.2.0":
version "4.4.0"
resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59"
Expand Down Expand Up @@ -4373,6 +4385,15 @@ fraction.js@^4.3.6:
resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.3.6.tgz#e9e3acec6c9a28cf7bc36cbe35eea4ceb2c5c92d"
integrity sha512-n2aZ9tNfYDwaHhvFTkhFErqOMIb8uyzSQ+vGJBjZyanAKZVbGUQ1sngfk9FdkBw7G26O7AgNjLcecLffD1c7eg==

framer-motion@^11.0.7:
version "11.0.7"
resolved "https://registry.yarnpkg.com/framer-motion/-/framer-motion-11.0.7.tgz#a64b4c309f24580603365c535d1b03cd937b06c1"
integrity sha512-IyzcBkDDx8KvP351oPLB8Km2QyNGMS+oc/LiuDr5w1ph32UXZZWFrBvOTcz3/beVAauthvtmDwSSXRefztaWcA==
dependencies:
tslib "^2.4.0"
optionalDependencies:
"@emotion/is-prop-valid" "^0.8.2"

fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
Expand Down
Loading