forked from matschik/component-party.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
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
16 changed files
with
137 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import nodePath from "node:path"; | ||
import { compressToURL } from "@matschik/lz-string"; | ||
|
||
const BASE = "https://markojs.com/playground/#"; | ||
|
||
export default function createMarkoPlayground() { | ||
return { | ||
fromContentByFilename(contentByFilename) { | ||
const data = Object.entries(contentByFilename).map(([path, content]) => ({ | ||
name: nodePath.parse(path).base, | ||
path: `/components/${path}`, | ||
content, | ||
})); | ||
|
||
return BASE + compressToURL(JSON.stringify(data)); | ||
}, | ||
}; | ||
} |
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
28 changes: 16 additions & 12 deletions
28
content/4-component-composition/3-slot/marko/FunnyButton.marko
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,14 +1,18 @@ | ||
<button style={ | ||
background: "rgba(0, 0, 0, 0.4)", | ||
color: "#fff", | ||
padding: "10px 20px", | ||
fontSize: "30px", | ||
border: "2px solid #fff", | ||
margin: "8px", | ||
transform: "scale(0.9)", | ||
boxShadow: "4px 4px rgba(0, 0, 0, 0.4)", | ||
transition: "transform 0.2s cubic-bezier(0.34, 1.65, 0.88, 0.925) 0s", | ||
outline: "0", | ||
}> | ||
<button.${funnyButton}> | ||
<${input.renderBody}/> | ||
</button> | ||
|
||
<style.module.css/{ funnyButton }> | ||
.funnyButton { | ||
background: rgba(0, 0, 0, 0.4); | ||
color: #fff; | ||
padding: 10px 20px; | ||
font-size: 30px; | ||
border: 2px solid #fff; | ||
margin: 8px; | ||
transform: scale(0.9); | ||
box-shadow: 4px 4px rgba(0, 0, 0, 0.4); | ||
transition: transform 0.2s cubic-bezier(0.34, 1.65, 0.88, 0.925) 0s; | ||
outline: 0; | ||
} | ||
</style> |
28 changes: 16 additions & 12 deletions
28
content/4-component-composition/4-slot-fallback/marko/FunnyButton.marko
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,16 +1,20 @@ | ||
<button style={ | ||
background: "rgba(0, 0, 0, 0.4)", | ||
color: "#fff", | ||
padding: "10px 20px", | ||
fontSize: "30px", | ||
border: "2px solid #fff", | ||
margin: "8px", | ||
transform: "scale(0.9)", | ||
boxShadow: "4px 4px rgba(0, 0, 0, 0.4)", | ||
transition: "transform 0.2s cubic-bezier(0.34, 1.65, 0.88, 0.925) 0s", | ||
outline: "0", | ||
}> | ||
<button.${funnyButton}> | ||
<${input.renderBody}> | ||
<span>No content found</span> | ||
</> | ||
</button> | ||
|
||
<style.module.css/{ funnyButton }> | ||
.funnyButton { | ||
background: rgba(0, 0, 0, 0.4); | ||
color: #fff; | ||
padding: 10px 20px; | ||
font-size: 30px; | ||
border: 2px solid #fff; | ||
margin: 8px; | ||
transform: scale(0.9); | ||
box-shadow: 4px 4px rgba(0, 0, 0, 0.4); | ||
transition: transform 0.2s cubic-bezier(0.34, 1.65, 0.88, 0.925) 0s; | ||
outline: 0; | ||
} | ||
</style> |
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 |
---|---|---|
|
@@ -3,12 +3,11 @@ | |
username: "unicorn42", | ||
email: "[email protected]", | ||
}/> | ||
|
||
function updateUsername(newUsername) { | ||
<const/updateUsername(newUsername) { | ||
user = { ...user, username: newUsername }; | ||
} | ||
}/> | ||
|
||
<h1>Welcome back, ${user.username}</h1> | ||
<set user={ ...user, updateUsername }> | ||
<set={ ...user, updateUsername }> | ||
<UserProfile /> | ||
</set> |
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,4 @@ | ||
<!doctype html> | ||
<!DOCTYPE html> | ||
<html> | ||
<App/> | ||
</html> |
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,8 @@ | ||
With [`@marko/cli`’s `build` or `serve`](https://github.com/marko-js/cli/tree/main/packages/serve) | ||
|
||
```marko | ||
<nav> | ||
<a href="/">Index</a> | ||
<a href="/contact">Contact Us</a> | ||
</nav> | ||
``` |
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,8 @@ | ||
With [`@marko/run`](https://github.com/marko-js/run/tree/main/packages/serve) | ||
|
||
```marko | ||
<nav> | ||
<a href="/">Index</a> | ||
<a href="/contact">Contact Us</a> | ||
</nav> | ||
``` |
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,9 @@ | ||
With [`@marko/cli`’s `build` or `serve`](https://github.com/marko-js/cli/tree/main/packages/serve) | ||
|
||
``` | ||
index.marko // index page "/" | ||
about.marko // about page "/about" | ||
hello/ | ||
|-- [name].marko // dynamic Hello page "/hello/Emily" | ||
[rest].marko // dynamic parameter can be used as catch-all to show 404 page | ||
``` |
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,19 @@ | ||
With [`@marko/run`](https://github.com/marko-js/run/tree/main/packages/serve) | ||
|
||
``` | ||
routes/ | ||
|-- +page.marko // index page "/" | ||
|-- about/ | ||
|-- +page.marko // about page "/about" | ||
|-- +layout.marko // global app layout | ||
|-- +handler.{js,ts,*} // run code for conditionally rendering HTML/API route | ||
|-- +middleware.{js,ts,*} // added to HTTP framework middleware chain | ||
|-- +meta.{js,ts,*} // adds metadata to route | ||
|-- +404.marko // shows when no suitable route found | ||
|-- +500.marko // shows when any route throws | ||
|-- /path/_less/ | ||
|-- +page.marko // pathless directory, page "/path" | ||
|-- /$dynamic/ | ||
|-- +page.marko // dynamic parameter, can be used as a route-specific 404 | ||
|-- /$$catchall/ // like dynamic, but consumes all path segments until the end | ||
``` |
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