Skip to content

Commit

Permalink
fix: dedupe MysticalBackgroundV3 & LoginBackground
Browse files Browse the repository at this point in the history
  • Loading branch information
alecdwm committed Sep 21, 2023
1 parent d650747 commit 4a335bb
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 205 deletions.
19 changes: 19 additions & 0 deletions apps/extension/src/ui/apps/popup/components/LoginBackground.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useMemo } from "react"
import { MYSTICAL_PHYSICS_V3, MysticalBackground, MysticalPhysicsV3 } from "talisman-ui"

const BG_CONFIG: MysticalPhysicsV3 = {
...MYSTICAL_PHYSICS_V3,
artifacts: 4,
radiusMax: 0.7,
ellipsisRatio: 0.4,
}

export type LoginBackgroundProps = {
className?: string
colors: [string, string]
}
export const LoginBackground = ({ className, colors }: LoginBackgroundProps) => {
const config = useMemo(() => ({ ...BG_CONFIG, colors }), [colors])

return <MysticalBackground className={className} config={config} />
}
11 changes: 2 additions & 9 deletions apps/extension/src/ui/apps/popup/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SuspenseTracker } from "@talisman/components/SuspenseTracker"
import { HandMonoTransparentLogo } from "@talisman/theme/logos"
import { classNames } from "@talismn/util"
import { api } from "@ui/api"
import { LoginBackground } from "@ui/apps/popup/components/LoginBackground"
import { useAnalytics } from "@ui/hooks/useAnalytics"
import { useFirstAccountColors } from "@ui/hooks/useFirstAccountColors"
import { Suspense, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react"
Expand All @@ -15,7 +16,6 @@ import {
} from "react-hook-form"
import { useTranslation } from "react-i18next"
import { Button, FormFieldInputText } from "talisman-ui"
import { LoginBackground } from "talisman-ui"
import * as yup from "yup"

import { PopupContent, PopupFooter, PopupLayout } from "../Layout/PopupLayout"
Expand All @@ -36,14 +36,7 @@ const INPUT_CONTAINER_PROPS = { className: "bg-white/10" }
const Background = () => {
const colors = useFirstAccountColors()

return (
<LoginBackground
width={400}
height={600}
colors={colors}
className="absolute left-0 top-0 m-0 block h-full w-full overflow-hidden "
/>
)
return <LoginBackground className="absolute left-0 top-0 h-full w-full" colors={colors} />
}

const Login = ({ setShowResetWallet }: { setShowResetWallet: () => void }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,9 @@ const AccountsList = ({ className, options }: { className?: string; options: Acc
</div>
)

const AccountsBgConfig: MysticalPhysicsV3 = {
const BG_CONFIG: MysticalPhysicsV3 = {
...MYSTICAL_PHYSICS_V3,
artifacts: 2,
blur: 0,
radiusMin: 4,
radiusMax: 4,
opacityMin: 0.5,
Expand Down Expand Up @@ -219,11 +218,11 @@ const Accounts = ({

const AllAccountsHeaderBackground = () => {
const colors = useFirstAccountColors()
const config = useMemo(() => ({ ...AccountsBgConfig, colors }), [colors])
const config = useMemo(() => ({ ...BG_CONFIG, colors }), [colors])

return (
<MysticalBackground
className="absolute left-0 top-0 h-full w-full overflow-hidden rounded-sm"
className="absolute left-0 top-0 h-full w-full rounded-sm"
config={config}
/>
)
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { classNames } from "@talismn/util"
import { CSSProperties, memo, useLayoutEffect, useMemo, useRef } from "react"
import { useMeasure } from "react-use"

Expand All @@ -23,7 +24,7 @@ export const MysticalBackgroundV3 = ({
)

return (
<div ref={refSize} className={className} style={style}>
<div ref={refSize} className={classNames("overflow-hidden", className)} style={style}>
<CelestialArtifacts config={mergedConfig} size={size} />
</div>
)
Expand Down
1 change: 0 additions & 1 deletion packages/talisman-ui/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export * from "./FormFieldContainer"
export * from "./FormFieldInputText"
export * from "./FormFieldTextarea"
export * from "./ListButton"
export * from "./LoginBackground"
export * from "./IconButton"
export * from "./MysticalBackgroundV2"
export * from "./MysticalBackgroundV3"
Expand Down

0 comments on commit 4a335bb

Please sign in to comment.