Skip to content

Commit 82f03b3

Browse files
committed
feat: first commit!
0 parents  commit 82f03b3

29 files changed

+2502
-0
lines changed

.gitignore

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
/target/
4+
5+
/dist/
6+
7+
8+
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
9+
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
10+
Cargo.lock
11+
12+
# These are backup files generated by rustfmt
13+
**/*.rs.bk
14+
15+
# Support playwright testing
16+
node_modules/
17+
test-results/
18+
end2end/playwright-report/
19+
playwright/.cache/
20+
pnpm-lock.yaml

Cargo.toml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "rust_lang_es"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
leptos = { version = "0.4.8", features = ["csr", "nightly"] }
8+
leptos_meta = { version = "0.4.8", features = ["csr", "nightly"] }
9+
leptos_router = { version = "0.4.8", features = ["csr", "nightly"] }
10+
log = "0.4"
11+
gloo-net = { version = "0.2", features = ["http"] }
12+
13+
14+
# dependecies for client (enable when csr or hydrate set)
15+
wasm-bindgen = { version = "0.2" }
16+
console_log = { version = "1"}
17+
console_error_panic_hook = { version = "0.1"}
18+

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 henrik
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extend = [{ path = "../cargo-make/main.toml" }]

README.md

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Leptos Starter Template
2+
3+
This is a template demonstrating how to integrate [TailwindCSS](https://tailwindcss.com/) with the [Leptos](https://github.com/leptos-rs/leptos) web framework and the [trunk](https://github.com/thedodd/trunk) tool.
4+
5+
6+
Install Tailwind and build the CSS:
7+
8+
`Trunk.toml` is configured to build the CSS automatically.
9+
10+
Install trunk to client side render this bundle.
11+
12+
`cargo install trunk`
13+
Then the site can be served with `trunk serve --open`
14+
15+
The browser will automatically open [http://127.0.0.1:8080//](http://127.0.0.1:8080//)
16+
17+
You can begin editing your app at `src/app.rs`.
18+
19+
## Installing Tailwind
20+
21+
You can install Tailwind using `npm`:
22+
23+
```bash
24+
npm install -D tailwindcss
25+
```
26+
27+
If you'd rather not use `npm`, you can install the Tailwind binary [here](https://github.com/tailwindlabs/tailwindcss/releases).
28+
29+
## Setting up with VS Code and Additional Tools
30+
31+
If you're using VS Code, add the following to your `settings.json`
32+
33+
```json
34+
"emmet.includeLanguages": {
35+
"rust": "html",
36+
"*.rs": "html"
37+
},
38+
"tailwindCSS.includeLanguages": {
39+
"rust": "html",
40+
"*.rs": "html"
41+
},
42+
"files.associations": {
43+
"*.rs": "rust"
44+
},
45+
"editor.quickSuggestions": {
46+
"other": "on",
47+
"comments": "on",
48+
"strings": true
49+
},
50+
"css.validate": false,
51+
```
52+
53+
Install [Tailwind CSS Intellisense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss).
54+
55+
Install [VS Browser](https://marketplace.visualstudio.com/items?itemName=Phu1237.vs-browser) extension (allows you to open a browser at the right window.
56+
57+
Allow vscode Ports forward: 3000, 3001.
58+
59+
## Notes about Tooling
60+
61+
By default, `cargo-leptos` uses `nightly` Rust, `cargo-generate`, and `sass`. If you run into any trouble, you may need to install one or more of these tools.
62+
63+
1. `rustup toolchain install nightly --allow-downgrade` - make sure you have Rust nightly
64+
2. `rustup default nightly` - setup nightly as default, or you can use rust-toolchain file later on
65+
3. `rustup target add wasm32-unknown-unknown` - add the ability to compile Rust to WebAssembly
66+
4. `cargo install cargo-generate` - install `cargo-generate` binary (should be installed automatically in future)
67+
5. `npm install -g sass` - install `dart-sass` (should be optional in future
68+
69+
70+
## Attribution
71+
This is based on the original Tailwind example (../examples/tailwind)

Trunk.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[[hooks]]
2+
stage = "pre_build"
3+
command = "sh"
4+
command_arguments = ["-c", "npx tailwindcss -i input.css -o style/output.css"]

end2end/package-lock.json

+74
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

end2end/package.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "end2end",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {},
7+
"keywords": [],
8+
"author": "",
9+
"license": "ISC",
10+
"devDependencies": {
11+
"@playwright/test": "^1.28.0"
12+
}
13+
}

end2end/playwright.config.ts

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import type { PlaywrightTestConfig } from "@playwright/test";
2+
import { devices } from "@playwright/test";
3+
4+
/**
5+
* Read environment variables from file.
6+
* https://github.com/motdotla/dotenv
7+
*/
8+
// require('dotenv').config();
9+
10+
/**
11+
* See https://playwright.dev/docs/test-configuration.
12+
*/
13+
const config: PlaywrightTestConfig = {
14+
testDir: "./tests",
15+
/* Maximum time one test can run for. */
16+
timeout: 30 * 1000,
17+
expect: {
18+
/**
19+
* Maximum time expect() should wait for the condition to be met.
20+
* For example in `await expect(locator).toHaveText();`
21+
*/
22+
timeout: 5000,
23+
},
24+
/* Run tests in files in parallel */
25+
fullyParallel: true,
26+
/* Fail the build on CI if you accidentally left test.only in the source code. */
27+
forbidOnly: !!process.env.CI,
28+
/* Retry on CI only */
29+
retries: process.env.CI ? 2 : 0,
30+
/* Opt out of parallel tests on CI. */
31+
workers: process.env.CI ? 1 : undefined,
32+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
33+
reporter: "html",
34+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
35+
use: {
36+
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
37+
actionTimeout: 0,
38+
/* Base URL to use in actions like `await page.goto('/')`. */
39+
// baseURL: 'http://localhost:3000',
40+
41+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
42+
trace: "on-first-retry",
43+
},
44+
45+
/* Configure projects for major browsers */
46+
projects: [
47+
{
48+
name: "chromium",
49+
use: {
50+
...devices["Desktop Chrome"],
51+
},
52+
},
53+
54+
{
55+
name: "firefox",
56+
use: {
57+
...devices["Desktop Firefox"],
58+
},
59+
},
60+
61+
{
62+
name: "webkit",
63+
use: {
64+
...devices["Desktop Safari"],
65+
},
66+
},
67+
68+
/* Test against mobile viewports. */
69+
// {
70+
// name: 'Mobile Chrome',
71+
// use: {
72+
// ...devices['Pixel 5'],
73+
// },
74+
// },
75+
// {
76+
// name: 'Mobile Safari',
77+
// use: {
78+
// ...devices['iPhone 12'],
79+
// },
80+
// },
81+
82+
/* Test against branded browsers. */
83+
// {
84+
// name: 'Microsoft Edge',
85+
// use: {
86+
// channel: 'msedge',
87+
// },
88+
// },
89+
// {
90+
// name: 'Google Chrome',
91+
// use: {
92+
// channel: 'chrome',
93+
// },
94+
// },
95+
],
96+
97+
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
98+
// outputDir: 'test-results/',
99+
100+
/* Run your local dev server before starting the tests */
101+
// webServer: {
102+
// command: 'npm run start',
103+
// port: 3000,
104+
// },
105+
};
106+
107+
export default config;

end2end/tests/example.spec.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test("homepage has title and links to intro page", async ({ page }) => {
4+
await page.goto("http://localhost:8080/");
5+
6+
await expect(page).toHaveTitle("Leptos • Counter with Tailwind");
7+
8+
await expect(page.locator("h2")).toHaveText("Welcome to Leptos with Tailwind");
9+
});

index.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="es">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<link data-trunk rel="rust" data-wasm-opt="z" />
7+
<link data-trunk rel="icon" type="image/ico" href="/public/favicon.ico" />
8+
<link data-trunk rel="copy-file" type="image/png" href="/public/RustLogo.png" />
9+
<link data-trunk rel="copy-file" type="image/png" href="/public/Enojado.png" />
10+
<link data-trunk rel="copy-file" type="image/png" href="/public/rhq3ezvso9611.png" />
11+
<link data-trunk rel="css" href="/style/output.css" />
12+
<title>Rust Lang en Español</title>
13+
</head>
14+
15+
<body class="dark:bg-slate-700 dark:text-white"></body>
16+
17+
</html>

0 commit comments

Comments
 (0)