Skip to content

Commit be782d2

Browse files
Merge branch 'main' into improve-session-docs
2 parents 83b8ff7 + 2c5de7f commit be782d2

14 files changed

Lines changed: 531 additions & 71 deletions

File tree

src/routes/guides/complex-state-management.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { For, createSignal, Show, createMemo } from "solid-js"
1313
const App = () => {
1414
const [tasks, setTasks] = createSignal([])
1515
const [numberOfTasks, setNumberOfTasks] = createSignal(tasks.length)
16-
const completedTasks = createMemo(() => tasks().filter((task) => task.completed))
16+
const completedTasks = createMemo(() => tasks().filter((task) => task.completed))
1717
let input
1818

1919
const addTask = (text) => {

src/routes/guides/routing-and-navigation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ This means you can initialize the page, or use [Data APIs](/solid-router/referen
493493

494494
<Callout>
495495
To prevent a fetch from happening more than once, or to trigger a refetch, you
496-
can use the [`cache` function](/solid-router/reference/data-apis/cache).
496+
can use the [`query` function](/solid-router/reference/data-apis/query).
497497
</Callout>
498498

499499
```jsx title="index.jsx"
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
title: TailwindCSS v3
3+
order: 7
4+
mainNavExclude: true
5+
---
6+
7+
[Tailwind CSS v3](https://v3.tailwindcss.com/) is an on-demand utility CSS library that integrates seamlessly with Solid as a built-in PostCSS plugin.
8+
9+
## Installation
10+
11+
1. Install Tailwind CSS as a development dependency:
12+
13+
<TabsCodeBlocks>
14+
<div id="npm">
15+
```bash frame="none"
16+
npm i --save-dev tailwindcss@3 postcss autoprefixer
17+
```
18+
</div>
19+
20+
<div id="yarn">
21+
```bash frame="none"
22+
yarn add --dev tailwindcss@3 postcss autoprefixer
23+
```
24+
</div>
25+
26+
<div id="pnpm">
27+
```bash frame="none"
28+
pnpm add --save-dev tailwindcss@3 postcss autoprefixer
29+
```
30+
</div>
31+
32+
<div id="bun">
33+
```bash frame="none"
34+
bun add --save-dev tailwindcss@3 postcss autoprefixer
35+
```
36+
</div>
37+
</TabsCodeBlocks>
38+
39+
2. Next, run the init command to generate both `tailwind.config.js` and `postcss.config.js`.
40+
41+
<TabsCodeBlocks>
42+
<div id="npm">
43+
```bash frame="none"
44+
npx tailwindcss init -p
45+
```
46+
</div>
47+
48+
<div id="yarn">
49+
```bash frame="none"
50+
yarn dlx tailwindcss init -p
51+
```
52+
</div>
53+
54+
<div id="pnpm">
55+
```bash frame="none"
56+
pnpm dlx tailwindcss init -p
57+
```
58+
</div>
59+
60+
<div id="bun">
61+
```bash frame="none"
62+
bunx tailwindcss init -p
63+
```
64+
</div>
65+
</TabsCodeBlocks>
66+
67+
3. Since TailwindCSS is configuration-driven, after initializing, a `tailwind.config.js` file will be created at the root of your project directory:
68+
69+
```js
70+
/** @type {import('tailwindcss').Config} */
71+
module.exports = {
72+
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
73+
theme: {
74+
extend: {},
75+
},
76+
plugins: [],
77+
};
78+
```
79+
80+
For a deeper dive into configuration, you can check out the [Tailwind Official Documentation](https://tailwindcss.com/docs/configuration).
81+
82+
## Add Tailwind directives
83+
84+
In your `src/index.css` file, add the following Tailwind directives:
85+
86+
```css
87+
@tailwind base;
88+
@tailwind components;
89+
@tailwind utilities;
90+
```
91+
92+
These directives inform PostCSS that you're using Tailwind and establish the order of the directives. You can append custom CSS below these directives.
93+
94+
## Import TailwindCSS
95+
96+
Import your `index.css` file into the root `index.jsx` or `index.tsx` file:
97+
98+
```jsx
99+
import { render } from "solid-js/web"
100+
import App from "./App"
101+
import "./index.css"
102+
103+
render(() => <App />, document.getElementById('root') as HTMLElement);
104+
```
105+
106+
## Usage
107+
108+
With Tailwind CSS set up, you can now utilize its utility classes.
109+
For instance, if you previously had a `Card.css` file, you can replace or remove it:
110+
111+
```
112+
/* src/components/Card.css */
113+
/* Remove or replace these styles with Tailwind utility classes */
114+
```
115+
116+
Update your components to use Tailwind's utility classes:
117+
118+
```jsx
119+
/* src/components/Card.jsx */
120+
function Card() {
121+
return (
122+
<div class="grid place-items-center min-h-screen">
123+
<div class="h-[160px] aspect aspect-[2] rounded-[16px] shadow-[0_0_0_4px_hsl(0_0%_0%_/_15%)]">
124+
Hello, world!
125+
</div>
126+
</div>
127+
);
128+
}
129+
```
130+
131+
## Support
132+
133+
For additional assistance, refer to the [Tailwind CSS/Vite integration guide](https://tailwindcss.com/docs/guides/vite).

src/routes/guides/styling-components/tailwind.mdx

Lines changed: 28 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,94 +4,71 @@ order: 5
44
mainNavExclude: true
55
---
66

7-
[Tailwind CSS](https://tailwindcss.com/) is an on-demand utility CSS library that integrates seamlessly with Solid as a built-in PostCSS plugin.
7+
<Callout type="info" title="Note">
8+
9+
This guide is for TailwindCSS v4. For **Tailwind CSS v3** refer to [TailwindCSS v3](/guides/styling-components/tailwind-v3).
10+
11+
</Callout>
12+
13+
[Tailwind CSS](https://tailwindcss.com/) is an on-demand utility CSS library that integrates seamlessly with Solid as a built-in PostCSS plugin.
814

915
## Installation
1016

1117
1. Install Tailwind CSS as a development dependency:
1218

1319
<TabsCodeBlocks>
1420
<div id="npm">
15-
```bash frame="none"
16-
npm i --save-dev tailwindcss postcss autoprefixer
17-
```
18-
</div>
1921

20-
<div id="yarn">
2122
```bash frame="none"
22-
yarn add --dev tailwindcss postcss autoprefixer
23+
npm i --save-dev tailwindcss @tailwindcss/postcss postcss
2324
```
24-
</div>
2525

26-
<div id="pnpm">
27-
```bash frame="none"
28-
pnpm add --save-dev tailwindcss postcss autoprefixer
29-
```
3026
</div>
27+
<div id="yarn">
3128

32-
<div id="bun">
3329
```bash frame="none"
34-
bun add --save-dev tailwindcss postcss autoprefixer
30+
yarn add --dev tailwindcss @tailwindcss/postcss postcss
3531
```
36-
</div>
37-
</TabsCodeBlocks>
3832

39-
2. Next, run the init command to generate both `tailwind.config.js` and `postcss.config.js`.
40-
41-
<TabsCodeBlocks>
42-
<div id="npm">
43-
```bash frame="none"
44-
npx tailwindcss init -p
45-
```
4633
</div>
34+
<div id="pnpm">
4735

48-
<div id="yarn">
4936
```bash frame="none"
50-
yarn dlx tailwindcss init -p
37+
pnpm add --save-dev tailwindcss @tailwindcss/postcss postcss
5138
```
52-
</div>
5339

54-
<div id="pnpm">
55-
```bash frame="none"
56-
pnpm dlx tailwindcss init -p
57-
```
5840
</div>
59-
6041
<div id="bun">
42+
6143
```bash frame="none"
62-
bunx tailwindcss init -p
44+
bun add --save-dev tailwindcss @tailwindcss/postcss postcss
6345
```
46+
6447
</div>
6548
</TabsCodeBlocks>
6649

67-
3. Since TailwindCSS is configuration-driven, after initializing, a `tailwind.config.js` file will be created at the root of your project directory:
68-
69-
```js
70-
/** @type {import('tailwindcss').Config} */
71-
module.exports = {
72-
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
73-
theme: {
74-
extend: {},
75-
},
76-
plugins: [],
77-
};
50+
2. Add `@tailwind/postcss` to the `plugins` in your PostCSS configuration. If you do not have a PostCSS configuration file, create a new one called `postcss.config.mjs`.
51+
52+
```js title="postcss.config.mjs"
53+
export default {
54+
plugins: {
55+
"@tailwindcss/postcss": {},
56+
}
57+
}
7858
```
7959

8060
For a deeper dive into configuration, you can check out the [Tailwind Official Documentation](https://tailwindcss.com/docs/configuration).
8161

82-
## Add Tailwind directives
62+
## Import TailwindCSS
8363

84-
In your `src/index.css` file, add the following Tailwind directives:
64+
Add an `@import` to your `src/index.css` file that imports Tailwind CSS.
8565

86-
```css
87-
@tailwind base;
88-
@tailwind components;
89-
@tailwind utilities;
66+
```css title="src/index.css"
67+
@import "tailwindcss";
9068
```
9169

92-
These directives inform PostCSS that you're using Tailwind and establish the order of the directives. You can append custom CSS below these directives.
9370

94-
## Import TailwindCSS
71+
## Import your CSS file
9572

9673
Import your `index.css` file into the root `index.jsx` or `index.tsx` file:
9774

src/routes/solid-router/getting-started/config.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
title: "Config-based routing"
33
---
44

5-
Solid Router allows for configuration-based routing, where JSX is not needed to set up routes.
5+
Solid Router supports config-based routing, which offers the same capabilities as [component routing](/solid-router/getting-started/component).
6+
The decision to use config-based routing over component routing depends largely on personal preference.
67

78
To define a single route, a route definition object can be passed to the [`<Router>`](/solid-router/reference/components/router) component:
89

src/routes/solid-router/reference/components/a.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
title: A
33
---
44

5-
Solid Router exposes an `<A />` component as a wrapper around the native [`<a />`](https://mdn.io/a) tag.
5+
Solid Router exposes the `<A />` component as a wrapper around the [native anchor tag ](https://mdn.io/a).
6+
It relies on the routing context provided by the [`<Router>` component](/solid-router/reference/components/router) and if used outside, will triggers a runtime error..
67

78
`<A />` supports relative and base paths. `<a />` doesn't. But `<a />` gets augmented
89
when JS is present via a top-level listener to the DOM, so you get the

src/routes/solid-router/reference/data-apis/create-async.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ An asynchronous primitive with a function that tracks similar to `createMemo`.
77
Reading it before it is ready causes Suspense/Transitions to trigger.
88

99
<Callout type="caution">
10-
Using `cache` in `createResource` directly will not work since the fetcher is
10+
Using `query` in `createResource` directly will not work since the fetcher is
1111
not reactive. This means that it will not invalidate properly.
1212
</Callout>
1313

@@ -17,7 +17,7 @@ It is recommended that `createAsync` be used in favor of `createResource` specia
1717

1818

1919
```tsx title="component.tsx" {6,10}
20-
import { createAsync } from "solid/router";
20+
import { createAsync } from "@solidjs/router";
2121
import { Suspense } from "solid-js";
2222
import { getUser } from "./api";
2323

src/routes/solid-router/reference/data-apis/query.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ For instance, both `{ name: 'Ryan', awesome: true }` and `{ awesome: true, name:
8585

8686
## Return value
8787

88-
The return value is a `CachedFunction`, a function that has the same signature as the function you passed to `cache`.
88+
The return value is a `CachedFunction`, a function that has the same signature as the function you passed to `query`.
8989
This cached function stores the return value using the cache key.
9090
Under most circumstances, this temporarily prevents the passed function from running with the same arguments, even if the created function is called repeatedly.
9191

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
title: useResolvedPath
3+
---
4+
5+
`useResolvedPath` retrieves a signal\<string\>.
6+
It contains the current resolved path as defined in the Route.
7+
8+
```js
9+
const path = useResolvedPath(() => '');
10+
11+
// Parent Route path: /user/*
12+
console.log(path()); // /user
13+
14+
const path = useResolvedPath(() => 'a/b/c');
15+
16+
// Parent Route path: /user/*
17+
console.log(path()); // /user/a/b/c
18+
19+
const path = useResolvedPath(() => '/a/b/c'); // Note: /
20+
21+
// Parent Route path: /user/*
22+
console.log(path()); // a/b/c
23+
```
24+
25+
Useful for making modular routers
26+
27+
```js
28+
const parentRoutePath = useResolvedPath(() => '');
29+
30+
return <>
31+
<h1>Module component layer</h1>
32+
<Router base={parentRoutePath()}> // Modular magic
33+
<Route path="/" component={() => <div>Index</div>}/>
34+
<Route path="/a" component={() => <div>AComponent</div>}/>
35+
</Router>
36+
</>
37+
```

0 commit comments

Comments
 (0)