@luxfi/core 4.3.18 → 4.4.3
Sign up to get free protection for your applications and to get access to all the features.
- package/components/auth/auth-listener.tsx +32 -0
- package/components/auth/common-auth-domains.ts +12 -0
- package/components/auth/login-panel.tsx +27 -0
- package/components/commerce/bag-button.tsx +1 -1
- package/components/header/mobile.tsx +2 -2
- package/components/icons/bag-icon.tsx +2 -2
- package/components/index.ts +1 -0
- package/package.json +3 -3
- package/style/lux-global.css +12 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
'use client'
|
2
|
+
|
3
|
+
import { useEffect } from "react"
|
4
|
+
import { useAuth } from '@hanzo/auth/service'
|
5
|
+
|
6
|
+
const AuthListener = () => {
|
7
|
+
const auth = useAuth()
|
8
|
+
|
9
|
+
const requestAuthToken = () => {
|
10
|
+
const childFrame = document.getElementById('login') as HTMLIFrameElement
|
11
|
+
childFrame?.contentWindow?.postMessage(true, process.env.NEXT_PUBLIC_LOGIN_SITE_URL ?? '')
|
12
|
+
}
|
13
|
+
|
14
|
+
useEffect(() => {
|
15
|
+
const handleMessage = (event: any) => {
|
16
|
+
if (event.origin === process.env.NEXT_PUBLIC_AUTH_ORIGIN) {
|
17
|
+
const token = event.data
|
18
|
+
auth.loginWithCustomToken(token)
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
window.addEventListener('message', handleMessage)
|
23
|
+
|
24
|
+
return () => {
|
25
|
+
window.removeEventListener('message', handleMessage)
|
26
|
+
}
|
27
|
+
}, [])
|
28
|
+
|
29
|
+
return (<iframe id='login' onLoad={requestAuthToken} src={process.env.NEXT_PUBLIC_LOGIN_SITE_URL}/>)
|
30
|
+
}
|
31
|
+
|
32
|
+
export default AuthListener
|
@@ -0,0 +1,12 @@
|
|
1
|
+
const domains = [
|
2
|
+
{ id: 'lux.market', url: 'https://lux.market' },
|
3
|
+
{ id: 'lux.credit', url: 'https://lux.credit' },
|
4
|
+
{ id: 'lux.network', url: 'https://lux.network' },
|
5
|
+
{ id: 'lux.shop', url: 'https://lux.shop' },
|
6
|
+
{ id: 'lux.finance', url: 'https://lux.finance' },
|
7
|
+
{ id: 'lux.exchange', url: 'https://lux.exchange' },
|
8
|
+
]
|
9
|
+
|
10
|
+
export {
|
11
|
+
domains as default
|
12
|
+
}
|
@@ -1,3 +1,5 @@
|
|
1
|
+
'use client'
|
2
|
+
|
1
3
|
import Link from 'next/link'
|
2
4
|
import Autoplay from 'embla-carousel-autoplay'
|
3
5
|
|
@@ -8,6 +10,8 @@ import { LoginPanel as Login } from '@hanzo/auth/components'
|
|
8
10
|
import { Logo } from '..'
|
9
11
|
import LuxLogo from '../icons/lux-logo'
|
10
12
|
import { legal } from '../../site-def/footer'
|
13
|
+
import domains from './common-auth-domains'
|
14
|
+
import { useEffect } from 'react'
|
11
15
|
|
12
16
|
const LoginPanel: React.FC<{
|
13
17
|
close: () => void
|
@@ -25,6 +29,28 @@ const LoginPanel: React.FC<{
|
|
25
29
|
const termsOfServiceUrl = legal.find(({title}) => title === 'Terms and Conditions')?.href || ''
|
26
30
|
const privacyPolicyUrl = legal.find(({title}) => title === 'Privacy Policy')?.href || ''
|
27
31
|
|
32
|
+
const onLogin = (token: string) => {
|
33
|
+
localStorage.setItem('auth-token', token)
|
34
|
+
for (const { url } of domains) {
|
35
|
+
parent?.contentWindow?.postMessage(token, url)
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
useEffect(() => {
|
40
|
+
const handleMessage = (event: any) => {
|
41
|
+
if (domains.includes(event.origin)) {
|
42
|
+
const token = localStorage.getItem('auth-token')
|
43
|
+
parent.contentWindow?.postMessage(token, event.origin)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
window.addEventListener('message', handleMessage)
|
48
|
+
|
49
|
+
return () => {
|
50
|
+
window.removeEventListener('message', handleMessage)
|
51
|
+
}
|
52
|
+
}, [])
|
53
|
+
|
28
54
|
return (
|
29
55
|
<div className={cn('grid grid-cols-1 md:grid-cols-2', className)}>
|
30
56
|
<div className='hidden md:flex w-full h-full bg-level-1 flex-row items-end justify-end overflow-y-auto min-h-screen'>
|
@@ -72,6 +98,7 @@ const LoginPanel: React.FC<{
|
|
72
98
|
className='w-full max-w-sm'
|
73
99
|
termsOfServiceUrl={termsOfServiceUrl}
|
74
100
|
privacyPolicyUrl={privacyPolicyUrl}
|
101
|
+
onLoginChanged={onLogin}
|
75
102
|
/>
|
76
103
|
</div>
|
77
104
|
</div>
|
@@ -47,7 +47,7 @@ const BagButton: React.FC<{
|
|
47
47
|
<div className={
|
48
48
|
'z-above-content flex flex-col justify-center items-center ' +
|
49
49
|
'absolute left-0 right-0 top-0 bottom-0 ' +
|
50
|
-
'leading-none font-sans font-bold text-
|
50
|
+
'leading-none font-sans font-bold text-primary-fg text-xs '
|
51
51
|
}>
|
52
52
|
<div className='h-[3px] w-full' />
|
53
53
|
<div>{c.cartQuantity}</div>
|
@@ -55,9 +55,9 @@ const MobileHeader: React.FC<{
|
|
55
55
|
|
56
56
|
const menuOpen = () => (menuState !== 'closed')
|
57
57
|
|
58
|
-
const onLoginChanged = (
|
58
|
+
const onLoginChanged = (token: string) => {
|
59
59
|
// by def, menu was in state 'login'
|
60
|
-
if (
|
60
|
+
if (!!token) { setMenuState('nav') }
|
61
61
|
}
|
62
62
|
|
63
63
|
const setMenuOpen = (open: boolean) => {
|
@@ -2,8 +2,8 @@ import React from 'react'
|
|
2
2
|
import { type LucideProps } from 'lucide-react'
|
3
3
|
|
4
4
|
const BagIcon: React.FC<LucideProps> = (props: LucideProps) => (
|
5
|
-
<svg fill="none" viewBox="0 0
|
6
|
-
<path d="
|
5
|
+
<svg fill="none" viewBox="0 0 1019 1281" {...props}>
|
6
|
+
<path d="m977.243 365.553h-175.407v-90.629c0-151.923-131.968-274.924-292.334-274.924-160.367 0-292.337 123.002-292.337 274.924v90.629h-175.4023c-23.3886 0-41.7627 17.051-41.7627 38.756v775.121c0 55.8 48.4456 100.76 108.582 100.76h801.84c60.138 0 108.578-44.96 108.578-100.76v-775.121c0-21.705-18.37-38.756-41.757-38.756zm-676.553-90.629c0-108.517 93.546-196.9408 208.812-196.9408 115.265 0 208.813 88.4218 208.813 196.9408v89.08h-417.625z" fill="currentColor"/>
|
7
7
|
</svg>
|
8
8
|
)
|
9
9
|
|
package/components/index.ts
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@luxfi/core",
|
3
|
-
"version": "4.3
|
3
|
+
"version": "4.4.3",
|
4
4
|
"description": "Library that contains shared UI primitives, support for a common design system, and other boilerplate support.",
|
5
5
|
"publishConfig": {
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
@@ -39,8 +39,8 @@
|
|
39
39
|
"./conf": "./conf/index.ts"
|
40
40
|
},
|
41
41
|
"dependencies": {
|
42
|
-
"@hanzo/auth": "2.
|
43
|
-
"@hanzo/commerce": "6.
|
42
|
+
"@hanzo/auth": "2.4.2",
|
43
|
+
"@hanzo/commerce": "6.4.2",
|
44
44
|
"@hanzo/ui": "3.6.3",
|
45
45
|
"@next/third-parties": "^14.1.0",
|
46
46
|
"embla-carousel-autoplay": "^8.0.1",
|
package/style/lux-global.css
CHANGED
@@ -17,3 +17,15 @@
|
|
17
17
|
.font-heading, h1, h2, h3 {
|
18
18
|
@apply uppercase;
|
19
19
|
}
|
20
|
+
|
21
|
+
/* Specific style fixes for react-square-web-payments-sdk -
|
22
|
+
* reduce gap between card input and pay button
|
23
|
+
*/
|
24
|
+
#rswps-card-container {
|
25
|
+
min-height: unset !important;
|
26
|
+
}
|
27
|
+
|
28
|
+
.sq-card-wrapper .sq-card-message {
|
29
|
+
margin-top: 0 !important;
|
30
|
+
margin-bottom: 0 !important;
|
31
|
+
}
|