Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reincorporated Preact and PreactTS templates. #145

Merged
merged 23 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bd67853
Reincorporated Preact and PreactTS templates.
extrordinaire Aug 28, 2022
b8914eb
Update README.md
extrordinaire Aug 28, 2022
2ab7a4a
Added the templates inside .scripts for testing and added that step i…
extrordinaire Aug 28, 2022
e877b7e
Merge remote-tracking branch 'refs/remotes/origin/dev' into dev
extrordinaire Aug 28, 2022
9e79f25
Formatted with cargo fmt --all and added missing dependency babel/core
extrordinaire Aug 28, 2022
3a37a70
Formatted with prettier
extrordinaire Aug 28, 2022
dcbc64f
Fixed scripts in preact vanilla
extrordinaire Aug 28, 2022
a42f63d
Update .github/CONTRIBUTING.md
extrordinaire Aug 30, 2022
ff0873c
Update packages/cli/fragments/fragment-preact-ts/index.html
extrordinaire Aug 30, 2022
e2c55fe
Update packages/cli/fragments/fragment-preact-ts/src/app.tsx
extrordinaire Aug 30, 2022
c76ef96
Update packages/cli/fragments/fragment-preact/src/app.jsx
extrordinaire Aug 30, 2022
607c5fd
Update packages/cli/fragments/fragment-preact/src/app.jsx
extrordinaire Aug 30, 2022
35682da
Done all revision request and modified every which is more concise
extrordinaire Aug 30, 2022
a76e4ce
Modified every Click on Tauri, Vite, and {Framework} logos to learn m…
extrordinaire Aug 30, 2022
33db40f
Formatted with Cargo and Prettier, fixed misspelled stylesheet index …
extrordinaire Aug 30, 2022
3e850e5
Update packages/cli/fragments/fragment-preact-ts/src/app.tsx
extrordinaire Aug 30, 2022
72c09da
Update packages/cli/fragments/fragment-preact/src/app.jsx
extrordinaire Aug 30, 2022
6dfb7af
Merge branch 'dev' into dev2
amrbashir Aug 30, 2022
3027e3f
update beforedev/buildCommands in manifest
amrbashir Aug 30, 2022
4be78f4
inscrease preact logo shadow
amrbashir Aug 30, 2022
1112701
add @types/node to preact-ts
amrbashir Aug 30, 2022
9c07acc
fmt
amrbashir Aug 30, 2022
cae0b35
changefile
amrbashir Aug 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Currently supported template presets include:
- `yew`
- `next`
- `next-ts`
- `preact`
- `preact-ts`

You can use `.` for the project name to scaffold in the current directory.

Expand Down
1 change: 1 addition & 0 deletions packages/cli/fragments/_assets_/preact.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
}
7 changes: 7 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Tauri + Preact + Typescript

This template should help get you started developing with Tauri, Preact and Typescript in Vite.

## Recommended IDE Setup

- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
13 changes: 13 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/_cta_manifest_
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT

devCommand = {{pkg_manager_run_command}} dev
buildCommand = {{pkg_manager_run_command}} build
devPath = http://localhost:1420
distDir = ../dist

[files]
preact.svg = src/assets/preact.svg
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
24 changes: 24 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Preact + TS</title>
extrordinaire marked this conversation as resolved.
Show resolved Hide resolved
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "{{package_name}}",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"tauri": "tauri"
},
"dependencies": {
"@tauri-apps/api": "^1.0.2",
"preact": "^10.10.1"
},
"devDependencies": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @types/node to devDependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is not resolved yet.

"@preact/preset-vite": "^2.3.0",
"@tauri-apps/cli": "^1.0.5",
"typescript": "^4.6.4",
"vite": "^3.0.7"
}
}
36 changes: 36 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/src/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

.logo {
height: 6em;
padding: 1.5em;
}
.logo:hover {
filter: drop-shadow(0 0 1em #646cffaa);
}

.logo.preact:hover {
filter: drop-shadow(0 0 1em #673ab8aa);
}
.logo.tauri:hover {
filter: drop-shadow(0 0 2em #fff41daa);
}

.card {
padding: 2em;
}

.read-the-docs {
color: #888;
}

.row {
display: flex;
flex-flow: row wrap;
justify-content: space-evenly;
align-items: center;
}
extrordinaire marked this conversation as resolved.
Show resolved Hide resolved
37 changes: 37 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/src/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { useState } from "preact/hooks";
import preactLogo from "./assets/preact.svg";
import "./app.css";

export function App() {
const [count, setCount] = useState(0);
extrordinaire marked this conversation as resolved.
Show resolved Hide resolved

return (
<>
<div>
extrordinaire marked this conversation as resolved.
Show resolved Hide resolved
<div className="row">
<a href="https://tauri.app" target="_blank">
<img src="/tauri.svg" className="logo tauri" alt="Tauri logo" />
</a>
<a href="https://vitejs.dev" target="_blank">
<img src="/vite.svg" className="logo" alt="Vite logo" />
</a>
<a href="https://preactjs.com" target="_blank">
<img src={preactLogo} className="logo preact" alt="Preact logo" />
</a>
</div>
</div>
<h1>Tauri + Vite + Preact</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/app.tsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Tauri, Vite and Preact logos to learn more
</p>
</>
);
}
70 changes: 70 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
:root {
extrordinaire marked this conversation as resolved.
Show resolved Hide resolved
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
5 changes: 5 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/src/main.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { render } from 'preact'
import { App } from './app'
import './index.css'

render(<App />, document.getElementById('app') as HTMLElement)
1 change: 1 addition & 0 deletions packages/cli/fragments/fragment-preact-ts/src/preact.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import JSX = preact.JSX
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
23 changes: 23 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": true,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
"jsxFactory": "h",
"jsxFragmentFactory": "Fragment"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
9 changes: 9 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
28 changes: 28 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { defineConfig } from 'vite'
import preact from '@preact/preset-vite'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [preact()],


// Vite optons tailored for Tauri development and only applied in `tauri dev` or `tauri build`
// prevent vite from obscuring rust errors
clearScreen: false,
// tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
},
// to make use of `TAURI_DEBUG` and other env variables
// https://tauri.studio/v1/api/config#buildconfig.beforedevcommand
envPrefix: ["VITE_", "TAURI_"],
build: {
// Tauri supports es2021
target: ["es2021", "chrome100", "safari13"],
// don't minify for debug builds
minify: !process.env.TAURI_DEBUG ? "esbuild" : false,
// produce sourcemaps for debug builds
sourcemap: !!process.env.TAURI_DEBUG,
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
}
7 changes: 7 additions & 0 deletions packages/cli/fragments/fragment-preact/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Tauri + Preact

This template should help get you started developing with Tauri and Preact in Vite.

## Recommended IDE Setup

- [VS Code](https://code.visualstudio.com/) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer)
13 changes: 13 additions & 0 deletions packages/cli/fragments/fragment-preact/_cta_manifest_
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2019-2022 Tauri Programme within The Commons Conservancy
# SPDX-License-Identifier: Apache-2.0
# SPDX-License-Identifier: MIT

devCommand = {{pkg_manager_run_command}} dev
buildCommand = {{pkg_manager_run_command}} build
devPath = http://localhost:1420
distDir = ../dist

[files]
preact.svg = src/assets/preact.svg
vite.svg = public/vite.svg
tauri.svg = public/tauri.svg
24 changes: 24 additions & 0 deletions packages/cli/fragments/fragment-preact/_gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions packages/cli/fragments/fragment-preact/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Preact</title>
extrordinaire marked this conversation as resolved.
Show resolved Hide resolved
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
Loading