-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1660 from NullVoxPopuli/more-guides-updates
More guides updates
- Loading branch information
Showing
8 changed files
with
183 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import Controller from '@ember/controller'; | ||
|
||
export default class ApplicationController extends Controller { | ||
queryParams = ['showAnswer']; | ||
queryParams = ['showAnswer', 'local']; | ||
} |
50 changes: 48 additions & 2 deletions
50
apps/tutorial/public/docs/6-component-patterns/3-conditional-blocks/answer.gjs
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,5 +1,51 @@ | ||
const Conditional = <template> | ||
<div class="block-layout"> | ||
{{#if (has-block "blue")}} | ||
<div class="blue"> | ||
{{yield to="blue"}} | ||
</div> | ||
{{/if}} | ||
|
||
<div class="red"> | ||
{{yield to="default"}} | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.block-layout { | ||
border: 1px solid black; | ||
padding: 0.5rem; | ||
display: grid; | ||
gap: 0.5rem; | ||
.red { border: 1px solid red; } | ||
.blue { border: 1px solid blue; } | ||
.red, .blue { padding: 0.5rem; } | ||
} | ||
</style> | ||
</template>; | ||
|
||
<template> | ||
This tutorial chapter needs to be written! | ||
<div class="layout"> | ||
<Conditional> | ||
Default content. Only the red box shows. | ||
The blue box should not be rendered. | ||
</Conditional> | ||
|
||
<Conditional> | ||
<:blue> | ||
Shows up in blue | ||
</:blue> | ||
<:default> | ||
Content for :default shows up in red | ||
</:default> | ||
</Conditional> | ||
</div> | ||
|
||
It could be written by you!, if you want <3 | ||
<style> | ||
.layout { | ||
display: grid; | ||
gap: 1rem; | ||
} | ||
</style> | ||
</template> |
48 changes: 46 additions & 2 deletions
48
apps/tutorial/public/docs/6-component-patterns/3-conditional-blocks/prompt.gjs
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,5 +1,49 @@ | ||
const Conditional = <template> | ||
<div class="block-layout"> | ||
<div class="blue"> | ||
{{yield to="blue"}} | ||
</div> | ||
|
||
<div class="red"> | ||
{{yield to="default"}} | ||
</div> | ||
</div> | ||
|
||
<style> | ||
.block-layout { | ||
border: 1px solid black; | ||
padding: 0.5rem; | ||
display: grid; | ||
gap: 0.5rem; | ||
.red { border: 1px solid red; } | ||
.blue { border: 1px solid blue; } | ||
.red, .blue { padding: 0.5rem; } | ||
} | ||
</style> | ||
</template>; | ||
|
||
<template> | ||
This tutorial chapter needs to be written! | ||
<div class="layout"> | ||
<Conditional> | ||
Default content. Only the red box shows. | ||
The blue box should not be rendered. | ||
</Conditional> | ||
|
||
<Conditional> | ||
<:blue> | ||
Shows up in blue | ||
</:blue> | ||
<:default> | ||
Content for :default shows up in red | ||
</:default> | ||
</Conditional> | ||
</div> | ||
|
||
It could be written by you!, if you want <3 | ||
<style> | ||
.layout { | ||
display: grid; | ||
gap: 1rem; | ||
} | ||
</style> | ||
</template> |
44 changes: 42 additions & 2 deletions
44
apps/tutorial/public/docs/6-component-patterns/3-conditional-blocks/prose.md
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,3 +1,43 @@ | ||
This tutorial chapter needs to be written! | ||
Conditional Blocks are `:named` blocks that only render when a condition is met. In many cases, that could be the condition that a block is used at all. | ||
|
||
It could be written by you!, if you want <3 | ||
For example, observe the difference in these component invocations: | ||
```hbs | ||
<Modal> | ||
<:content> | ||
content here | ||
</:content> | ||
</Modal> | ||
``` | ||
and | ||
```hbs | ||
<Modal> | ||
<:content> | ||
quetsion here | ||
</:content> | ||
<:footer> | ||
buttons here | ||
</:footer> | ||
</Modal> | ||
``` | ||
|
||
The `:footer` block is optionally present, and we may expect that when it is omitted, that the component we're using, `Modal` in this case, doesn't include any of the padding or styling associated with the footer of the `Modal`. | ||
|
||
To implement this, there is a built-in feature of the templating language, the [`(has-block)`][docs-has-block] helper. | ||
|
||
Usage would look like this: | ||
```hbs | ||
{{#if (has-block 'footer')}} | ||
<footer class="styles, etc"> | ||
{{yield to="footer"}} | ||
</footer> | ||
{{/if}} | ||
``` | ||
|
||
The styling provided by the `footer` element, and accompanying CSS classes would be omitted when the caller omits the `:footer` named block. | ||
|
||
In this exercise, | ||
<p class="call-to-play">update the <code>Conditional</code> component to conditionally render the <code>:blue</code> block only when it is declared by the caller.</p>. | ||
|
||
|
||
|
||
[docs-has-block]: https://api.emberjs.com/ember/5.6/classes/Ember.Templates.helpers/methods/has-block?anchor=has-block |
39 changes: 36 additions & 3 deletions
39
apps/tutorial/public/docs/6-component-patterns/4-contextual-components/answer.gjs
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,5 +1,38 @@ | ||
<template> | ||
This tutorial chapter needs to be written! | ||
import { hash } from '@ember/helper'; | ||
|
||
const AcceptButton = <template> | ||
<button>Accept</button> | ||
</template>; | ||
|
||
const DeclineButton = <template> | ||
<button>Decline {{@text}}</button> | ||
</template>; | ||
|
||
const CustomButton = <template> | ||
<button> | ||
<span> | ||
{{yield to="default"}} | ||
</span> | ||
{{#if (has-block "right")}} | ||
<span> | ||
{{yield to="right"}} | ||
</span> | ||
{{/if}} | ||
</button> | ||
</template> | ||
|
||
|
||
It could be written by you!, if you want <3 | ||
const ButtonGroup = <template> | ||
{{yield (hash | ||
Accept=AcceptButton | ||
Decline=DeclineButton | ||
Custom=CustomButton | ||
)}} | ||
</template>; | ||
|
||
<template> | ||
<ButtonGroup as |b|> | ||
<b.Accept /> | ||
<b.Decline @text="to accept" /> | ||
</ButtonGroup> | ||
</template> |
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