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 15 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
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ A template is a just combination of two fragments, [`fragment-base`](../packages
- Add a directory in `<repo-root>/packages/cli/fragments` and name `fragment-template` where `template` is the name of the template and add all the files you need there as they should appear after the template is created.
- In `<repo-root>/packages/cli/src/template.rs`, add an entry in the `Template` enum, modify `post_init_info` if needed and modify `FromStr` and `Display` implementation
- In `<repo-root>/packages/cli/src/package_manager.rs` add your new template to the appropraite package manager in the `templates` method
- Modify `<repo-root>/.scripts/generate-templates-matrix.js` and append the template name inside the template list for the appropriate package manager so the CI would run tests for it.

## Financial Contribution

Expand Down
2 changes: 2 additions & 0 deletions .scripts/generate-templates-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const nodeJsTemplates = [
"vanilla",
"next",
"next-ts",
"preact",
"preact-ts",
];

const matrix = [
Expand Down
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.
5 changes: 1 addition & 4 deletions packages/cli/fragments/fragment-next-ts/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ function App() {
</span>
</div>

<p>
Click on the Tauri, Next, and React logos to learn more about each
framework.
</p>
<p>Click on the Tauri, Next, and React logos to learn more.</p>

<div className="row">
<div>
Expand Down
5 changes: 1 addition & 4 deletions packages/cli/fragments/fragment-next/src/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,7 @@ function App() {
</span>
</div>

<p>
Click on the Tauri, Next, and React logos to learn more about each
framework.
</p>
<p>Click on the Tauri, Next, and React logos to learn more.</p>

<div className="row">
<div>
Expand Down
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>Tauri + Preact + TS App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions packages/cli/fragments/fragment-preact-ts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"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.

"@babel/core": "^7.12.10",
"@preact/preset-vite": "^2.3.0",
"@tauri-apps/cli": "^1.0.5",
"typescript": "^4.6.4",
"vite": "^3.0.7"
}
}
7 changes: 7 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,7 @@
.logo.vite:hover {
filter: drop-shadow(0 0 2em #747bff);
}

.logo.preact:hover {
filter: drop-shadow(0 0 1em #673ab8aa);
}
46 changes: 46 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,46 @@
import { useState } from "preact/hooks";
import preactLogo from "./assets/preact.svg";
import { invoke } from "@tauri-apps/api/tauri";
import "./app.css";

export function App<FC>() {
const [greetMsg, setGreetMsg] = useState<string>("");
const [name, setName] = useState<string>("");

const greet = async () => {
setGreetMsg(await invoke("greet", { name }));
};

return (
<div class="container">
<h1>Welcome to Tauri!</h1>
<div class="row">
<a href="https://vitejs.dev" target="_blank">
<img src="/vite.svg" class="logo vite" alt="Vite logo" />
</a>
<a href="https://tauri.app" target="_blank">
<img src="/tauri.svg" class="logo tauri" alt="Tauri logo" />
</a>
<a href="https://preactjs.com" target="_blank">
<img src={preactLogo} class="logo preact" alt="Preact logo" />
</a>
</div>

<p>Click on the Tauri, Vite, and Preact logos to learn more.</p>

<div className="row">
<div>
<input
id="greet-input"
onChange={(e) => setName(e.currentTarget.value)}
placeholder="Enter a name..."
/>
<button type="button" onClick={() => greet()}>
Greet
</button>
</div>
</div>
<p>{greetMsg}</p>
</div>
);
}
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 "./style.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"]
}
27 changes: 27 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,27 @@
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>Tauri + Preact App</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
22 changes: 22 additions & 0 deletions packages/cli/fragments/fragment-preact/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": "vite build",
"preview": "vite preview",
"tauri": "tauri"
},
"dependencies": {
"@tauri-apps/api": "^1.0.2",
"preact": "^10.10.1"
},
"devDependencies": {
"@babel/core": "^7.12.10",
"@preact/preset-vite": "^2.3.0",
"@tauri-apps/cli": "^1.0.5",
"vite": "^3.0.7"
}
}
6 changes: 6 additions & 0 deletions packages/cli/fragments/fragment-preact/src/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.logo.vite:hover {
filter: drop-shadow(0 0 2em #747bff);
}
.logo.preact:hover {
filter: drop-shadow(0 0 1em #673ab8aa);
}
Loading