@luxfi/core 4.4.18 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  'use client'
2
2
 
3
3
  import Link from 'next/link'
4
+ import { useRouter } from 'next/navigation'
5
+
4
6
  import Autoplay from 'embla-carousel-autoplay'
5
7
  import { setCookie } from 'cookies-next'
6
8
 
@@ -8,10 +10,9 @@ import { cn } from '@hanzo/ui/util'
8
10
  import { Button, Carousel, CarouselContent, CarouselItem } from '@hanzo/ui/primitives'
9
11
  import { LoginPanel as Login } from '@hanzo/auth/components'
10
12
 
11
- import { Logo } from '..'
13
+ import Logo from '../logo'
12
14
  import LuxLogo from '../icons/lux-logo'
13
15
  import { legal } from '../../site-def/footer'
14
- import { useRouter } from 'next/navigation'
15
16
 
16
17
  const LoginPanel: React.FC<{
17
18
  close: () => void
@@ -44,7 +45,7 @@ const LoginPanel: React.FC<{
44
45
  redirectUrl && router.push(redirectUrl)
45
46
  }
46
47
 
47
- return (<>
48
+ return (
48
49
  <div className={cn('grid grid-cols-1 md:grid-cols-2', className)}>
49
50
  <div className='hidden md:flex w-full h-full bg-level-1 flex-row items-end justify-end overflow-y-auto min-h-screen'>
50
51
  <div className='h-full w-full max-w-[750px] px-8 pt-0'>
@@ -97,7 +98,7 @@ const LoginPanel: React.FC<{
97
98
  </div>
98
99
  </div>
99
100
  </div>
100
- </>)
101
+ )
101
102
  }
102
103
 
103
104
  export default LoginPanel
@@ -8,14 +8,12 @@ export * as Icons from './icons'
8
8
  export { default as Logo } from './logo'
9
9
  export { default as MiniChart } from './mini-chart'
10
10
  export { default as NotFound } from './not-found'
11
- export {
12
- default as RootLayout,
13
- viewport as rootLayoutViewport
14
- } from './root-layout'
11
+
15
12
 
16
13
  export { default as CheckoutPanel } from './commerce/checkout-panel'
17
14
  export { default as LoginPanel } from './auth/login-panel'
18
15
  export { default as AuthListener } from './auth/auth-listener'
16
+ export { default as Scripts } from './scripts'
19
17
 
20
18
 
21
19
  /* PLEASE KEEP
@@ -4,6 +4,7 @@ import { useEffect } from 'react'
4
4
  import { GoogleAnalytics } from '@next/third-parties/google'
5
5
  import { FacebookPixel } from '../next/analytics'
6
6
 
7
+ // TODO: Rename this component, since Next has one called Script
7
8
  const Scripts = () => {
8
9
 
9
10
  useEffect(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxfi/core",
3
- "version": "4.4.18",
3
+ "version": "4.5.0",
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/",
@@ -10,7 +10,7 @@
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "git+https://github.com/luxfi/web.git",
13
- "directory": "packages/common"
13
+ "directory": "packages/core"
14
14
  },
15
15
  "keywords": [
16
16
  "components",
@@ -23,14 +23,11 @@
23
23
  "pub": "npm publish",
24
24
  "build": "tsc",
25
25
  "tc": "tsc",
26
- "ln:ui": "pnpm link -g @hanzo/ui",
27
- "ln:auth": "pnpm link -g @hanzo/auth",
28
- "ln:cmmc": "pnpm link -g @hanzo/commerce",
29
- "ul:all": "rm node_modules/@hanzo/*",
30
26
  "clean": "rm -rf node_modules"
31
27
  },
32
28
  "exports": {
33
29
  ".": "./components/index.ts",
30
+ "./root-layout": "./root-layout/index.tsx",
34
31
  "./server-actions": "./server-actions/index.ts",
35
32
  "./next": "./next/index.ts",
36
33
  "./style/": "./style/",
@@ -39,11 +36,12 @@
39
36
  "./conf": "./conf/index.ts"
40
37
  },
41
38
  "dependencies": {
42
- "@hanzo/auth": "2.4.4",
43
- "@hanzo/commerce": "6.4.4",
44
- "@hanzo/ui": "3.6.3",
39
+ "@hanzo/auth": "2.4.5",
40
+ "@hanzo/commerce": "6.4.6",
41
+ "@hanzo/ui": "3.6.4",
45
42
  "@next/third-parties": "^14.1.0",
46
43
  "cookies-next": "^4.1.1",
44
+ "date-fns": "^3.6.0",
47
45
  "embla-carousel-autoplay": "^8.0.1",
48
46
  "react-device-detect": "^2.2.3",
49
47
  "react-social-icons": "^6.4.0"
@@ -0,0 +1,2 @@
1
+ Unwise to have this in a barrel / index file that is mostly imported by a Client Component.
2
+ Creates Next / SSR issues
@@ -0,0 +1,113 @@
1
+ import React, { type PropsWithChildren } from 'react'
2
+ import type { Viewport } from 'next'
3
+
4
+ import { Toaster } from '@hanzo/ui/primitives'
5
+ import { AuthServiceProvider } from '@hanzo/auth/service'
6
+ import { getUserServerSide } from '@hanzo/auth/server'
7
+ import type { AuthServiceConf } from '@hanzo/auth/types'
8
+ import { CommerceProvider } from '@hanzo/commerce'
9
+
10
+ import getAppRouterBodyFontClasses from '../next/font/get-app-router-font-classes'
11
+ import { FacebookPixelHead } from '../next/analytics/pixel-analytics'
12
+
13
+ import { AuthListener, ChatWidget, Header, Scripts } from '../components'
14
+
15
+ import { selectionUISpecifiers } from '../conf'
16
+ import type SiteDef from '../site-def/site-def'
17
+
18
+
19
+ // Next 14: https://nextjs.org/docs/app/building-your-application/upgrading/codemods#use-viewport-export
20
+ const viewport = {
21
+ themeColor: [
22
+ { media: '(prefers-color-scheme: light)', color: 'white' },
23
+ { media: '(prefers-color-scheme: dark)', color: 'black' },
24
+ ],
25
+ } satisfies Viewport
26
+
27
+ /*
28
+ These '.variable' fields are actually autogenerate css classnames that *define* the actual
29
+ css variables ('--<ugly-name>') that one asks for in the tailwind classes.
30
+ They are what make them available in the global scope. So this MUST
31
+ be done like this for the tailwind font classes to work.
32
+
33
+ (...not to be confused with the css var itself. This field should be named something else!)
34
+ */
35
+
36
+ /*
37
+ re body: overflow-y-hidden overflow-x-hidden, h-full
38
+ We cannot have these on body tag for scroll-snap to work on iOS!
39
+ */
40
+ const bodyClasses =
41
+ 'bg-background text-foreground flex flex-col min-h-full' +
42
+ getAppRouterBodyFontClasses()
43
+
44
+ const RootLayout: React.FC<PropsWithChildren & {
45
+ siteDef: SiteDef
46
+ showHeader?: boolean
47
+ chatbot?: boolean
48
+ }> = async ({
49
+ showHeader = false,
50
+ chatbot = true,
51
+ siteDef,
52
+ children,
53
+ }) => {
54
+
55
+ const currentUser = await getUserServerSide()
56
+ const usingCommerce = siteDef.ext.commerce && siteDef.ext.commerce.rootNode && siteDef.ext.commerce.families
57
+
58
+ const Guts: React.FC = () => (<>
59
+ {showHeader && <Header siteDef={siteDef}/>}
60
+ {children}
61
+ {chatbot && (
62
+ <ChatWidget
63
+ title='LUX'
64
+ subtitle='AI'
65
+ chatbotUrl='https://lux.chat/iframe'
66
+ suggestedQuestions={siteDef.ext?.chatBot?.suggestedQuestions ?? []}
67
+ />
68
+ )}
69
+ </>)
70
+
71
+ return (
72
+ <html lang='en' suppressHydrationWarning className='hanzo-ui-dark-theme' style={{backgroundColor: '#000'}}>
73
+ <head >
74
+ {/* https://stackoverflow.com/a/75716588/11645689 */ }
75
+ <base target='_blank' />
76
+ <FacebookPixelHead/>
77
+ </head>
78
+
79
+ <body className={bodyClasses} style={{
80
+ // Not sure why these got added (by my commit)
81
+
82
+ // As also noted above, 'overflow: hidden' on the <body> tag breaks scroll snap!
83
+ //paddingRight: '0 !important',
84
+ //maxWidth: '100vw',
85
+ display: 'none', // see scripts.tsx
86
+
87
+ }}>
88
+ <Scripts/>
89
+ <AuthServiceProvider user={currentUser} conf={{} as AuthServiceConf}>
90
+ {usingCommerce ? (
91
+ <CommerceProvider
92
+ rootNode={siteDef.ext.commerce.rootNode}
93
+ families={siteDef.ext.commerce.families}
94
+ options={siteDef.ext.commerce.options}
95
+ uiSpecs={selectionUISpecifiers}
96
+ >
97
+ <Guts />
98
+ </CommerceProvider>
99
+ ) : (
100
+ <Guts />
101
+ )}
102
+ <AuthListener/>
103
+ </AuthServiceProvider>
104
+ <Toaster position='top-center' duration={3000}/>
105
+ </body>
106
+ </html>
107
+ )
108
+ }
109
+
110
+ export {
111
+ RootLayout,
112
+ viewport
113
+ }
@@ -0,0 +1 @@
1
+ move login and logout api routes here!
@@ -14,7 +14,7 @@
14
14
  display: none;
15
15
  }
