Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: copy examples to folder #12

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions examples/aggregation/components/my-component.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<style>
my-component {
color: rebeccapurple;
}
</style>
9 changes: 9 additions & 0 deletions examples/aggregation/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");
page.defineComponents("components/my-component.webc");

let { html, css, js, components } = await page.compile();
console.log({ html, css, js, components });
1 change: 1 addition & 0 deletions examples/aggregation/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<my-component>Default slot</my-component>
3 changes: 3 additions & 0 deletions examples/attributes/components/my-component.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template webc:root class="another-class">
Some component content
</template>
9 changes: 9 additions & 0 deletions examples/attributes/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");
page.defineComponents("components/my-component.webc");

let { html, css, js, components } = await page.compile();
console.log({ html, css, js, components });
1 change: 1 addition & 0 deletions examples/attributes/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<my-component class="sr-only">This is the default slot</my-component>
6 changes: 6 additions & 0 deletions examples/custom-transforms/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "module",
"dependencies": {
"markdown-it": "^13.0.1"
}
}
15 changes: 15 additions & 0 deletions examples/custom-transforms/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import MarkdownIt from "markdown-it";
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");

let md = new MarkdownIt({ html: true });

page.setTransform("md", (content) => {
return md.render(content);
});

let { html, css, js, components } = await page.compile();
console.log({ html, css, js, components });
31 changes: 31 additions & 0 deletions examples/custom-transforms/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template webc:type="md">
# Header
## Header 2
### Header 3

* List item 1
* List item 2
* List item 3

1. List item 1
2. List item 2
3. List item 3

**Bold text**

*Italic text*

~~Strikethrough text~~

