nitro-web 0.0.20 → 0.0.22

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.
@@ -1,10 +1,52 @@
1
- import { Layout1 as L1, Layout2 as L2 } from 'nitro-web'
2
- import Logo from '../../client/imgs/logo/logo.svg'
3
1
  import { Config } from 'types'
2
+ import { Outlet } from 'react-router-dom'
3
+ import { Message, Sidebar } from 'nitro-web'
4
+ import Logo from '../../client/imgs/logo/logo.svg'
5
+
6
+ // Dashboard, app screens (only the <Outlet/> receives `params` and `location`)
7
+ export function Layout1() {
8
+ return (
9
+ <div class="bg-[#F3F3F3]">
10
+ <Message />
11
+ <div class="flex-1">
12
+ <div class="max-w-[1800px] mx-auto lg:flex min-h-[100%] w-[100%] bg-[#FDFDFD] shadow-[0_0_40px_0_rgb(237_237_237)]">
13
+ <Sidebar Logo={Logo} />
14
+ <div class="py-10 px-14 flex-1">
15
+ <Outlet />
16
+ </div>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ )
21
+ }
22
+
23
+ // Signin, reset password, etc
24
+ export function Layout2({ config }: { config: Config }) {
25
+ return (
26
+ <div class="bg-[#F3F3F3]">
27
+ <Message />
28
+ <div class="max-w-[1800px] mx-auto bg-[#FDFDFD] shadow-[0_0_40px_0_rgb(237_237_237)] flex flex-col min-h-full w-full">
29
+ <div class="max-w-[700px] mx-auto flex-1 w-full px-5 py-10">
30
+ <div class="border-b mb-6">
31
+ <Link to="/signin" class="logo relative block -ml-1 -mt-1 p-1">
32
+ <Logo width="60" />
33
+ </Link>
34
+ </div>
35
+ <Outlet />
36
+ </div>
4
37
 
5
- const links = [
6
- { name: 'Nitro on Github', to: 'https://github.com/boycce/nitro-web', initial: 'G' },
7
- ]
38
+ <div class="max-w-[700px] mx-auto w-full px-5 pb-4 flex items-center text-sm text-[#1F1F1F]">
39
+ <ul class="flex-1 flex gap-4 list-style-none">
40
+ <li><Link class="underline1" to="/">Home</Link></li>
41
+ <li><Link class="underline1" to="/about">About</Link></li>
42
+ <li><Link class="underline1" to="/support">Support</Link></li>
43
+ </ul>
44
+ <div>
45
+ 2025 © {config?.name || 'Nitro'}
46
+ </div>
47
+ </div>
8
48
 
9
- export const Layout1 = ({ config }: { config: Config }) => { return <L1 Logo={Logo} links={links} config={config} /> }
10
- export const Layout2 = ({ config }: { config: Config }) => { return <L2 Logo={Logo} config={config} /> }
49
+ </div>
50
+ </div>
51
+ )
52
+ }
package/client/app.tsx CHANGED
@@ -30,7 +30,7 @@ type Route = {
30
30
  redirect?: string
31
31
  }
32
32
 
