Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
/target
examples/*/target
examples/*/dist
examples/*/Cargo.lock
31 changes: 31 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Code of Conduct

## Our Pledge

We are committed to providing a friendly, safe, and welcoming environment for all contributors.

## Our Standards

**Expected behavior:**

- Be respectful and inclusive
- Accept constructive criticism gracefully
- Focus on what is best for the community
- Show empathy towards others

**Unacceptable behavior:**

- Harassment, trolling, or personal attacks
- Discriminatory language or imagery
- Publishing others' private information
- Other conduct inappropriate in a professional setting

## Enforcement

Project maintainers may remove, edit, or reject comments, commits, code, issues, and other contributions that violate this Code of Conduct.

Instances of unacceptable behavior may be reported by opening an issue or contacting the maintainers directly.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org/), version 2.1.
56 changes: 56 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Contributing

Thanks for your interest in contributing to `yew-nav-link`!

## Quick Start

1. Fork and clone the repo
2. Create a branch from an issue: `git checkout -b 123-feature-name`
3. Make changes following our standards
4. Submit a PR

## Standards

This project follows [RustManifest](https://github.com/RAprogramm/RustManifest) guidelines:

### Code Style

- Format with `cargo +nightly fmt`
- Max 99 characters per line
- No `mod.rs` files
- Use `::` only in imports

### Quality

- No `unwrap()` or `expect()` in library code
- Avoid unnecessary `clone()`
- Prefer `&str` over `String`, `&[T]` over `Vec<T>`

### Documentation

- Doc comments (`///`) on all public items
- Include examples in doc comments

### Commits

Format: `#issue type: description`

```
#42 feat: add custom class support
#15 fix: active state detection
#8 docs: update usage examples
```

Types: `feat`, `fix`, `docs`, `refactor`, `test`, `chore`

## Before PR

```bash
cargo +nightly fmt
cargo clippy -- -D warnings
cargo test
```

## Questions?

Open an issue or check [RustManifest](https://github.com/RAprogramm/RustManifest) for detailed guidelines.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ repository = "https://github.com/RAprogramm/yew-nav-link"
license = "MIT"
keywords = ["yew", "router", "navigation", "wasm", "frontend"]
categories = ["gui", "wasm", "web-programming"]
exclude = ["examples/*"]

[dependencies]
yew = { version = "0.22", features = ["csr"] }
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Navigation link component for [Yew](https://yew.rs) with automatic active state
- [Overview](#overview)
- [Installation](#installation)
- [Requirements](#requirements)
- [Examples](#examples)
- [Usage](#usage)
- [Component Syntax](#component-syntax)
- [Function Syntax](#function-syntax)
Expand Down Expand Up @@ -55,6 +56,33 @@ yew-nav-link = "0.3"

<div align="right"><a href="#top">↑ top</a></div>

## Examples

Full working examples are available in the [examples/](https://github.com/RAprogramm/yew-nav-link/tree/main/examples) directory:

| Example | Description |
|---------|-------------|
| [basic](https://github.com/RAprogramm/yew-nav-link/tree/main/examples/basic) | Simple navigation with Home, About, Contact pages |
| [bootstrap](https://github.com/RAprogramm/yew-nav-link/tree/main/examples/bootstrap) | Integration with Bootstrap 5 navbar |
| [tailwind](https://github.com/RAprogramm/yew-nav-link/tree/main/examples/tailwind) | Sidebar navigation styled with Tailwind CSS |
| [nested-routes](https://github.com/RAprogramm/yew-nav-link/tree/main/examples/nested-routes) | Multi-level navigation with nested routing |

### Running Examples

```bash
# Install prerequisites (once)
rustup target add wasm32-unknown-unknown
cargo install trunk

# Run example
cd examples/basic
trunk serve
```

Open http://127.0.0.1:8080 in your browser.

<div align="right"><a href="#top">↑ top</a></div>

## Usage

### Component Syntax
Expand Down
38 changes: 38 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Security Policy

## Supported Versions

| Version | Supported |
|---------|--------------------|
| 0.3.x | :white_check_mark: |
| < 0.3 | :x: |

## Reporting a Vulnerability

**Do not open a public issue for security vulnerabilities.**

Instead:

1. Email: andrey.rozanov.vl@gmail.com
2. Or use [GitHub Security Advisories](https://github.com/RAprogramm/yew-nav-link/security/advisories/new)

Include:

- Description of the vulnerability
- Steps to reproduce
- Potential impact
- Suggested fix (if any)

## Response Timeline

- **Acknowledgment**: within 48 hours
- **Initial assessment**: within 7 days
- **Fix timeline**: depends on severity

## Disclosure

We follow coordinated disclosure. We will work with you to understand and address the issue before any public disclosure.

## Scope

This policy applies to the `yew-nav-link` crate. For issues in dependencies, please report to the respective maintainers.
23 changes: 23 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Examples

## Quick Start

```bash
rustup target add wasm32-unknown-unknown
cargo install trunk

cd basic
trunk serve
# Open http://127.0.0.1:8080
```

## Examples

| Example | Description |
|---------|-------------|
| [basic](./basic) | Simple navigation with component and function syntax |
| [bootstrap](./bootstrap) | Bootstrap 5 navbar integration |
| [tailwind](./tailwind) | Sidebar with Tailwind CSS styling |
| [nested-routes](./nested-routes) | Multi-level navigation |

Each example has its own README with details.
10 changes: 10 additions & 0 deletions examples/basic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "basic-example"
version = "0.1.0"
edition = "2024"
publish = false

[dependencies]
yew = { version = "0.22", features = ["csr"] }
yew-router = "0.19"
yew-nav-link = { path = "../.." }
55 changes: 55 additions & 0 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Basic Example

Simple navigation demo with Home, About, Contact pages.

## What it demonstrates

- `NavLink<Route>` component syntax
- `nav_link()` function syntax
- Automatic `active` class on current route

## Run

```bash
# Prerequisites (once)
rustup target add wasm32-unknown-unknown
cargo install trunk

# Run
trunk serve
```

Open http://127.0.0.1:8080

## Project structure

```
basic/
├── Cargo.toml # Dependencies
├── index.html # HTML template with styles
└── src/
└── main.rs # App code
```

## Key code

```rust
use yew_nav_link::{NavLink, nav_link};

// Component syntax
<NavLink<Route> to={Route::Home}>{ "Home" }</NavLink<Route>>

// Function syntax
{ nav_link(Route::About, "About") }
```

## CSS

NavLink renders `<a class="nav-link">` (or `<a class="nav-link active">` when route matches).

Styles in `index.html`:

```css
.nav-link { color: #ecf0f1; }
.nav-link.active { background: #3498db; }
```
74 changes: 74 additions & 0 deletions examples/basic/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>yew-nav-link Example</title>
<link data-trunk rel="rust" data-wasm-opt="z" />
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
line-height: 1.6;
color: #333;
}

nav {
background: #2c3e50;
padding: 1rem 2rem;
}

nav ul {
list-style: none;
display: flex;
gap: 1rem;
}

.nav-link {
color: #ecf0f1;
text-decoration: none;
padding: 0.5rem 1rem;
border-radius: 4px;
transition: background 0.2s;
}

.nav-link:hover {
background: #34495e;
}

.nav-link.active {
background: #3498db;
font-weight: 600;
}

main {
max-width: 800px;
margin: 2rem auto;
padding: 0 1rem;
}

h1 {
color: #2c3e50;
margin-bottom: 1rem;
}

p {
margin-bottom: 1rem;
}

.card {
background: #f8f9fa;
border-radius: 8px;
padding: 1.5rem;
margin-top: 1rem;
}
</style>
</head>
<body>
</body>
</html>
Loading