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: final tweaks #212

Merged
merged 2 commits into from
Dec 11, 2023
Merged
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
2 changes: 1 addition & 1 deletion packages/core/src/bridge.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { create } from 'zustand'
import { type IDKitConfig } from '@/types/config'
import { VerificationState } from '@/types/bridge'
import type { ISuccessResult } from '@/types/result'
import type { CredentialType } from '@/types/config'
import { encodeAction, generateSignal } from '@/lib/hashing'
import { AppErrorCodes, ResponseStatus } from '@/types/bridge'
import { VerificationLevel, type IDKitConfig } from '@/types/config'
import { decryptResponse, encryptRequest, exportKey, generateKey } from '@/lib/crypto'
import {
DEFAULT_VERIFICATION_LEVEL,
Expand Down
10 changes: 5 additions & 5 deletions packages/react/src/components/AboutWorldID.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Props = {
const AboutWorldID: FC<Props> = ({ className }) => {
return (
<div className={classNames(className, 'space-y-4 text-left')}>
<p className="text-0d151d text-sm font-medium uppercase dark:text-white">{__('What is World ID?')}</p>
<p className="text-sm font-medium uppercase text-0d151d dark:text-white">{__('What is World ID?')}</p>
<div className="space-y-3">
<FeatureHighlight title="Your global digital ID" icon={HumanIcon}>
<p>{__('With Worldcoin and World ID sign in seamlessly and prove you are a unique human.')}</p>
Expand All @@ -31,12 +31,12 @@ type FeatureHighlightProps = PropsWithChildren<{

const FeatureHighlight: FC<FeatureHighlightProps> = ({ icon: Icon, title, children }) => (
<div className="flex space-x-6">
<div className="bg-d3dfea/30 dark:bg-29343f flex aspect-square h-8 w-8 items-center justify-center rounded-full">
<Icon className="text-0d151d h-3 w-3 dark:text-white" />
<div className="flex aspect-square h-8 w-8 items-center justify-center rounded-full bg-d3dfea/30 dark:bg-29343f">
<Icon className="h-3 w-3 text-0d151d dark:text-white" />
</div>
<div>
<p className="text-0d151d font-medium dark:text-white">{title}</p>
<div className="text-9eafc0 dark:text-9eafc0 mt-[2px] text-sm font-normal">{children}</div>
<p className="font-medium text-0d151d dark:text-white">{title}</p>
<div className="mt-[2px] text-sm font-normal text-9eafc0 dark:text-9eafc0">{children}</div>
</div>
</div>
)
Expand Down
20 changes: 4 additions & 16 deletions packages/react/src/components/IDKitWidget/BaseWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ import { AnimatePresence, motion } from 'framer-motion'
import ArrowLongLeftIcon from '../Icons/ArrowLongLeftIcon'
import HostAppVerificationState from './States/HostAppVerificationState'

const getParams = ({ open, processing, onOpenChange, stage, setStage, theme, computed, setOptions }: IDKitStore) => ({
const getParams = ({ open, processing, onOpenChange, stage, setStage, computed, setOptions }: IDKitStore) => ({
stage,
theme,
setStage,
processing,
setOptions,
Expand All @@ -35,18 +34,10 @@ const getParams = ({ open, processing, onOpenChange, stage, setStage, theme, com
})

const IDKitWidget: FC<WidgetProps> = ({ children, ...config }) => {
const {
isOpen,
onOpenChange,
processing,
stage,
setStage,
canGoBack,
setOptions,
theme: _theme,
} = useIDKitStore(getParams, shallow)
const media = useMedia()

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

useEffect(() => {
setOptions(config, ConfigSource.PROPS)
}, [config, setOptions])
Expand Down Expand Up @@ -77,10 +68,7 @@ const IDKitWidget: FC<WidgetProps> = ({ children, ...config }) => {
{isOpen && (
<root.div mode="open" id="idkit-widget">
<Styles />
<div
id="modal"
className={classNames(_theme == 'dark' && 'dark', 'fixed z-10 font-sans')}
>
<div id="modal" className="fixed z-10 font-sans">
<Dialog.Overlay asChild>
<motion.div
initial={{ opacity: 0 }}
Expand Down
54 changes: 0 additions & 54 deletions packages/react/src/components/SignInButton.tsx

This file was deleted.

68 changes: 0 additions & 68 deletions packages/react/src/components/SignInWithWorldID.tsx

This file was deleted.

6 changes: 2 additions & 4 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import useIDKit from './hooks/useIDKit'
import SignInButton from './components/SignInButton'
import IDKitWidget from '@/components/IDKitWidget/index'
import type { WidgetProps, Config } from '@/types/config'
import { VerificationLevel } from '@worldcoin/idkit-core'
import { solidityEncode } from '@worldcoin/idkit-core/hashing'
import SignInWithWorldID from './components/SignInWithWorldID'
import type { ISuccessResult, IErrorState } from '@worldcoin/idkit-core'
import { CredentialType, VerificationLevel } from '@worldcoin/idkit-core'

export { IDKitWidget, useIDKit, solidityEncode, SignInWithWorldID, CredentialType, SignInButton, VerificationLevel }
export { IDKitWidget, useIDKit, solidityEncode, VerificationLevel }
export type { ISuccessResult, IErrorState, Config, WidgetProps }
6 changes: 1 addition & 5 deletions packages/react/src/store/idkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export type IDKitStore = {
stage: IDKITStage
autoClose: boolean
processing: boolean
theme: Config['theme']
result: ISuccessResult | null
errorState: IErrorState | null
errorCallbacks: Record<ConfigSource, CallbackFn<IErrorState> | undefined> | Record<string, never>
Expand Down Expand Up @@ -60,7 +59,6 @@ const useIDKitStore = createWithEqualityFn<IDKitStore>()(

open: false,
result: null,
theme: 'light',
errorTitle: '',
errorDetail: '',
autoClose: true,
Expand Down Expand Up @@ -116,18 +114,16 @@ const useIDKitStore = createWithEqualityFn<IDKitStore>()(
action_description,
bridge_url,
autoClose,
theme,
advanced,
}: Config,
source: ConfigSource
) => {
set({
theme,
signal,
action,
autoClose,
bridge_url,
action_description,
autoClose: autoClose ?? true,
app_id: advanced?.self_hosted ? SELF_HOSTED_APP_ID : app_id,
verification_level: verification_level ?? DEFAULT_VERIFICATION_LEVEL,
})
Expand Down
2 changes: 0 additions & 2 deletions packages/react/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ export enum ConfigSource {
export type WidgetConfig = {
/** Whether to automatically close the widget after a successful verification. Defaults to `false`. */
autoClose?: boolean
/** The theme to apply to the widget's UI. Defaults to `light`. */
theme?: 'dark' | 'light'
/** Function to trigger when verification is successful. Should receive a single parameter of type `ISuccessResult` which contains the proof details. */
onSuccess: CallbackFn<ISuccessResult>
/** Called after the proof is returned from the World App, but before showing the success screen. Throwing in this screen will show the user a custom error. Used to perform additional validation when needed. */
Expand Down
Loading