@luxfi/ui 5.5.3 → 5.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/LICENSE +29 -0
  2. package/components/auth/callback.tsx +40 -0
  3. package/components/auth/login-panel.tsx +15 -44
  4. package/components/auth/login.tsx +47 -0
  5. package/components/auth/provider.tsx +34 -0
  6. package/components/auth/resume.ts +16 -0
  7. package/components/auth/widget.tsx +80 -0
  8. package/components/chat-widget.tsx +6 -7
  9. package/components/commerce/checkout-panel/desktop-cp.tsx +2 -2
  10. package/components/commerce/checkout-panel/mobile-cp.tsx +2 -2
  11. package/components/footer-nav.tsx +31 -0
  12. package/components/footer.tsx +7 -12
  13. package/components/header/desktop-nav-menu.tsx +4 -6
  14. package/components/header/desktop.tsx +4 -4
  15. package/components/header/index.tsx +1 -1
  16. package/components/header/mobile-nav-menu-ai.tsx +1 -1
  17. package/components/header/mobile-nav-menu.tsx +2 -2
  18. package/components/header/mobile.tsx +3 -3
  19. package/components/icons/index.ts +0 -1
  20. package/components/index.ts +2 -2
  21. package/components/logo.tsx +39 -67
  22. package/components/security/index.tsx +55 -0
  23. package/next/analytics/fpixel.ts +1 -1
  24. package/next/middleware/determine-device-mw.ts +0 -13
  25. package/package.json +31 -28
  26. package/root-layout/index.tsx +3 -10
  27. package/site-def/footer/community.tsx +1 -4
  28. package/site-def/footer/network.ts +2 -2
  29. package/site-def/main-nav.tsx +19 -19
  30. package/style/lux-global.css +49 -0
  31. package/types/site-def.ts +7 -0
  32. package/util/index.ts +11 -0
  33. package/components/auth/auth-listener.tsx +0 -29
  34. package/components/auth/auth-token/clear-auth-token.tsx +0 -12
  35. package/components/auth/auth-token/set-auth-token.tsx +0 -16
  36. package/components/auth/common-auth-domains.ts +0 -17
  37. package/components/auth/mobile-login-button.tsx +0 -107
  38. package/components/auth/signup-panel.tsx +0 -113
  39. package/components/icons/lux-logo.tsx +0 -10
