Skip to content

Commit fc43294

Browse files
authored
Merge branch 'master' into recipe-ui-add-style
2 parents 2101724 + 295fea9 commit fc43294

File tree

4 files changed

+87
-2
lines changed

4 files changed

+87
-2
lines changed

docs/v4-recipes/ui/add-feliz.md renamed to docs/recipes/ui/add-feliz.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[Feliz](https://github.com/Zaid-Ajaj/Feliz) is a wrapper for the base [React](https://reactjs.org/) DSL library that emphasises consistency, lightweight formatting, discoverable attributes and full type-safety. The default SAFE Template already uses Feliz.
33

44
### Using Feliz
5-
1. [Add Feliz to your project](./../package-management/add-nuget-package-to-client.md)
5+
1. [Add Feliz to your project](./../../v4-recipes//package-management/add-nuget-package-to-client.md)
66
1. Start using Feliz in your code.
77

88
```fsharp

docs/recipes/ui/add-tailwind.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# How do I add Tailwind to a SAFE project?
2+
3+
[Tailwind](https://tailwindcss.com/) is a utility-first CSS framework which can be composed to build any design, directly in your markup.
4+
5+
As of SAFE version 5 (released in December 2023) it is included in the template by default so it can be used straight away.
6+
7+
If you are are using the minimal template or if you are upgrading from an old version of SAFE, continue reading for installation instructions.
8+
9+
1. [Add a stylesheet](https://safe-stack.github.io/docs/recipes/ui/add-style/) to the project
10+
11+
1. Install the required npm packages
12+
```shell
13+
npm install -D tailwindcss postcss autoprefixer
14+
```
15+
1. Initialise a `tailwind.config.js`
16+
```shell
17+
npx tailwindcss init
18+
```
19+
1. Amend the `tailwind.config.js` as follows
20+
```javascript
21+
/** @type {import('tailwindcss').Config} */
22+
module.exports = {
23+
mode: "jit",
24+
content: [
25+
"./index.html",
26+
"./**/*.{fs,js,ts,jsx,tsx}",
27+
],
28+
theme: {
29+
extend: {},
30+
},
31+
plugins: [],
32+
}
33+
```
34+
35+
1. Create a `postcss.config.js` with the following
36+
```javascript
37+
module.exports = {
38+
plugins: {
39+
tailwindcss: {},
40+
autoprefixer: {},
41+
}
42+
}
43+
```
44+
45+
1. Add the Tailwind layers to your stylesheet
46+
```css
47+
@tailwind base;
48+
@tailwind components;
49+
@tailwind utilities;
50+
```
51+
52+
1. In the `src/Client` folder find the code in `Index.fs` to show the list of todos and add a Tailwind text colour class(text-red-200)
53+
```fsharp
54+
for todo in model.Todos do
55+
Html.li [
56+
prop.classes [ "text-red-200" ]
57+
prop.text todo.Description
58+
]
59+
```
60+
61+
You should see some nice red "to-do"s proving that Tailwind is now in your project.

docs/recipes/ui/cdn-to-npm.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# How do I migrate from a CDN stylesheet to an NPM package?
2+
Often, referencing a stylesheet from a CDN is all that's needed to add new styles but you can use an NPM package instead.
3+
---
4+
5+
#### 1. Remove the CDN Reference
6+
Remove the CDN reference from the index template in `src/Client/index.html`:
7+
```html
8+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
9+
```
10+
11+
#### 2. Add the NPM Package
12+
Add styles from NPM. [How do I add an NPM package to the client?](../../package-management/add-npm-package-to-client)
13+
In this example we will add the [Bulma NPM package](https://www.npmjs.com/package/bulma).
14+
15+
#### 3. Add a reference to your stylesheet
16+
1. Add a stylesheet to your project using [this recipe](../add-style). Add a scss file instead of a css file.
17+
1. Add the following lines to your scss file:
18+
```scss
19+
// Set variables to affect Bulma styles
20+
$body-color: #c6538c;
21+
@import 'bulma/bulma.sass';
22+
```

mkdocs.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ nav:
7373
- Remove FAKE: "recipes/build/remove-fake.md"
7474
- Package my SAFE app for deployment: "recipes/build/bundle-app.md"
7575
- UI:
76+
- Add Tailwind support: "recipes/ui/add-tailwind.md"
7677
- Add daisyUI support: "recipes/ui/add-daisyui.md"
7778
- Add Stylesheet support: "recipes/ui/add-style.md"
79+
- Add Feliz support: "recipes/ui/add-feliz.md"
7880
- Add FontAwesome support: "recipes/ui/add-fontawesome.md"
81+
- Migrate from a CDN stylesheet to an NPM package: "recipes/ui/cdn-to-npm.md"
7982
- Storage:
8083
- Quickly add a database: "recipes/storage/use-litedb.md"
8184
- JavaScript:
@@ -139,7 +142,6 @@ nav:
139142
- Remove Bulma: "v4-recipes/ui/remove-bulma.md"
140143
- Add Tailwind support: "v4-recipes/ui/add-tailwind.md"
141144
- Add daisyUI support: "v4-recipes/ui/add-daisyui.md"
142-
- Add Feliz support: "v4-recipes/ui/add-feliz.md"
143145
- Migrate from a CDN stylesheet to an NPM package: "v4-recipes/ui/cdn-to-npm.md"
144146
- Add routing with state shared between pages: "v4-recipes/ui/add-routing.md"
145147
- Add routing with separate models per page: "v4-recipes/ui/add-routing-with-separate-models.md"

0 commit comments

Comments
 (0)