Skip to content

Commit

Permalink
fix(shadcn): config fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
tomjeannesson committed Aug 22, 2023
1 parent 5142c1a commit c37330f
Show file tree
Hide file tree
Showing 26 changed files with 1,832 additions and 200 deletions.
3 changes: 3 additions & 0 deletions desktop-app/.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
33 changes: 33 additions & 0 deletions desktop-app/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"standard-with-typescript",
"plugin:react/recommended"
],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"project": "./desktop-app/tsconfig.json"
},
"plugins": [
"react"
],
"rules": {
"react/react-in-jsx-scope": "off",
"react/jsx-filename-extension": [
1,
{
"extensions": [
".ts",
".tsx"
]
}
],
// "space-before-function-paren": "off",
"@typescript-eslint/space-before-function-paren": "off",
"@typescript-eslint/indent": "off"
}
}
7 changes: 7 additions & 0 deletions desktop-app/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "none",
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"semi": false
}
4 changes: 2 additions & 2 deletions desktop-app/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"cssVariables": true
},
"aliases": {
"components": "renderer/components",
"utils": "renderer/lib/utils"
"components": "@/components",
"utils": "@/lib/utils"
}
}
36 changes: 19 additions & 17 deletions desktop-app/main/background.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
import { app } from 'electron';
import serve from 'electron-serve';
import { createWindow } from './helpers';
import { app } from 'electron'
import serve from 'electron-serve'
import { createWindow } from './helpers'

const isProd: boolean = process.env.NODE_ENV === 'production';
const isProd: boolean = process.env.NODE_ENV === 'production'

if (isProd) {
serve({ directory: 'app' });
serve({ directory: 'app' })
} else {
app.setPath('userData', `${app.getPath('userData')} (development)`);
app.setPath('userData', `${app.getPath('userData')} (development)`)
}

(async () => {
await app.whenReady();
;(async () => {
await app.whenReady()

const mainWindow = createWindow('main', {
width: 1000,
height: 600,
});
height: 600
})

if (isProd) {
await mainWindow.loadURL('app://./home.html');
await mainWindow.loadURL('app://./index.html')
} else {
const port = process.argv[2];
await mainWindow.loadURL(`http://localhost:${port}/home`);
mainWindow.webContents.openDevTools();
const port = process.argv[2]
await mainWindow.loadURL(`http://localhost:${port}/`)
mainWindow.webContents.openDevTools()
}
})();
})()
.then()
.catch(console.error)

app.on('window-all-closed', () => {
app.quit();
});
app.quit()
})
15 changes: 8 additions & 7 deletions desktop-app/main/helpers/create-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import {
} from 'electron';
import Store from 'electron-store';


export default (windowName: string, options: BrowserWindowConstructorOptions): BrowserWindow => {
const key = 'window-state';
const name = `window-state-${windowName}`;
const store = new Store({ name });
const defaultSize = {
width: options.width,
height: options.height,
width: options.width!,
height: options.height!,
};
const restore = function() : Electron.Rectangle {return store.get(key, defaultSize) as Electron.Rectangle};
let state = {};
let win;
let win:BrowserWindow;

const restore = () => store.get(key, defaultSize);

const getCurrentPosition = () => {
const position = win.getPosition();
Expand All @@ -29,7 +30,7 @@ export default (windowName: string, options: BrowserWindowConstructorOptions): B
};
};