@@ -1,29 +0,0 @@
1
- 'use client'
2
-
3
- import { useEffect } from 'react'
4
- import { useAuth } from '@hanzo/auth/service'
5
- import { getCookie } from 'cookies-next'
6
-
7
- const AuthListener = () => {
8
- const auth = useAuth()
9
-
10
- useEffect(() => {
11
- fetch(`${process.env.NEXT_PUBLIC_LOGIN_SITE_URL}/api/auth/get-auth-token`, {
12
- method: 'GET',
13
- credentials: 'include',
14
- })
15
- .then(response => response.json())
16
- .then((data: any) => {
17
- const token = data.reqToken
18
- console.log(data)
19
- console.log(token)
20
- if (!!token) {
21
- auth.loginWithCustomToken(token)
22
- }
23
- })
24
- }, [auth])
25
-
26
- return ( <></> )
27
- }
28
-
29
- export default AuthListener
@@ -1,12 +0,0 @@
1
- import domains from '../common-auth-domains'
2
-
3
- const ClearAuthToken = () => {
4
- return (<>
5
- {domains.map(({url}) => (
6
- /* Clear auth-token cookie across all Lux domains */
7
- <img src={`${url}/api/auth/clear-auth-token`} className='absolute hidden'/>
8
- ))}
9
- </>)
10
- }
11
-
12
- export default ClearAuthToken
@@ -1,16 +0,0 @@
1
- import domains from '../common-auth-domains'
2
-
3
- const SetAuthToken: React.FC<{
4
- authToken: string
5
- }> = ({
6
- authToken,
7
- }) => {
8
- return (<>
9
- {!!authToken && domains.map(({url}) => (
10
- /* Set auth-token cookie across all Lux domains */
11
- <img src={`${url}/api/auth/set-auth-token?token=${authToken}`} className='absolute hidden'/>
12
- ))}
13
- </>)
14
- }
15
-
16
- export default SetAuthToken
@@ -1,17 +0,0 @@
1
- const domains = [
2
- { id: 'lux.market', url: 'https://lux.market' },
3
- { id: 'lux.shop', url: 'https://lux.shop' },
4
- { id: 'lux.credit', url: 'https://lux.credit' },
5
- { id: 'lux.network', url: 'https://lux.network' },
6
- { id: 'wallet.lux.network', url: 'https://wallet.lux.network' },
7
- { id: 'safe.lux.network', url: 'https://safe.lux.network' },
8
- { id: 'lux.finance', url: 'https://lux.finance' },
9
- { id: 'lux.exchange', url: 'https://lux.exchange' },
10
- { id: 'lux.quest', url: 'https://lux.quest' },
11
- { id: 'lux.id', url: 'https://lux.id' },
12
- { id: 'lux.chat', url: 'https://lux.chat' }
13
- ]
14
-
15
- export {
16
- domains as default
17
- }
@@ -1,107 +0,0 @@
1
- 'use client'
2
- import React from "react"
3
- import { observer } from "mobx-react-lite"
4
-
5
- import {
6
- Button,
7
- LinkElement,
8
- Popover,
9
- PopoverContent,
10
- PopoverTrigger,
11
- Separator
12
- } from '@hanzo/ui/primitives'
13
-
14
- import type { LinkDef } from '@hanzo/ui/types'
15
- import { cn } from '@hanzo/ui/util'
16
-
17
- import { useAuth } from "@hanzo/auth/service"
18
-
19
- import { Ethereum } from "@hanzo/auth/icons"
20
-
21
- const MobileAuthWidget: React.FC<{
22
- noLogin?: boolean
23
- className?: string
24
- handleLogin?: () => void
25
- }> = observer(({
26
- noLogin = false,
27
- className
28
- }) => {
29
- const auth = useAuth()
30
- const handleLogin = () => {
31
- window.location.href = "https://lux.id";
32
- };
33
-
34
- if (!auth) {
35
- return null
36
- }
37
- if (!auth.loggedIn && typeof window !== 'undefined') {
38
- return (noLogin ? null : (
39
- (handleLogin) ? (
40
- <div className="flex items-center py-1 px-1 gap-1">
41
- <Button
42
- variant='primary'
43
- className='text-base font-semibold !min-w-0 self-center flex-1'
44
- onClick={handleLogin}
45
- >
46
- Sign Up
47
- </Button>
48
- <Button
49
- variant='outline'
50
- className=' text-base font-semibold !min-w-0 self-center flex-1'
51
- onClick={handleLogin}
52
- >
53
- Log In
54
- </Button>
55
- </div>
56
- ) : (
57
- <LinkElement
58
- def={{
59
- href: `${process.env.NEXT_PUBLIC_LOGIN_SITE_URL}?redirectUrl=${window.location.href}`,
60
- title: 'Login',
61
- variant: 'primary',
62
- newTab: false
63
- } satisfies LinkDef}
64
- className='h-8 w-fit !min-w-0'
65
- />
66
- )
67
- ))
68
- }
69
-
70
- return (
71
- <Popover>
72
- <PopoverTrigger asChild>
73
- <Button
74
- variant="outline"
75
- size='icon'
76
- className={cn('rounded-full text-muted border-2 border-muted bg-level-1 hover:bg-level-2 hover:border-foreground hover:text-foreground uppercase w-8 h-8', className)}
77
- >{auth.user?.email[0]}</Button>
78
- </PopoverTrigger>
79
- <PopoverContent className='bg-level-0'>
80
- <div className="grid gap-4">
81
- <div className="space-y-2 truncate">
82
- {auth.user?.displayName ? (
83
- <>
84
- <h4 className="font-medium leading-none truncate">{auth.user.displayName}</h4>
85
- <p className="text-sm opacity-50 truncate">{auth.user.email}</p>
86
- </>
87
- ) : (
88
- <h4 className="font-medium leading-none truncate">{auth.user?.email}</h4>
89
- )}
90
- {auth.user?.walletAddress ? (
91
- <p className="text-sm opacity-50 truncate">{auth.user.walletAddress}</p>
92
- ) : (
93
- <Button variant="outline" className='w-full flex items-center gap-2' onClick={auth.associateWallet.bind(auth)}>
94
- <Ethereum height={20} />Connect your wallet
95
- </Button>
96
- )}
97
- </div>
98
- <Separator />
99
- <Button variant="outline" onClick={auth.logout.bind(auth)}>Logout</Button>
100
- </div>
101
- </PopoverContent>
102
- </Popover>
103
- )
104
-
105
- })
106
-
107
- export default MobileAuthWidget
@@ -1,113 +0,0 @@
1
- 'use client'
2
-
3
- import Link from 'next/link'
4
- import { useRouter } from 'next/navigation'
5
-
6
- import { setCookie } from 'cookies-next'
7
-
8
- import { cn } from '@hanzo/ui/util'
9
- import { Button, Carousel, CarouselContent, CarouselItem } from '@hanzo/ui/primitives'
10
- import { LoginPanel as Login, SignupPanel as Signup } from '@hanzo/auth/components'
11
-
12
- import { LuxLogo } from '../icons'
13
- import Logo from '../logo'
14
- import { EmblaAutoplay } from '..'
15
- import { legal } from '../../site-def/footer'
16
-
17
- const SignupPanel: React.FC<{
18
- close: () => void
19
- getStartedUrl?: string
20
- redirectUrl?: string
21
- className?: string
22
- reviews: { text: string, author: string, href: string }[]
23
- setIsLogin?: React.Dispatch<React.SetStateAction<boolean>>
24
- }> = ({
25
- close,
26
- getStartedUrl = '/',
27
- redirectUrl,
28
- className = '',
29
- reviews,
30
- setIsLogin
31
- }) => {
32
- const router = useRouter()
33
-
34
- const termsOfServiceUrl = legal.find(({ title }) => title === 'Terms and Conditions')?.href || ''
35
- const privacyPolicyUrl = legal.find(({ title }) => title === 'Privacy Policy')?.href || ''
36
- const domains = ['lux.id', 'lux.credit', 'lux.market', 'lux.network', 'lux.shop', 'wallet.lux.network', 'safe.lux.network', 'lux.finance', 'lux.exchange', 'lux.quest']
37
-
38
- // TODO :aa shouldn't this happen in @hanzo/auth: components/LoginPanel ??
39
- // Otherwise, the functionality is split across modules! (and client/fw!)
40
- // (This was never my intent w the onLoginChanged callback.)
41
- const onLogin = (token: string) => {
42
- for (let i = 0; i < domains.length; i++) {
43
- setCookie('auth-token', token, {
44
- domain: domains[i],
45
- path: '/',
46
- sameSite: 'none',
47
- secure: true,
48
- httpOnly: false,
49
- expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30), // 30 days
50
- })
51
- }
52
-
53
- redirectUrl && router.push(redirectUrl)
54
- }
55
-
56
- return (
57
- <div className={cn('grid grid-cols-1 md:grid-cols-2', className)}>
58
- <div className='hidden md:flex w-full h-full bg-[radial-gradient(circle_at_24.1%_68.8%_,_rgba(15,14,14,0)_,_rgba(9,9,9,99.4))] flex-row items-end justify-end overflow-y-auto min-h-screen'>
59
- <div className='h-full w-full max-w-[750px] px-8 pt-0'>
60
- <div className='h-full w-full max-w-[550px] mx-auto flex flex-col justify-between min-h-screen py-10'>
61
- <Button
62
- variant='ghost'
63
- onClick={close}
64
- className='w-fit !min-w-0 p-2'
65
- >
66
- <Logo size='md' textClx='!cursor-pointer' variant='text-only' />
67
- </Button>
68
- <Carousel
69
- options={{ align: 'center', loop: true }}
70
- className='w-full'
71
- plugins={[EmblaAutoplay({ delay: 5000, stopOnInteraction: true })]}
72
- >
73
- <CarouselContent>
74
- {reviews.map(({ text, author, href }, index) => (
75
- <CarouselItem key={index}>
76
- <Link href={href} className='flex flex-col gap-3 cursor-pointer'>
77
- <p>“{text}“</p>
78
- <p className='text-sm'>{author}</p>
79
- </Link>
80
- </CarouselItem>
81
- ))}
82
- </CarouselContent>
83
- </Carousel>
84
- </div>
85
- </div>
86
- </div>
87
- <div className='w-full h-full bg-background flex flex-row items-center'>
88
- <div className='w-full max-w-[750px] relative flex flex-col items-center px-8 pt-0 text-center'>
89
- <div className='relative h-full w-full max-w-[400px] mx-auto flex flex-col gap-4 items-center py-10'>
90
- <Button
91
- variant='ghost'
92
- onClick={close}
93
- className='block md:hidden absolute rounded-full p-2 left-0 h-auto hover:bg-background'
94
- >
95
- <LuxLogo className='w-5 h-5' />
96
- </Button>
97
- <Signup
98
- getStartedUrl={getStartedUrl}
99
- redirectUrl={redirectUrl}
100
- className='w-full max-w-sm'
101
- termsOfServiceUrl={termsOfServiceUrl}
102
- privacyPolicyUrl={privacyPolicyUrl}
103
- onLoginChanged={onLogin}
104
- setIsLogin={setIsLogin}
105
- />
106
- </div>
107
- </div>
108
- </div>
109
- </div>
110
- )
111
- }
112
-
113
- export default SignupPanel
@@ -1,10 +0,0 @@
1
- import React from 'react'
2
- import { type LucideProps } from 'lucide-react'
3
-
4
- const LuxLogo: React.FC<LucideProps> = (props: LucideProps) => (
5
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" {...props}>
6
- <polygon points="25,46.65 50,3.35 0,3.35" fill="white" stroke='black' strokeWidth={props.strokeWidth}/>
7
- </svg>
8
- )
9
-
10
- export default LuxLogo