-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
280 additions
and
117 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,6 +1,6 @@ | ||
--- | ||
layout: layouts/Document.astro | ||
order: 333 | ||
order: 3 | ||
--- | ||
|
||
## Class arrays | ||
|
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,49 @@ | ||
--- | ||
layout: layouts/Document.astro | ||
order: 1 | ||
--- | ||
import Code from "../../../components/Code.astro" | ||
|
||
## Inline styles | ||
|
||
Similarly to React, you can use js inline styles in dreamland. Here's an example: | ||
|
||
<Code> | ||
```js | ||
let element = html`<div style=${{ color: "red", backgroundColor: "blue" }}>Hello, world!</div>`; | ||
``` | ||
```jsx | ||
let element = <div style={{ color: "red", backgroundColor: "blue" }}>Hello, world!</div>; | ||
``` | ||
</Code> | ||
|
||
You can also use the `use` function to bind a variable to a style property: | ||
|
||
|
||
<Code> | ||
```js | ||
let state = $state({ | ||
color: "red", | ||
}); | ||
|
||
let element = html`<div style=${{ color: use(state.color) }}>Hello, world!</div>`; | ||
``` | ||
```jsx | ||
let state = $state({ | ||
color: "red", | ||
}); | ||
|
||
let element = <div style={{ color: use(state.color) }}>Hello, world!</div>; | ||
``` | ||
```tsx | ||
let state: { | ||
color: string | ||
} = $state({ | ||
color: "red", | ||
}); | ||
|
||
let element: HTMLElement = <div style={{ color: use(state.color) }}>Hello, world!</div>; | ||
``` | ||
</Code> | ||
|
||
This is the ideal solution for when styles change often, but is not optimal for more static css |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.