-
Notifications
You must be signed in to change notification settings - Fork 19
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
Proofreading the docs... #37
base: v2
Are you sure you want to change the base?
Changes from 10 commits
cf32cb7
b6cc82c
ab8b1d9
de5fde2
fd354e6
769fccf
eee072e
056c0f6
f63c855
ab672f8
252f9b3
d3fe5e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,103 +10,29 @@ parent: Usage | |
#### Component Attributes | ||
|
||
Attributes declared on the components will be all be accessible through the `state`. | ||
If the property is initialized in the `this.state`, the attribute will be reactive: | ||
|
||
```html | ||
<x-user status="thinking 🤔"><x-user> | ||
``` | ||
|
||
`status` will therefore be reactive and the _thinking 🤔_ attribute value will overwrite the _Happy 😄_ default status. | ||
|
||
⚠️ A property that is not declared in the `state` won't be reactive. | ||
|
||
These properties can be accessed through `this.getAttribute()` from within the component. | ||
After all, these components are just native! 🏡 | ||
|
||
|
||
#### Slots | ||
vinyll marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[Slots](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/slot) are part of the | ||
native web-component. | ||
Because Lego builds native web-components, you can use the standard _slots_ as documented. | ||
If the property is initialized in the `this.state`, the attribute will be reactive. | ||
|
||
Example: | ||
|
||
__index.html__ | ||
```html | ||
<user-profile> | ||
<span>This user is in Paris</span> | ||
<user-profile> | ||
``` | ||
|
||
__bricks/user-profile.html__ | ||
```html | ||
<template> | ||
<h1>User profile</h1> | ||
<p>important information: <slot></slot></p> | ||
</template> | ||
<x-user status="Thinking 🤔"></x-user> | ||
``` | ||
|
||
Will write `…<p>important information: <span>This user is in Paris</span></p>` | ||
|
||
[See more advanced examples](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_templates_and_slots#Adding_flexibility_with_slots). | ||
|
||
|
||
### Reactive CSS Within `<style>` | ||
vinyll marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
CSS is much more fun when it's scoped. | ||
Here it come with the web-components. | ||
|
||
Here again, no trick, just the full power of web-components and scoping styles. | ||
Well, you should know that the css is reactive too! 😲 | ||
|
||
Writing CSS is as easy as | ||
|
||
__bricks/x-user.html__ | ||
```html | ||
<script> | ||
const state = { fontScale: 1 } | ||
const state = { status: "Happy 😄" } | ||
</script> | ||
|
||
<template> | ||
<h1>Bonjour!</h1> | ||
<p>User status: {{ state.status }}</p> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, that should be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed 👍 |
||
</template> | ||
|
||
<style> | ||
:host { | ||
font-size: ${state.fontScale}rem; | ||
} | ||
h1 { | ||
padding: 1rem; | ||
text-align: center; | ||
} | ||
</style> | ||
``` | ||
|
||
#### Host | ||
|
||
[`:host` is a native selector](https://developer.mozilla.org/en-US/docs/Web/CSS/:host()) | ||
for web-components. | ||
It allows to select the current component itself. | ||
|
||
#### Variables | ||
|
||
You can use variables in your CSS just like in your templates. | ||
|
||
Example: | ||
```html | ||
<script> | ||
const state = { color: '#357' } | ||
</script> | ||
|
||
<template> | ||
<h1>Bonjour<h1> | ||
</template> | ||
`status` will therefore be reactive and the _Thinking 🤔_ attribute value will overwrite the _Happy 😄_ default status. | ||
|
||
<style> | ||
h1 { | ||
color: ${ state.color }; | ||
} | ||
</style> | ||
``` | ||
⚠️ A property that is not declared in the `state` won't be reactive. | ||
|
||
will apply the `#357` color onto `h1`. | ||
These properties can be accessed through `this.getAttribute()` from within the component. | ||
After all, these components are just native! 🏡 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ permalink: /configuring-components/ | |
nav_order: 50 | ||
--- | ||
|
||
The compiler can take serveral parameters: `sourceDir`, `destDist`, `watch`… | ||
The compiler can take several parameters: `sourceDir`, `destDist`, `watch`… | ||
|
||
These will allow you to fine grain your configuration when compiling. | ||
|
||
|
@@ -48,3 +48,4 @@ Passing parameters in the CLI will override default parameters and custom config | |
|
||
The command line accepts the following parameters: `npx lego <sourceDir> <destDir> <options>`. | ||
The only option for now is `-w` (stading for the `watch` config property). | ||
<!-- FIXME: stading is unknown --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't know what you mean here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should rephrase to something like:
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<!-- FIXME: what is the purpose of this README? --> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this file required? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should it describe how to compile the doc instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is a good idea! |
||
Documentation was moved to https://github.com/Polight/lego/tree/master/docs | ||
|
||
```html | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about
responsiveness
orreactivity
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
go for
reactivity