generated from bywhitebird/starter-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ddd6f96
commit 21e9322
Showing
18 changed files
with
1,541 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default { | ||
plugins: { | ||
tailwindcss: {}, | ||
autoprefixer: {}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,101 @@ | ||
import React from 'react' | ||
import { | ||
Outlet, | ||
RootRoute, | ||
Route, | ||
Router, | ||
RouterProvider, | ||
} from '@tanstack/router' | ||
import React, { useCallback, useContext } from 'react' | ||
|
||
import './globals.css' | ||
|
||
import { OctentOptionsContext, OctentOptionsProvider } from './contexts/octent-options-context' | ||
import { useAuth } from './hooks/use-auth' | ||
import { HttpsGitAuthenticationPage } from './pages/authentication/https-git-authentication-page' | ||
|
||
import type { OctentOptions } from '.' | ||
|
||
// import { GithubAuthenticationPage } from './pages/authentication/github-authentication-page' | ||
|
||
function navigate(url: Exclude<Parameters<typeof router.getRoute>[0], '__root__'>) { | ||
location.href = url | ||
} | ||
|
||
function Root() { | ||
const renavigate = useCallback((type: string) => { | ||
if (type !== 'none') | ||
// navigate('/dashboard') | ||
console.log('Navigate to dashboard') | ||
else | ||
navigate('/') | ||
}, []) | ||
|
||
useAuth.subscribe((state) => { | ||
renavigate(state.type) | ||
}) | ||
|
||
const authenticationType = useAuth(state => state.type) | ||
renavigate(authenticationType) | ||
|
||
return <Outlet /> | ||
} | ||
|
||
const rootRoute = new RootRoute({ | ||
component: Root, | ||
}) | ||
|
||
function Index() { | ||
const options = useContext(OctentOptionsContext) | ||
|
||
const parsedRepositoryUrl = new URL(options.repositoryUrl) | ||
|
||
switch (parsedRepositoryUrl.hostname) { | ||
// case 'github.com': { | ||
// console.error('GitHub authentication is not supported yet') | ||
// } | ||
default: { | ||
if (parsedRepositoryUrl.protocol === 'https:') | ||
navigate('/authentication/other') | ||
|
||
if (parsedRepositoryUrl.protocol === 'ssh:') | ||
console.error('SSH authentication is not supported yet') | ||
} | ||
} | ||
|
||
return <></> | ||
} | ||
|
||
const indexRoute = new Route({ | ||
path: '/', | ||
component: Index, | ||
getParentRoute: () => rootRoute, | ||
}) | ||
|
||
const httpsGitAuthenticationRoute = new Route({ | ||
path: '/authentication/other', | ||
component: HttpsGitAuthenticationPage, | ||
getParentRoute: () => rootRoute, | ||
}) | ||
|
||
const routeTree = rootRoute.addChildren([ | ||
indexRoute, | ||
httpsGitAuthenticationRoute, | ||
]) | ||
|
||
const router = new Router({ routeTree }) | ||
|
||
declare module '@tanstack/router' { | ||
interface Register { | ||
router: typeof router | ||
} | ||
} | ||
|
||
function App(props: OctentOptions) { | ||
return ( | ||
<div className="App"> | ||
{JSON.stringify(props)} | ||
</div> | ||
) | ||
return <div className="App bg-background text-foreground h-screen w-screen"> | ||
<OctentOptionsProvider value={props}> | ||
<RouterProvider router={router} /> | ||
</OctentOptionsProvider> | ||
</div> | ||
} | ||
|
||
export default App |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Slot } from '@radix-ui/react-slot' | ||
import { type VariantProps, cva } from 'class-variance-authority' | ||
import * as React from 'react' | ||
|
||
import { cn } from '@/lib/utils' | ||
|
||
const buttonVariants = cva( | ||
'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-background', | ||
{ | ||
variants: { | ||
variant: { | ||
default: 'bg-primary text-primary-foreground hover:bg-primary/90', | ||
destructive: | ||
'bg-destructive text-destructive-foreground hover:bg-destructive/90', | ||
outline: | ||
'border border-input hover:bg-accent hover:text-accent-foreground', | ||
secondary: | ||
'bg-secondary text-secondary-foreground hover:bg-secondary/80', | ||
ghost: 'hover:bg-accent hover:text-accent-foreground', | ||
link: 'underline-offset-4 hover:underline text-primary', | ||
}, | ||
size: { | ||
default: 'h-10 py-2 px-4', | ||
sm: 'h-9 px-3 rounded-md', | ||
lg: 'h-11 px-8 rounded-md', | ||
}, | ||
}, | ||
defaultVariants: { | ||
variant: 'default', | ||
size: 'default', | ||
}, | ||
}, | ||
) | ||
|
||
export interface ButtonProps | ||
extends React.ButtonHTMLAttributes<HTMLButtonElement>, | ||
VariantProps<typeof buttonVariants> { | ||
asChild?: boolean | ||
} | ||
|
||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( | ||
({ className, variant, size, asChild = false, ...props }, ref) => { | ||
const Comp = asChild ? Slot : 'button' | ||
return ( | ||
<Comp | ||
className={cn(buttonVariants({ variant, size, className }))} | ||
ref={ref} | ||
{...props} | ||
/> | ||
) | ||
}, | ||
) | ||
Button.displayName = 'Button' | ||
|
||
export { Button, buttonVariants } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import * as React from "react" | ||
|
||
import { cn } from "@/lib/utils" | ||
|
||
const Card = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn( | ||
"rounded-lg border bg-card text-card-foreground shadow-sm", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
Card.displayName = "Card" | ||
|
||
const CardHeader = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn("flex flex-col space-y-1.5 p-6", className)} | ||
{...props} | ||
/> | ||
)) | ||
CardHeader.displayName = "CardHeader" | ||
|
||
const CardTitle = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLHeadingElement> | ||
>(({ className, ...props }, ref) => ( | ||
<h3 | ||
ref={ref} | ||
className={cn( | ||
"text-lg font-semibold leading-none tracking-tight", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
CardTitle.displayName = "CardTitle" | ||
|
||
const CardDescription = React.forwardRef< | ||
HTMLParagraphElement, | ||
React.HTMLAttributes<HTMLParagraphElement> | ||
>(({ className, ...props }, ref) => ( | ||
<p | ||
ref={ref} | ||
className={cn("text-sm text-muted-foreground", className)} | ||
{...props} | ||
/> | ||
)) | ||
CardDescription.displayName = "CardDescription" | ||
|
||
const CardContent = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} /> | ||
)) | ||
CardContent.displayName = "CardContent" | ||
|
||
const CardFooter = React.forwardRef< | ||
HTMLDivElement, | ||
React.HTMLAttributes<HTMLDivElement> | ||
>(({ className, ...props }, ref) => ( | ||
<div | ||
ref={ref} | ||
className={cn(" flex items-center p-6 pt-0", className)} | ||
{...props} | ||
/> | ||
)) | ||
CardFooter.displayName = "CardFooter" | ||
|
||
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent } |
Oops, something went wrong.