Skip to content

Commit

Permalink
dummy app: added visibility toggle example
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWilmot committed Sep 24, 2022
1 parent 617e147 commit 7b659c3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
11 changes: 7 additions & 4 deletions tests/dummy/app/controllers/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class Application extends Controller {
@tracked specType: string;
@tracked config: object;
@tracked data: DataRecord;
@tracked isVisible: boolean;

constructor() {
super(...arguments);
Expand All @@ -27,14 +28,16 @@ export default class Application extends Controller {
this.specType = SPEC_TYPE;
this.config = CONFIG;
this.data = DATA_1;

this.isVisible = false;
}

@action updateData() {
this.data = DATA_2;
// TODO: Hack to workaround tracked property not being fired by this.data
// change
this.specType = '';
this.specType = 'vega';
}

@action toggleVisibility() {
this.isVisible = !this.isVisible;
}
}

Expand Down
11 changes: 11 additions & 0 deletions tests/dummy/app/styles/app.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[aria-hidden="true"] {
margin: -1px;
padding: 0;
width: 1px;
height: 1px;
overflow: hidden;
clip: rect(0 0 0 0);
clip: rect(0, 0, 0, 0);
position: absolute;
}

23 changes: 22 additions & 1 deletion tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,30 @@
</div>

<div>
<button {{on "click" this.updateData}}>
<button type="button" {{on "click" this.updateData}}>
Update data
</button>
</div>

<br>
<div>
<button type="button" {{on "click" this.toggleVisibility}}>
Toggle visibility
</button>
</div>

<div aria-hidden={{if this.isVisible "false" "true"}}>
<div
{{vega
specType=this.specType
spec=this.spec
data=this.data
config=this.config
isVisible=this.isVisible
}}
style="height: 100%; min-height: 400px; max-height: 100%;"
>
</div>
</div>

{{outlet}}

0 comments on commit 7b659c3

Please sign in to comment.