-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Melange and native instructions (#465)
- Loading branch information
Showing
13 changed files
with
255 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"rescript": "ReScript", | ||
"editor-support": "Editor Support" | ||
"melange": "Melange", | ||
"native": "Native" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
title: Getting Started - Melange | ||
showAllLanguage: false | ||
--- | ||
|
||
import { Callout } from "nextra/components"; | ||
import Link from "next/link"; | ||
|
||
# Melange | ||
|
||
Ensure that you have set up a Melange project beforehand. If you haven't done so yet, refer to the Melange getting started [documentation](https://melange.re/v3.0.0/getting-started.html). | ||
|
||
This guide assumes that you'll use opam and dune. | ||
|
||
### Install | ||
|
||
```bash | ||
opam install styled-ppx | ||
``` | ||
|
||
### Packages available | ||
|
||
- `styled-ppx` is the ppx | ||
- `styled-ppx.css` are the CSS bindings | ||
- `styled-ppx.emotion` are the `emotion.sh` bindings | ||
|
||
### Usage | ||
|
||
Add `styled-ppx` under dune's preprocess pps for library with `(modes melange)` or `melange.emit`. Add `styled-ppx.css` and `styled-ppx.emotion` as libraries. | ||
|
||
```diff | ||
(library | ||
(name ...) | ||
(modes melange) | ||
(libraries | ||
+ styled-ppx.css | ||
+ styled-ppx.emotion | ||
reason-react) | ||
(preprocess | ||
(pps | ||
+ styled-ppx | ||
melange.ppx | ||
reason-react-ppx))) | ||
``` | ||
|
||
```diff | ||
(melange.emit | ||
(libraries | ||
+ styled-ppx.css | ||
+ styled-ppx.emotion | ||
reason-react) | ||
(preprocess | ||
(pps | ||
+ styled-ppx | ||
melange.ppx | ||
reason-react-ppx))) | ||
``` | ||
|
||
Note: `reason-react` and `reason-react-ppx` are optional, and only needed if you use styled components (`[%styled.div {||}]`). | ||
|
||
### Example | ||
|
||
```reason | ||
/* This is a ReasonReact module with those styles encoded as a unique className */ | ||
module Link = [%styled.a (~color=CssJs.hex("4299E1")) => {| | ||
font-size: 1.875rem; | ||
line-height: 1.5; | ||
text-decoration: none; | ||
margin: 0px; | ||
padding: 10px 0px; | ||
color: $(color); | ||
|}]; | ||
/* This is a unique className pointing to those styles */ | ||
let layout = [%cx {| | ||
display: flex; | ||
width: 100%; | ||
height: 100%; | ||
justify-content: center; | ||
align-items: center | ||
|}]; | ||
/* Later in a component */ | ||
<div className=layout> | ||
<Link | ||
color={CssJs.hex("333333")} | ||
href="https://sancho.dev" | ||
rel="noopener noreferrer"> | ||
{React.string("sancho.dev")} | ||
</Link> | ||
</div>; | ||
``` |
80 changes: 0 additions & 80 deletions
80
packages/website/site/pages/getting-started/melange.mdx.bak
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
--- | ||
title: Getting Started - Native | ||
showAllLanguage: false | ||
--- | ||
|
||
import { Callout } from "nextra/components"; | ||
import Link from "next/link"; | ||
|
||
# Native | ||
|
||
This guide assumes that you'll use opam and dune. | ||
|
||
### Install | ||
|
||
```bash | ||
opam install styled-ppx | ||
``` | ||
|
||
### Packages available | ||
|
||
- `styled-ppx` is the ppx | ||
- `styled-ppx.css_native` are the CSS bindings | ||
- `styled-ppx.emotion_native` is a native implementaiton of `emotion.sh` capable of storing CSS, hashing it and generating a unique className, autoprefixing, etc. | ||
|
||
### Usage | ||
|
||
Add `styled-ppx` under dune's preprocess pps for any library or executable. Add `styled-ppx.css_native` and `styled-ppx.emotion_emotion` as libraries. | ||
|
||
```diff | ||
(library | ||
(name ...) | ||
(libraries | ||
+ styled-ppx.css | ||
+ styled-ppx.emotion | ||
server-reason-react) | ||
(preprocess | ||
(pps | ||
+ styled-ppx | ||
melange.ppx | ||
server-reason-react-ppx))) | ||
``` | ||
|
||
```diff | ||
(melange.emit | ||
(target ...) | ||
(libraries | ||
+ styled-ppx.css | ||
+ styled-ppx.emotion | ||
server-reason-react) | ||
(preprocess | ||
(pps | ||
+ styled-ppx | ||
melange.ppx | ||
server-reason-react-ppx))) | ||
``` | ||
|
||
Note: `server-reason-react` and `server-reason-react-ppx` are optional, and only needed if you use styled components (`[%styled.div {||}]`). | ||
|
||
### Example | ||
|
||
```reason | ||
/* This is a server-reason-react module with those styles encoded as a unique className */ | ||
module Link = [%styled.a (~color=CssJs.hex("4299E1")) => {| | ||
font-size: 1.875rem; | ||
line-height: 1.5; | ||
text-decoration: none; | ||
margin: 0px; | ||
padding: 10px 0px; | ||
color: $(color); | ||
|}]; | ||
/* This is a unique className pointing to those styles */ | ||
let layout = [%cx {| | ||
display: flex; | ||
width: 100%; | ||
height: 100%; | ||
justify-content: center; | ||
align-items: center | ||
|}]; | ||
/* Later in a component */ | ||
let app = | ||
<div className=layout> | ||
<Link | ||
color={CssJs.hex("333333")} | ||
href="https://sancho.dev" | ||
rel="noopener noreferrer"> | ||
{React.string("sancho.dev")} | ||
</Link> | ||
</div>; | ||
let stylesheet = CssJs.render_style_tag(); /* This will render the stylesheet to be present in the head of the document */ | ||
``` |
Oops, something went wrong.