Skip to content

Commit

Permalink
switch to react
Browse files Browse the repository at this point in the history
  • Loading branch information
tytremblay committed Dec 13, 2024
1 parent ed8be74 commit c591d1a
Show file tree
Hide file tree
Showing 19 changed files with 507 additions and 446 deletions.
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,33 @@
"@radix-ui/react-switch": "^1.1.2",
"@radix-ui/react-toggle": "^1.1.1",
"@radix-ui/react-toggle-group": "^1.1.1",
"@vitejs/plugin-react": "^4.3.4",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"immer": "^10.1.1",
"lodash": "^4.17.21",
"lucide-react": "^0.456.0",
"next-themes": "^0.2.1",
"preact": "^10.25.2",
"qrcode.react": "^3.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-helmet": "^6.1.0",
"tailwind-merge": "^2.5.5",
"tailwindcss-animate": "^1.0.7",
"vaul": "^1.1.1",
"zustand": "^4.5.5"
},
"devDependencies": {
"@preact/preset-vite": "^2.9.3",
"@tailwindcss/forms": "^0.5.9",
"@types/lodash": "^4.17.13",
"@types/node": "^22.10.2",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.7",
"@types/react-helmet": "^6.1.11",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.16",
"typescript": "^5.7.2",
"vite": "^5.4.11"
}
}
}
756 changes: 382 additions & 374 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

Binary file modified public/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/favicon.ico
Binary file not shown.
2 changes: 1 addition & 1 deletion src/components/ConfigEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button } from '@/components/ui/button';
import Editor, { useMonaco } from '@monaco-editor/react';
import { useEffect, useMemo, useState } from 'preact/hooks';
import { useEffect, useMemo, useState } from 'react';
import schema from '../../config/schema.json';
import { getConfig, useQRScoutState } from '../store/store';

Expand Down
9 changes: 5 additions & 4 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Helmet } from 'react-helmet';
import { useQRScoutState } from '../store/store';

export function Header() {
const title = useQRScoutState(state => state.formData.title);
const page_title = useQRScoutState(state => state.formData.page_title);
return (
<head>
<title>QRScout|{title}</title>
<Helmet>
<title>QRScout | {page_title}</title>
<link rel="icon" href="/favicon.ico" />
</head>
</Helmet>
);
}
132 changes: 90 additions & 42 deletions src/components/Logo.tsx

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/components/QR/QRModal.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Copy } from 'lucide-react';
import { useMemo } from 'preact/hooks';
import { QRCodeSVG } from 'qrcode.react';
import { useMemo } from 'react';
import { getFieldValue, useQRScoutState } from '../../store/store';
import { Config } from '../inputs/BaseInputProps';
import { Button } from '../ui/button';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { QRModal } from '@/components/QR';
import { useMemo } from 'preact/hooks';
import { useMemo } from 'react';
import { useQRScoutState } from '../../../store/store';
import { Section } from '../../core/Section';
import { ResetButton } from './ResetButton';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sections/ConfigSection/ConfigSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useMediaQuery } from '@/hooks';
import { setConfig } from '@/store/store';
import { Transition } from '@headlessui/react';
import { Cog6ToothIcon } from '@heroicons/react/20/solid';
import { useMemo, useState } from 'preact/hooks';
import { useMemo, useState } from 'react';
import { Section } from '../../core/Section';
import { Settings } from './Settings';
import { ThemeSelector } from './ThemeSelector';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Sections/ConfigSection/ThemeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Computer, Moon, Sun } from 'lucide-react';
import { useTheme } from 'next-themes';

export function ThemeSelector() {
const { theme, setTheme, resolvedTheme } = useTheme();
const { theme, setTheme } = useTheme();

return (
<div className="flex items-center space-x-2">
Expand Down
2 changes: 1 addition & 1 deletion src/components/core/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRef } from 'preact/hooks';
import { useRef } from 'react';
import { useOnClickOutside } from '../../hooks/useOnClickOutside';
import { CloseButton } from './CloseButton';

Expand Down
2 changes: 1 addition & 1 deletion src/components/inputs/CheckboxInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function CheckboxInput(data: BoolInputProps) {
return (
<Switch
checked={data.value}
onClick={e => setChecked(!checked)}
onCheckedChange={setChecked}
id={data.title}
className="m-2"
/>
Expand Down
6 changes: 3 additions & 3 deletions src/components/inputs/SelectInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export default function SelectInput(data: SelectInputProps) {
// }
}
return (
<Select name={data.title} onValueChange={handleSelect}>
<Select name={data.title} onValueChange={handleSelect} value={data.value}>
<SelectTrigger>
<SelectValue value={data.value} />
<SelectValue />
</SelectTrigger>
<SelectContent value={data.value} multiple={data.multiSelect}>
<SelectContent>
{Object.keys(data.options).map(o => {
return (
<SelectItem key={o} value={o}>
Expand Down
8 changes: 4 additions & 4 deletions src/components/inputs/StringInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export default function StringInput(props: StringInputProps) {
name={`${data?.title}_input`}
id={`${data?.title}_input`}
onChange={handleChange}
defaultValue={data?.defaultValue || ''}
value={data?.value || ''}
maxlength={props.max}
minlength={props.min}
defaultValue={data?.defaultValue}
value={data?.value}
maxLength={props.max}
minLength={props.min}
/>
);
}
7 changes: 4 additions & 3 deletions src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { render } from 'preact';
import { createRoot } from 'react-dom/client';
import { App } from './app.tsx';
import './index.css';

import { ThemeProvider } from 'next-themes';

render(
const root = createRoot(document.getElementById('app')!);

root.render(
<ThemeProvider attribute="class">
<App />
</ThemeProvider>,
document.getElementById('app')!,
);
6 changes: 2 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"paths": {
"@/*": ["./src/*"],
"react": ["./node_modules/preact/compat/"],
"react-dom": ["./node_modules/preact/compat/"]
"@/*": ["./src/*"]
},

/* Bundler mode */
Expand All @@ -18,7 +16,7 @@
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"jsxImportSource": "preact",
"jsxImportSource": "react",

/* Linting */
"strict": true,
Expand Down
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import preact from '@preact/preset-vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import { defineConfig } from 'vite';

// https://vitejs.dev/config/
export default defineConfig({
base: '/QRScout/',
plugins: [preact()],
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
Expand Down

0 comments on commit c591d1a

Please sign in to comment.