Skip to content

Commit

Permalink
Merge branch 'main' into hashed-signal
Browse files Browse the repository at this point in the history
  • Loading branch information
0xPenryn committed Mar 25, 2024
2 parents db34a2b + 891c813 commit f1e3388
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 367 deletions.
Binary file removed packages/react/public/images/verified.webp
Binary file not shown.
44 changes: 0 additions & 44 deletions packages/react/src/components/AboutWorldID.tsx

This file was deleted.

21 changes: 0 additions & 21 deletions packages/react/src/components/Button.tsx

This file was deleted.

35 changes: 0 additions & 35 deletions packages/react/src/components/Frame.tsx

This file was deleted.

21 changes: 2 additions & 19 deletions packages/react/src/components/IDKitWidget/BaseWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { FC } from 'react'
import root from 'react-shadow'
import { IDKITStage } from '@/types'
import useMedia from '@/hooks/useMedia'
import { classNames } from '@/lib/utils'
import Styles from '@/components/Styles'
import useIDKitStore from '@/store/idkit'
import { shallow } from 'zustand/shallow'
Expand All @@ -12,31 +11,28 @@ import ErrorState from './States/ErrorState'
import { ConfigSource } from '@/types/config'
import * as Toast from '@radix-ui/react-toast'
import type { IDKitStore } from '@/store/idkit'
import PrivacyState from './States/PrivacyState'
import SuccessState from './States/SuccessState'
import WorldIDState from './States/WorldIDState'
import * as Dialog from '@radix-ui/react-dialog'
import type { WidgetProps } from '@/types/config'
import WorldcoinIcon from '../Icons/WorldcoinIcon'
import { Fragment, useEffect, useMemo } from 'react'
import { AnimatePresence, motion } from 'framer-motion'
import ArrowLongLeftIcon from '../Icons/ArrowLongLeftIcon'
import HostAppVerificationState from './States/HostAppVerificationState'

const getParams = ({ open, processing, onOpenChange, stage, setStage, computed, setOptions }: IDKitStore) => ({
const getParams = ({ open, processing, onOpenChange, stage, setStage, setOptions }: IDKitStore) => ({
stage,
setStage,
processing,
setOptions,
isOpen: open,
onOpenChange,
canGoBack: computed.canGoBack(stage),
})

const IDKitWidget: FC<WidgetProps> = ({ children, ...config }) => {
const media = useMedia()

const { isOpen, onOpenChange, stage, setStage, canGoBack, setOptions } = useIDKitStore(getParams, shallow)
const { isOpen, onOpenChange, stage, setOptions } = useIDKitStore(getParams, shallow)

useEffect(() => {
setOptions(config, ConfigSource.PROPS)
Expand All @@ -50,8 +46,6 @@ const IDKitWidget: FC<WidgetProps> = ({ children, ...config }) => {
return SuccessState
case IDKITStage.ERROR:
return ErrorState
case IDKITStage.PRIVACY:
return PrivacyState
case IDKITStage.HOST_APP_VERIFICATION:
return HostAppVerificationState
default:
Expand Down Expand Up @@ -99,17 +93,6 @@ const IDKitWidget: FC<WidgetProps> = ({ children, ...config }) => {
<Toast.Provider>
<Toast.Viewport className="flex justify-center" />
<div className="mx-6 mb-12 flex items-center justify-between">
<button
onClick={() => setStage(IDKITStage.WORLD_ID)}
disabled={!canGoBack}
className={classNames(
!canGoBack && 'invisible pointer-events-none',
'dark:bg-d3dfea/15 flex h-8 w-8 items-center justify-center rounded-full bg-gray-100 dark:text-white'
)}
>
<ArrowLongLeftIcon className="w-4" />
</button>

<Dialog.Close className="flex items-center justify-center rounded-full dark:text-white">
<XMarkIcon className="h-5 w-5" />
</Dialog.Close>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ const ErrorState = () => {
</div>
<div>
<p className="text-center text-2xl font-semibold text-gray-900 dark:text-white">
{(errorState?.code && ERROR_TITLES[errorState.code]) || ERROR_TITLES[AppErrorCodes.GenericError]}
{(errorState?.code && ERROR_TITLES[errorState.code]) ?? ERROR_TITLES[AppErrorCodes.GenericError]}
</p>
<p className="mx-auto mt-2 max-w-[224px] text-center text-657080">
{/* eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing */}
{errorState?.message || ERROR_MESSAGES[errorState?.code ?? AppErrorCodes.GenericError]}
{errorState?.message ?? ERROR_MESSAGES[errorState?.code ?? AppErrorCodes.GenericError]}
</p>
</div>
<div className="flex justify-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const HostAppVerificationState = () => {
<div className="flex justify-center">
<LoadingIcon className="h-24 w-24" />
</div>
<div className="text-70868f mt-4">{__('Transmitting verification to host app. Please wait...')}</div>
<div className="mt-4 text-70868f">{__('Transmitting verification to host app. Please wait...')}</div>
</div>
)
}
Expand Down
40 changes: 0 additions & 40 deletions packages/react/src/components/IDKitWidget/States/PrivacyState.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions packages/react/src/components/Icons/ChevronDownIcon.tsx

This file was deleted.

14 changes: 0 additions & 14 deletions packages/react/src/components/Icons/InfoIcon.tsx

This file was deleted.

7 changes: 0 additions & 7 deletions packages/react/src/components/Icons/QuestionMarkIcon.tsx

This file was deleted.

56 changes: 0 additions & 56 deletions packages/react/src/components/Icons/WorldIDWordmark.tsx

This file was deleted.

32 changes: 0 additions & 32 deletions packages/react/src/components/WorldIDIcon.tsx

This file was deleted.

10 changes: 0 additions & 10 deletions packages/react/src/store/idkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export type IDKitStore = {
verifyCallbacks: Record<ConfigSource, CallbackFn<ISuccessResult> | undefined> | Record<string, never>
successCallbacks: Record<ConfigSource, CallbackFn<ISuccessResult> | undefined> | Record<string, never>

computed: {
canGoBack: (stage: IDKITStage) => boolean
}

retryFlow: () => void
setStage: (stage: IDKITStage) => void
onOpenChange: (open: boolean) => void
Expand Down Expand Up @@ -69,12 +65,6 @@ const useIDKitStore = createWithEqualityFn<IDKitStore>()(
successCallbacks: {},
stage: IDKITStage.WORLD_ID,

computed: {
canGoBack: (stage: IDKITStage) => {
return stage == IDKITStage.PRIVACY
},
},

setStage: stage => set({ stage }),
setErrorState: errorState => set({ errorState }),
setProcessing: (processing: boolean) => set({ processing }),
Expand Down
1 change: 0 additions & 1 deletion packages/react/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export enum IDKITStage {
WORLD_ID = 'WORLD_ID',
PRIVACY = 'PRIVACY',
SUCCESS = 'SUCCESS',
ERROR = 'ERROR',
HOST_APP_VERIFICATION = 'HOST_APP_VERIFICATION',
Expand Down
Loading

0 comments on commit f1e3388

Please sign in to comment.