const windowWithinBounds = (windowState, bounds) => {
const windowWithinBounds = (windowState:Electron.Rectangle, bounds:Electron.Rectangle) => {
return (
windowState.x >= bounds.x &&
windowState.y >= bounds.y &&
Expand All @@ -41,12 +42,12 @@ export default (windowName: string, options: BrowserWindowConstructorOptions): B
const resetToDefaults = () => {
const bounds = screen.getPrimaryDisplay().bounds;
return Object.assign({}, defaultSize, {
x: (bounds.width - defaultSize.width) / 2,
x: (bounds.width - defaultSize.width ) / 2,
y: (bounds.height - defaultSize.height) / 2,
});
};

const ensureVisibleOnSomeDisplay = windowState => {
const ensureVisibleOnSomeDisplay = (windowState:Electron.Rectangle ) => {
const visible = screen.getAllDisplays().some(display => {
return windowWithinBounds(windowState, display.bounds);
});
Expand Down
14 changes: 12 additions & 2 deletions desktop-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@
"scripts": {
"dev": "nextron",
"build": "nextron build",
"postinstall": "electron-builder install-app-deps"
"postinstall": "electron-builder install-app-deps",
"lint": "next lint"
},
"dependencies": {
"@hookform/resolvers": "^3.2.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.0.6",
"@radix-ui/react-separator": "^1.0.3",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.4",
"class-variance-authority": "^0.7.0",
Expand All @@ -32,15 +34,23 @@
"devDependencies": {
"@types/node": "^18.11.18",
"@types/react": "^18.0.26",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"autoprefixer": "^10.4.7",
"electron": "^21.3.3",
"electron-builder": "^23.6.0",
"eslint": "^8.0.1",
"eslint-config-next": "13.4.19",
"eslint-config-standard-with-typescript": "^38.0.0",
"eslint-plugin-import": "^2.25.2",
"eslint-plugin-n": "^15.0.0 || ^16.0.0 ",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.33.2",
"next": "^12.3.4",
"nextron": "^8.5.0",
"postcss": "^8.4.13",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwindcss": "^3.1.8",
"typescript": "^4.9.4"
"typescript": "*"
}
}
37 changes: 37 additions & 0 deletions desktop-app/renderer/components/layout/contextHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import type { ReactNode } from 'react'
import HeaderPopover from '@/components/ui/headerPopover'
import { Separator } from '@/components/ui/separator'
export default function ContextHeader({
children,
isProvider = false,
isExchangeAccount = false,
isSpace = false,
isFleet = false,
isBot = false
}: {
children: ReactNode
isProvider?: boolean
isExchangeAccount?: boolean
isSpace?: boolean
isFleet?: boolean
isBot?: boolean
}): JSX.Element {
isProvider = isProvider || isExchangeAccount || isSpace || isFleet || isBot
isExchangeAccount = isExchangeAccount || isSpace || isFleet || isBot
isSpace = isSpace || isFleet || isBot
isFleet = isFleet || isBot

return (
<>
<div className="flex items-center justify-between">
{isProvider && <HeaderPopover />}
<Separator orientation="vertical" />
{isExchangeAccount && <HeaderPopover />}
{isSpace && <HeaderPopover />}
{isFleet && <HeaderPopover />}
{isBot && <HeaderPopover />}
</div>
<main>{children}</main>
</>
)
}
11 changes: 11 additions & 0 deletions desktop-app/renderer/components/layout/footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { ReactNode } from 'react'

const Footer = ({ children }: { children: ReactNode }): JSX.Element => {
return (
<>
<main>{children}</main>
</>
)
}

export default Footer
13 changes: 13 additions & 0 deletions desktop-app/renderer/components/layout/header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { ReactNode } from 'react'

export default function Header({
children
}: {
children: ReactNode
}): JSX.Element {
return (
<>
<main>{children}</main>
</>
)
}
39 changes: 16 additions & 23 deletions desktop-app/renderer/components/ui/accordion.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
"use client"
"use client";

import * as AccordionPrimitive from "@radix-ui/react-accordion"
import { ChevronDown } from "lucide-react"
import * as React from "react"
import * as AccordionPrimitive from "@radix-ui/react-accordion";
import { ChevronDown } from "lucide-react";
import * as React from "react";

import { cn } from "@/lib/utils"
import { cn } from "@/lib/utils";

const Accordion = AccordionPrimitive.Root
const Accordion = AccordionPrimitive.Root;

const AccordionItem = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
>(({ className, ...props }, ref) => (
<AccordionPrimitive.Item
ref={ref}
className={cn("border-b", className)}
{...props}
/>
))
AccordionItem.displayName = "AccordionItem"
<AccordionPrimitive.Item ref={ref} className={cn("border-b", className)} {...props} />
));
AccordionItem.displayName = "AccordionItem";

const AccordionTrigger = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Trigger>,
Expand All @@ -31,14 +27,13 @@ const AccordionTrigger = React.forwardRef<
"flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",
className
)}
{...props}
>
{...props}>
{children}
<ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
</AccordionPrimitive.Trigger>
</AccordionPrimitive.Header>
))
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName
));
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;

const AccordionContent = React.forwardRef<
React.ElementRef<typeof AccordionPrimitive.Content>,
Expand All @@ -50,12 +45,10 @@ const AccordionContent = React.forwardRef<
"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",
className
)}
{...props}
>
{...props}>
<div className="pb-4 pt-0">{children}</div>
</AccordionPrimitive.Content>
))
AccordionContent.displayName = AccordionPrimitive.Content.displayName

export { Accordion, AccordionContent, AccordionItem, AccordionTrigger }
));
AccordionContent.displayName = AccordionPrimitive.Content.displayName;

export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
3 changes: 1 addition & 2 deletions desktop-app/renderer/components/ui/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,4 @@ const CardFooter = React.forwardRef<
))
CardFooter.displayName = "CardFooter"

export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle }

export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }
Loading

0 comments on commit c37330f

Please sign in to comment.