Skip to content

Commit

Permalink
feat(switcher): add active component option
Browse files Browse the repository at this point in the history
  • Loading branch information
Yelinz authored and anehx committed Aug 3, 2021
1 parent 537e16e commit 39c2e36
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 8 deletions.
2 changes: 2 additions & 0 deletions addon/mixins/switcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ export default Mixin.create({
attributeBindings: [
"ukSwitcher:uk-switcher",
"connect",
"active",
"animation",
"animationDuration:duration",
"swiping",
],

contentId: "",
active: 0,
animation: "",
animationDuration: 200,
swiping: false,
Expand Down
2 changes: 1 addition & 1 deletion addon/templates/components/uk-switcher.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{yield
(hash
nav=(component "uk-switcher/nav" contentId=contentId animation=animation animationDuration=animationDuration swiping=swiping)
nav=(component "uk-switcher/nav" contentId=contentId active=active animation=animation animationDuration=animationDuration swiping=swiping)
content=(component "uk-switcher/content" elementId=contentId)
)
}}
1 change: 1 addition & 0 deletions addon/templates/components/uk-switcher/nav.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
component=(component
componentName
contentId=contentId
active=@active
animation=@animation
animationDuration=@animationDuration
swiping=@swiping
Expand Down
13 changes: 7 additions & 6 deletions tests/dummy/app/controllers/docs/components/switcher.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Controller from "@ember/controller";

export default Controller.extend({
type: "tab",
animation: "uk-animation-fade",
animationDuration: 200,
swiping: false,
});
export default class SwitcherController extends Controller {
type = "tab";
active = 0;
animation = "uk-animation-fade";
animationDuration = 200;
swiping = false;
}
15 changes: 14 additions & 1 deletion tests/dummy/app/templates/docs/components/switcher.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2>Switcher</h2>

<div class="uk-padding uk-box-shadow-medium uk-margin">
<UkSwitcher @animation={{animation}} @animationDuration={{animationDuration}} @swiping={{swiping}} as |switcher|>
<UkSwitcher @active={{active}} @animation={{animation}} @animationDuration={{animationDuration}} @swiping={{swiping}} as |switcher|>
<switcher.nav @type={{type}} as |nav|>
<nav.component as |tab|>
<tab.item>Item 1</tab.item>
Expand Down Expand Up @@ -68,6 +68,19 @@
</tr>
</thead>
<tbody>
<tr>
<td><code>active</code></td>
<td><code>Number</code></td>
<td><code>0</code></td>
<td>Active index on init. Providing a negative number indicates a position starting from the end of the set.</td>
<td>
<small class="uk-text-muted">
Sadly we can't show this live since we"d need to
reinitialize the component on every change. Currently we
use <b>{{active}}</b>.
</small>
</td>
</tr>
<tr>
<td><code>animation</code></td>
<td><code>String</code></td>
Expand Down

0 comments on commit 39c2e36

Please sign in to comment.