16
16
 
17
- .font-heading, h1, h2, h3 {
17
+ .font-heading {
18
18
  @apply uppercase;
19
19
  }
20
20
 
@@ -1,71 +0,0 @@
1
- import React, { type PropsWithChildren } from 'react'
2
-
3
- import type { Viewport } from 'next'
4
-
5
- import { Toaster } from '@hanzo/ui/primitives'
6
-
7
- import Header from './header'
8
- import type SiteDef from '../site-def/site-def'
9
- import getAppRouterBodyFontClasses from '../next/font/get-app-router-font-classes'
10
- import { FacebookPixelHead } from '../next/analytics/pixel-analytics'
11
- import Scripts from './scripts'
12
-
13
- // Next 14: https://nextjs.org/docs/app/building-your-application/upgrading/codemods#use-viewport-export
14
- const viewport = {
15
- themeColor: [
16
- { media: '(prefers-color-scheme: light)', color: 'white' },
17
- { media: '(prefers-color-scheme: dark)', color: 'black' },
18
- ],
19
- } satisfies Viewport
20
-
21
- /*
22
- These '.variable' fields are actually autogenerate css classnames that *define* the actual
23
- css variables ('--<ugly-name>') that one asks for in the tailwind classes.
24
- They are what make them available in the global scope. So this MUST
25
- be done like this for the tailwind font classes to work.
26
-
27
- (...not to be confused with the css var itself. This field should be named something else!)
28
- */
29
-
30
- /*
31
- re body: overflow-y-hidden overflow-x-hidden, h-full
32
- We cannot have these on body tag for scroll-snap to work on iOS!
33
- */
34
- const bodyClasses =
35
- 'bg-background text-foreground flex flex-col min-h-full' +
36
- getAppRouterBodyFontClasses()
37
-
38
- const RootLayout: React.FC<PropsWithChildren & {
39
- siteDef: SiteDef
40
- header?: boolean
41
- }> = ({
42
- header = true,
43
- siteDef,
44
- children,
45
- }) => (
46
- <html lang='en' suppressHydrationWarning className='hanzo-ui-dark-theme' style={{backgroundColor: '#000'}}>
47
- <head >
48
- {/* https://stackoverflow.com/a/75716588/11645689 */ }
49
- <base target='_blank' />
50
- <FacebookPixelHead/>
51
- </head>
52
- <body className={bodyClasses} style={{
53
- // Not sure why these got added (by my check in)
54
- // overflow: hidden here breaks scroll snap, see comment above
55
- //paddingRight: '0 !important',
56
- //maxWidth: '100vw',
57
- display: 'none', // see scripts.tsx
58
-
59
- }}>
60
- <Scripts/>
61
- {header && <Header siteDef={siteDef}/>}
62
- {children}
63
- <Toaster position='top-center' duration={3000}/>
64
- </body>
65
- </html>
66
- )
67
-
68
- export {
69
- RootLayout as default,
70
- viewport
71
- }