[Link](https://11ty.dev)

![Image](https://pbs.twimg.com/profile_images/1196791261233111040/iWVjazhO_400x400.jpg)


| Column 1 | Column 2 | Column 3 |
| -------- | -------- | -------- |
| Row 1 | Row 1 | Row 1 |
| Row 2 | Row 2 | Row 2 |

</template>

11 changes: 11 additions & 0 deletions examples/helpers/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");
page.setHelper("alwaysBlue", () => {
return "I'm blue, da ba dee da ba di"
});

let { html, css, js, components } = await page.compile();
console.log({ html, css, js, components });
5 changes: 5 additions & 0 deletions examples/helpers/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script webc:type="render" webc:is="template">
function() {
return this.alwaysBlue();
}
</script>
12 changes: 12 additions & 0 deletions examples/html/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");

let { html, css, js, components } = await page.compile({
data: {
dataProperty: "dataValue",
},
});
console.log({ html, css, js, components });
5 changes: 5 additions & 0 deletions examples/html/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template @html="'Template HTML'"></template>
<template @html="this.dataProperty"></template>

<!-- webc:nokeep will replace the outer html -->
<template @html="'Template HTML'" webc:nokeep></template>
1 change: 1 addition & 0 deletions examples/imports/components/my-component.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Components don’t need a root element, y’all.
1 change: 1 addition & 0 deletions examples/imports/components/my-dynamic-component.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This other component is dynamically imported!!!
1 change: 1 addition & 0 deletions examples/imports/components/my-remapped-component.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
And this other component is a remapped component!
19 changes: 19 additions & 0 deletions examples/imports/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");

// Pass in a glob, using the file name as component name
page.defineComponents("components/**.webc");

// Array of file names, using file name as component name
// page.defineComponents(["components/my-component.webc"]);

// Object maps component name to file name
// page.defineComponents({
// "my-component": "components/my-component.webc"
// });

let { html } = await page.compile();
console.log({ html });
8 changes: 8 additions & 0 deletions examples/imports/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<title>WebC Example</title>
<my-component></my-component>

<!-- Dynamic import -->
<any-tag-name webc:import="components/my-dynamic-component.webc"></any-tag-name>

<!-- Remapping components -->
<div webc:is="my-remapped-component"></div>
1 change: 1 addition & 0 deletions examples/lookup-attributes/components/my-component.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img :src="src" :alt="alt" class="avatar-image">
9 changes: 9 additions & 0 deletions examples/lookup-attributes/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");
page.defineComponents("components/my-component.webc");

let { html, css, js, components } = await page.compile();
console.log({ html, css, js, components });
1 change: 1 addition & 0 deletions examples/lookup-attributes/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<avatar-image src="my-image.jpeg" alt="Zach is an awesome person"></avatar-image>
8 changes: 8 additions & 0 deletions examples/page/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");

let { html, css, js, components } = await page.compile();
console.log({ html, css, js, components });
26 changes: 26 additions & 0 deletions examples/page/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>WebC Example</title>
<style webc:keep>
body {
color: #333;
}
</style>
<script webc:keep>
alert("Hello World!");
</script>
<script webc:nokeep>
console.log("Hello World!");
</script>
</head>
<body>
<style webc:nokeep>
body {
color: red;
}
</style>
WebC *is* HTML.
</body>
</html>
1 change: 1 addition & 0 deletions examples/properties/components/my-component.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img :src="src" :alt="alt" class="avatar-image">
9 changes: 9 additions & 0 deletions examples/properties/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");
page.defineComponents("components/my-component.webc");

let { html, css, js, components } = await page.compile();
console.log({ html, css, js, components });
1 change: 1 addition & 0 deletions examples/properties/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<avatar-image src="my-image.jpeg" alt="Zach is an awesome person" @secret="This is just between us"></avatar-image>></avatar-image>
8 changes: 8 additions & 0 deletions examples/raw/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");

let { html, css, js, components } = await page.compile();
console.log({ html, css, js, components });
6 changes: 6 additions & 0 deletions examples/raw/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<template webc:raw>
Leave me out of this.
<style>
p { color: rebeccapurple; }
</style>
</template>
6 changes: 6 additions & 0 deletions examples/render/components/add-banner-to-css.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script webc:type="render" webc:is="style">
function() {
return `/* ${this.license} */`;
}
</script>
<slot></slot>
9 changes: 9 additions & 0 deletions examples/render/components/img.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script webc:type="render" webc:is="template">
function() {
if(!this.alt) {
throw new Error("oh no you didn’t");
}
// Free idea: use the Eleventy Image plugin to return optimized markup
return `<img src="${this.src}" alt="${this.alt}">`;
}
</script>
12 changes: 12 additions & 0 deletions examples/render/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");
page.defineComponents({
"avatar-image": "components/img.webc",
"add-banner-to-css": "components/add-banner-to-css.webc"
});

let { html, css, js, components } = await page.compile();
console.log({ html, css, js, components });
5 changes: 5 additions & 0 deletions examples/render/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<avatar-image src="my-image.jpeg" alt="Zach is an awesome person" @secret="This is just between us"></avatar-image>

<add-banner-to-css license="MIT licensed">
/* Some other CSS content */
</add-banner-to-css>
8 changes: 8 additions & 0 deletions examples/scoped-css/components/my-component-prefixed.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<style webc:scoped="my-prefix">
:host {
color: blue;
}
:host:defined {
color: rebeccapurple;
}
</style>
8 changes: 8 additions & 0 deletions examples/scoped-css/components/my-component.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<style webc:scoped>
:host {
color: blue;
}
:host:defined {
color: rebeccapurple;
}
</style>
9 changes: 9 additions & 0 deletions examples/scoped-css/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");
page.defineComponents("components/**.webc");

let { html, css, js, components } = await page.compile();
console.log({ html, css, js, components });
2 changes: 2 additions & 0 deletions examples/scoped-css/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<my-component>Default slot</my-component>
<my-component-prefixed>Prefixed slot</my-component-prefixed>
17 changes: 17 additions & 0 deletions examples/slots/components/my-component.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<p>Hello World!</p>

<dialog><slot></slot></dialog>

<div><slot name="my-slot"></slot></div>

<main><slot webc:keep name="my-other-slot"></slot></main>

<style>
p {
color: red;
}
</style>

<script>
alert("Hello World!");
</script>
9 changes: 9 additions & 0 deletions examples/slots/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { WebC } from "../../webc.js";

let page = new WebC();

page.setInputPath("page.webc");
page.defineComponents("components/my-component.webc");

let { html } = await page.compile();
console.log({ html });
17 changes: 17 additions & 0 deletions examples/slots/page.webc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<title>WebC Example</title>

<!-- Keep that host component HTML -->
<my-component webc:keep></my-component>

<!-- Slots -->
<my-component>This is the default slot</my-component>

<!-- Named slots -->
<my-component>
<div slot="my-slot">This is a named slot</div>
</my-component>

<!-- Named slots -->
<my-component>
<div slot="my-other-slot">This is another named slot with slot tag</div>
</my-component>
Loading