Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
b-rad-c committed Jan 2, 2024
1 parent dbef077 commit e63d5ec
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
2 changes: 1 addition & 1 deletion addons/van_cone/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ _Author: [b-rad-c](https://github.com/b-rad-c)_

### An SPA framework add on for VanJS

🔥 **Van Cone plus VanJS can create a fully featured SPA app that minifies and gzips to less than 3.5 kB!** 🔥
🔥 **Van Cone plus VanJS can create a fully featured SPA app that minifies and gzips to 4.10 kB!** 🔥

This lightweight (less than 250 lines) VanJS addon adds the following features:
- Navigation powered by custom router with async loading
Expand Down
11 changes: 5 additions & 6 deletions addons/van_cone/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 16,9 @@
* 🟢 check for broken links in md files
* 🟢 remove handleNav from return and documentation
* 🟢 add navState to link props documentation
* 🟡 remove extra callable wrapper for .default imports on component functions
* 🟢 remove extra callable wrapper for .default imports on component functions
* 🟢 check .default and call it
* 🟡 update examples
* 🔴 update medium tech app
* 🔴 update documentation - include example for default and non default imports
* 🔴 check for broken links in md files
* 🔴 check bundled size and update readme
* 🟢 update examples
* 🟢 update documentation - include example for default and non default imports
* 🟢 check for broken links in md files
* 🟢 check bundled size and update readme
11 changes: 6 additions & 5 deletions addons/van_cone/docs/API_REFERENCE.md
Original file line number Diff line number Diff line change
@@ -1,4 1,4 @@
# Van Cone
# Van Cone | API Reference

See [README.md](../README.md) for installation and overview.

Expand Down Expand Up @@ -182,24 182,25 @@ if (isCurrentPage("home").val) console.log("we're home!")
```

## `link(props, ...children)`
A light wrapper around `van.tags.a` that add dynamic url generation for `routeName`, with url and query params to be used when generating the url with [`navUrl`](#navurlroutename-params---query), see below for more details. It adds dynamic styling when `routeName` is the active route. Additional context can be provided to the component resolved by the router. For example, `link` could be used on a search results page to link to each item's and could optionally pass the item's data to the item page enabling the it to use the preloaded data instead of fetching it.
A light wrapper around `van.tags.a` that adds dynamic url generation for `routeName`, with url and query params to be used when generating the url with [`navUrl`](#navurlroutename-params---query). It also adds dynamic styling when `routeName` is the active route. Additional context can be provided to the component resolved by the router. For example, `link` could be used on a search results page to navigate to each item's page and could pass the item's data enabling item page to use preloaded data instead of fetching it.


### arguments

The argument signature is the same as `van.tags.a` but additional properties are available to the `props` argument which configure how the link component works.

```javascript
link(props, ...children)
```

The argument signature is the same as `van.tags.a` but additional properties are available in the `props` argument which configure how the link component works.

`props` - an object that will be passed to the resulting `van.tags.a` function, unchanged with the following exceptions:

These are Van Cone props which are used for navigation and **will not** be passed to `van.tags.a`:
* `props.name` (required) - the name of the route to navigate to
* `props.params` (optional) - an object of url parameters defined by the route
* `props.query` (optional) - an object of query string parameters
* `props.context` (optional) - additional data to be passed to the component, see [component example](./COMPONENT_GUIDE.md#full-component-example) for more info.
* `props.navState` (optional) - optional data to set on `window.history.state`, see [`createCone`](#createconerouterelement-routes-defaultnavstate) for more
* `props.navState` (optional) - optional data to set on `window.history.state`, see [`createCone`](#createconerouterelement-routes-defaultnavstate) for more.

The following are standard `a` tag props but have the following default values:
* `props.target` (default: `_self`)
Expand Down
29 changes: 20 additions & 9 deletions addons/van_cone/docs/COMPONENT_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 7,11 @@ In this guide you will find:
* [component function definition](#function-signature)
* [a hello world example](#hello-world-with-router)
* [a url and query param example](#url--query-params-example)
* [a full component example with nav link component](#full-component-example)
* [a full component example with nav link component and context](#full-component-example)
* [an example using a backend endpoint which is different than the frontend](#different-backend-endpoint)
* [wildcard / 404 not found](#wildcard-not-found-page)
* [return component directly](#returning-the-routes-element-directly)
* [return a component via import](#returning-the-routes-element-via-import)
* [define the route's component via callable](#define-the-routes-component-via-callable)
* [define the route's component via import](#define-the-routes-component-via-import)

# Component functions

Expand Down Expand Up @@ -138,8 138,8 @@ const routes = [{
];
```

### returning the route's element directly
Simple return via callable
### define the route's component via callable
The simplest way to define a route's component.
```javascript
const homePage = () => div('Home Page')

Expand All @@ -151,8 151,8 @@ const routes = [{
}]
```

### returning the route's element via import
For more complex apps with many pages, the async import method may be more appropriate.
### define the route's component via import
A route's component can also be returned via import.

```javascript
// Define route
Expand All @@ -173,8 173,7 @@ const { section, div, br, h1, img } = van.tags

const homePage = () => {

return () =>
section(
return section(
h1("Welcome to this SPA demo using VanJS!"),
br(),
div(
Expand All @@ -187,3 186,15 @@ const homePage = () => {
export default homePage;

```

Note that you can also use a non-default export like this:

```javascript
const routes = [{
path: ".*",
name: "home",
title: "VanJS Example | Home",
callable: async () => import('./pageComponents').homePage
}
];
```
2 changes: 1 addition & 1 deletion addons/van_cone/examples/hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 4,4 @@

This shows a minimal application using routing and url params. Click on the user link and then try changing the user id in the browser's address bar.

Gzips and minifies to 2.75kB
Gzips and minifies to 3.47kB
2 changes: 1 addition & 1 deletion addons/van_cone/examples/spa-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 2,7 @@

[Live preview](https://codesandbox.io/p/devbox/github/vanjs-org/van/tree/main/addons/van_cone/examples/spa-app)

A Van Cone powered demo SPA, 3.43 kB bundled and gzipped!
A Van Cone powered demo SPA, 4.10 kB bundled and gzipped!

## Features

Expand Down

0 comments on commit e63d5ec

Please sign in to comment.