33
- export async function setupApp(config: Config, layouts: React.FC[]) {
33
+ export async function setupApp(config: Config, layouts: React.FC<LayoutProps>[]) {
34
34
  // Fetch state and init app
35
35
  const settings: Settings = {
36
36
  beforeApp: config.beforeApp || beforeApp,
package/client/index.ts CHANGED
@@ -45,10 +45,6 @@ export { Location } from '../components/partials/form/location'
45
45
  export { Select, getSelectStyle } from '../components/partials/form/select'
46
46
  export { Toggle } from '../components/partials/form/toggle'
47
47
 
48
- // Component Layouts
49
- export { Layout1 } from '../components/partials/layout/layout1'
50
- export { Layout2 } from '../components/partials/layout/layout2'
51
-
52
48
  // Component Other
53
49
  export { IsFirstRender } from '../components/partials/is-first-render'
54
50
 
@@ -2,7 +2,6 @@
2
2
  import { Dialog, DialogBackdrop, DialogPanel, TransitionChild } from '@headlessui/react'
3
3
  import avatarImg from 'nitro-web/client/imgs/avatar.jpg'
4
4
  import { isDemo } from 'nitro-web'
5
- import { Config } from 'types'
6
5
  import {
7
6
  Bars3Icon,
8
7
  HomeIcon,
@@ -14,17 +13,16 @@ import {
14
13
  const sidebarWidth = 'lg:w-80'
15
14
 
16
15
  export type SidebarProps = {
17
- Logo: React.FC<{ width?: string, height?: string, alt?: string }>;
16
+ Logo?: React.FC<{ width?: string, height?: string }>;
18
17
  menu?: { name: string; to: string; Icon: React.FC<{ className?: string }> }[]
19
18
  links?: { name: string; to: string; initial: string }[]
20
- config?: Config
21
19
  }
22
20
 
23
21
  function classNames(...classes: string[]) {
24
22
  return classes.filter(Boolean).join(' ')
25
23
  }
26
24
 
27
- export function Sidebar({ Logo, menu, links, config }: SidebarProps) {
25
+ export function Sidebar({ Logo, menu, links }: SidebarProps) {
28
26
  const [sidebarOpen, setSidebarOpen] = useState(false)
29
27
  return (
30
28
  <>
@@ -47,14 +45,14 @@ export function Sidebar({ Logo, menu, links, config }: SidebarProps) {
47
45
  </button>
48
46
  </div>
49
47
  </TransitionChild>
50
- <SidebarContents Logo={Logo} menu={menu} links={links} config={config} />
48
+ <SidebarContents Logo={Logo} menu={menu} links={links} />
51
49
  </DialogPanel>
52
50
  </div>
53
51
  </Dialog>
54
52
 
55
53
  {/* Static sidebar for desktop */}
56
54
  <div className={`hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:flex-col ${sidebarWidth}`}>
57
- <SidebarContents Logo={Logo} menu={menu} links={links} config={config} />
55
+ <SidebarContents Logo={Logo} menu={menu} links={links} />
58
56
  </div>
59
57
 
60
58
  {/* mobile sidebar closed */}
@@ -73,7 +71,7 @@ export function Sidebar({ Logo, menu, links, config }: SidebarProps) {
73
71
  )
74
72
  }
75
73
 
76
- function SidebarContents ({ Logo, menu, links, config }: SidebarProps) {
74
+ function SidebarContents ({ Logo, menu, links }: SidebarProps) {
77
75
  const location = useLocation()
78
76
  const [store] = useTracked()
79
77
  const user = store.user
@@ -92,18 +90,19 @@ function SidebarContents ({ Logo, menu, links, config }: SidebarProps) {
92
90
  ]
93
91
 
94
92
  const _links = links || [
95
- { name: 'Team 1', to: '#', initial: 'T' },
96
- { name: 'Team 2', to: '#', initial: 'H' },
93
+ { name: 'Nitro on Github', to: 'https://github.com/boycce/nitro-web', initial: 'G' },
97
94
  ]
98
95
 
99
96
  // Sidebar component, swap this element with another sidebar if you like
100
97
  return (
101
98
  <div className="flex grow flex-col gap-y-8 overflow-y-auto bg-white py-5 px-10 lg:border-r lg:border-gray-200">
102
- <div className="flex h-16 shrink-0 items-center">
103
- <Link to="/">
104
- <Logo alt={config?.name || 'Nitro'} width="70" height={undefined} />
105
- </Link>
106
- </div>
99
+ {Logo && (
100
+ <div className="flex h-16 shrink-0 items-center">
101
+ <Link to="/">
102
+ <Logo width="70" height={undefined} />
103
+ </Link>
104
+ </div>
105
+ )}
107
106
  <nav className="flex flex-1 flex-col">
108
107
  <ul role="list" className="flex flex-1 flex-col gap-y-7">
109
108
  <li>
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Nitro is a battle-tested, modular base project to turbocharge your projects, styled using Tailwind 🚀",
4
4
  "repository": "github:boycce/nitro-web",
5
5
  "homepage": "https://boycce.github.io/nitro-web/",
6
- "version": "0.0.20",
6
+ "version": "0.0.22",
7
7
  "main": "./client/index.ts",
8
8
  "type": "module",
9
9
  "keywords": [
package/readme.md CHANGED
@@ -11,7 +11,7 @@ npm i nitro-web
11
11
  ### Install
12
12
 
13
13
  1. Copy ./_example into your project
14
- 2. In package.json, replace `"nitro-web": "file:.."` with `"nitro-web": "~0.0.20"`
14
+ 2. In package.json, replace `"nitro-web": "file:.."` with `"nitro-web": "~0.0.22"`
15
15
  3. In package.json, replace `"../.eslintrc.json"` with `"./node_modules/nitro-web/.eslintrc.json"`
16
16
  4. Run `npm i`
17
17
 
package/types.ts CHANGED
@@ -44,4 +44,6 @@ export type Store = {
44
44
  message?: MessageObject | string | null
45
45
  user?: User | null,
46
46
  apiAvailable?: boolean
47
- }
47
+ }
48
+
49
+ export type Svg = React.FC<React.SVGProps<SVGElement>>
@@ -1,29 +0,0 @@
1
- import { css } from 'twin.macro'
2
- import { Outlet } from 'react-router-dom'
3
- import { Message, Sidebar, SidebarProps } from 'nitro-web'
4
-
5
- export function Layout1({ Logo, menu, links, config }: SidebarProps) {
6
- // Dashboard, app screens (only the <Outlet/> receives `params` and `location`)
7
- return (
8
- <div css={style} class="bg-[#F3F3F3]">
9
- <Message />
10
- <div class="flex-1">
11
- <div class="wrapper lg:flex min-h-[100%] w-[100%] bg-[#FDFDFD] shadow-[0_0_40px_0_rgb(237_237_237)]">
12
- <Sidebar Logo={Logo} menu={menu} links={links} config={config} />
13
- <div class="py-10 px-14 flex-1">
14
- <Outlet />
15
- </div>
16
- </div>
17
- </div>
18
- </div>
19
- )
20
- }
21
-
22
- const style = css`
23
- .wrapper {
24
- position: relative;
25
- max-width: 1800px;
26
- margin: 0 auto;
27
- }
28
- `
29
-
@@ -1,48 +0,0 @@
1
- import { css } from 'twin.macro'
2
- import { Outlet } from 'react-router-dom'
3
- import { Message } from 'nitro-web'
4
- import { Config } from 'types'
5
-
6
- // Signin, reset password, etc
7
- export function Layout2({ Logo, config }: { Logo: React.ComponentType<{ alt: string; width: string }>, config: Config }) {
8
- return (
9
- <div css={style} class="bg-[#F3F3F3]">
10
- <Message />
11
- <div class="wrapper bg-[#FDFDFD] shadow-[0_0_40px_0_rgb(237_237_237)] flex flex-col min-h-full w-full">
12
- <div class="flex-1 w-full wrapper-2 px-5 py-10">
13
- <div class="border-b mb-6">
14
- <Link to="/signin" class="logo relative block -ml-1 -mt-1 p-1">
15
- <Logo alt={config?.name || 'Nitro'} width="60" />
16
- </Link>
17
- </div>
18
- <Outlet />
19
- </div>
20
-
21
- <div class="wrapper-2 w-full px-5 pb-4 flex items-center text-sm text-[#1F1F1F]">
22
- <ul class="flex-1 flex gap-4 list-style-none">
23
- <li><Link class="underline1" to="/">Home</Link></li>
24
- <li><Link class="underline1" to="/about">About</Link></li>
25
- <li><Link class="underline1" to="/support">Support</Link></li>
26
- </ul>
27
- <div>
28
- 2025 © {config?.name || 'Nitro'}
29
- </div>
30
- </div>
31
-
32
- </div>
33
- </div>
34
- )
35
- }
36
-
37
- const style = css`
38
- .wrapper {
39
- position: relative;
40
- max-width: 1800px;
41
- margin: 0 auto;
42
- }
43
- .wrapper-2 {
44
- max-width: 700px;
45
- margin: 0 auto;
46
- box-sizing: border-box;
47
- }
48
- `