Skip to content

Commit

Permalink
Updated demo app (#137)
Browse files Browse the repository at this point in the history
* refactor: Made <Tracks> a template-only component

* bugfix: Fixed visual regression in <Widgets::Widget-2::Captions> component

* refactor: Improved code readability of <Widgets::Widget-2::Captions> component

* chore: Called resizeObserver.unobserve and resizeObserver.observe in the same order as they are in the {{container-query}} modifier

* refactor: Improved code readability

* chore: Renamed {{draw-chart}} modifier to {{draw-stacked-chart}}

* refactor: Used the {{container-query}} modifier to set the best-fitting image

* refactor: Created a temporary variable in <Widgets::Widget-4::Memo::Header> component

* chore: Installed ember-template-lint-plugin-prettier

* chore: Ran yarn lint:hbs:fix to fix formatting issues

* bugfix: Fixed visual regressions

* chore: Temporarily removed overrides for test files, to illustrate an (unintended?) effect of ember-template-lint@v5

* Revert "chore: Temporarily removed overrides for test files, to illustrate an (unintended?) effect of ember-template-lint@v5"

This reverts commit 7f3de43.

* chore: Updated LICENSE

Co-authored-by: ijlee2 <ijlee2@users.noreply.github.com>
  • Loading branch information
ijlee2 and ijlee2 committed Dec 13, 2022
1 parent 3e6717f commit dcbbeaa
Show file tree
Hide file tree
Showing 42 changed files with 399 additions and 332 deletions.
11 changes: 11 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
'use strict';

module.exports = {
printWidth: 80,
singleQuote: true,

overrides: [
{
files: '*.hbs',
options: {
printWidth: 64,
singleQuote: false,
},
},
],
};
11 changes: 10 additions & 1 deletion .template-lintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
'use strict';

module.exports = {
extends: 'recommended',
plugins: ['ember-template-lint-plugin-prettier'],
extends: ['recommended', 'ember-template-lint-plugin-prettier:recommended'],
overrides: [
{
files: ['addon/**/*.hbs', 'tests/**/*-test.{js,ts}'],
rules: {
prettier: 'off',
},
},
],
};
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2022
Copyright (c) 2023 Isaac J. Lee

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
10 changes: 6 additions & 4 deletions addon/components/container-query.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
}}
...attributes
>
{{yield (hash
dimensions=this.dimensions
features=this.queryResults
)}}
{{yield
(hash
dimensions=this.dimensions
features=this.queryResults
)
}}
</Tag>
{{/let}}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"ember-source-channel-url": "^3.0.0",
"ember-svg-jar": "^2.4.2",
"ember-template-lint": "^5.0.2",
"ember-template-lint-plugin-prettier": "^4.1.0",
"ember-truth-helpers": "^3.1.1",
"ember-try": "^2.0.0",
"eslint": "^8.28.0",
Expand Down
5 changes: 1 addition & 4 deletions tests/dummy/app/components/navigation-menu.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<nav
aria-label={{@name}}
data-test-nav={{@name}}
>
<nav aria-label={{@name}} data-test-nav={{@name}}>
<ul local-class="list">
{{#each @menuItems as |menuItem|}}
<li local-class="item">
Expand Down
5 changes: 5 additions & 0 deletions tests/dummy/app/components/tracks.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { Track } from 'dummy/data/album';

export interface TracksComponentArgs {
tracks?: Array<Track>;
}
11 changes: 5 additions & 6 deletions tests/dummy/app/components/tracks.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@
as |CQ|
>
{{#if (and CQ.features.large CQ.features.tall)}}
<Tracks::Table
@tracks={{this.tracks}}
/>
<Tracks::Table @tracks={{@tracks}} />

{{else}}
<Tracks::List
@numColumns={{
if CQ.features.small 1
@numColumns={{if
CQ.features.small
1
(if CQ.features.medium 2 3)
}}
@tracks={{this.tracks}}
@tracks={{@tracks}}
/>

{{/if}}
Expand Down
12 changes: 0 additions & 12 deletions tests/dummy/app/components/tracks.ts

This file was deleted.

11 changes: 6 additions & 5 deletions tests/dummy/app/components/tracks/list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
}}
>
{{#each @tracks as |track index|}}
<li
data-test-item
local-class="item"
>
<li data-test-item local-class="item">
<div>
{{add index 1}}.
<span data-test-field="Title">
Expand All @@ -25,7 +22,11 @@
data-test-field="Explicit"
role="img"
>
{{svg-jar "alpha-e-box" aria-hidden="true" local-class="icon-explicit"}}
{{svg-jar
"alpha-e-box"
aria-hidden="true"
local-class="icon-explicit"
}}
</span>
{{/if}}
</li>
Expand Down
14 changes: 11 additions & 3 deletions tests/dummy/app/components/tracks/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,23 @@ import type { Track } from 'dummy/data/album';

interface TracksListComponentArgs {
numColumns?: number;
tracks: Array<Track>;
tracks?: Array<Track>;
}

export default class TracksListComponent extends Component<TracksListComponentArgs> {
get numColumns(): number {
return this.args.numColumns ?? 1;
const { numColumns } = this.args;

return numColumns ?? 1;
}

get numRows(): number {
return Math.ceil(this.args.tracks.length / this.numColumns);
const { tracks } = this.args;

if (!tracks) {
return 0;
}

return Math.ceil(tracks.length / this.numColumns);
}
}
2 changes: 1 addition & 1 deletion tests/dummy/app/components/tracks/table.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Track } from 'dummy/data/album';

export interface TracksTableComponentArgs {
tracks: Array<Track>;
tracks?: Array<Track>;
}
20 changes: 11 additions & 9 deletions tests/dummy/app/components/ui/form.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<form
aria-describedby={{if @instructions (concat this.formId "-instructions")}}
aria-describedby={{if
@instructions
(concat this.formId "-instructions")
}}
aria-labelledby={{if @title (concat this.formId "-title")}}
data-test-form={{or @title ""}}
local-class="form"
Expand All @@ -12,27 +15,26 @@
/>

<ContainerQuery
@features={{hash
wide=(cq-width min=480)
}}
@features={{hash wide=(cq-width min=480)}}
as |CQ|
>
{{yield
(hash
Checkbox=(component "ui/form/checkbox"
Checkbox=(component
"ui/form/checkbox"
changeset=this.changeset
isInline=true
isWide=CQ.features.wide
onUpdate=this.updateChangeset
)

Input=(component "ui/form/input"
Input=(component
"ui/form/input"
changeset=this.changeset
isWide=CQ.features.wide
onUpdate=this.updateChangeset
)

Textarea=(component "ui/form/textarea"
Textarea=(component
"ui/form/textarea"
changeset=this.changeset
isWide=CQ.features.wide
onUpdate=this.updateChangeset
Expand Down
15 changes: 8 additions & 7 deletions tests/dummy/app/components/ui/form/checkbox.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
@isWide={{@isWide}}
>
<:label as |l|>
<label
data-test-label
id="{{l.inputId}}-label"
>
<label data-test-label id="{{l.inputId}}-label">
{{@label}}

{{#if @isRequired}}
Expand All @@ -27,16 +24,20 @@
aria-required={{if @isRequired "true" "false"}}
data-test-field={{@label}}
local-class="checkbox
{{if this.isChecked "is-checked"}}
{{if (or @isDisabled @isReadOnly) "is-disabled"}}
{{if this.isChecked 'is-checked'}}
{{if (or @isDisabled @isReadOnly) 'is-disabled'}}
"
role="checkbox"
tabindex={{unless @isDisabled "0"}}
{{on "click" this.updateValue}}
{{on "keypress" this.updateValueByPressingSpace}}
>
{{#if this.isChecked}}
{{svg-jar "check" aria-hidden="true" local-class="checkmark-icon"}}
{{svg-jar
"check"
aria-hidden="true"
local-class="checkmark-icon"
}}
{{/if}}
</span>
</:field>
Expand Down
7 changes: 2 additions & 5 deletions tests/dummy/app/components/ui/form/input.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
@isWide={{@isWide}}
>
<:label as |l|>
<label
data-test-label
for={{l.inputId}}
>
<label data-test-label for={{l.inputId}}>
{{@label}}

{{#if @isRequired}}
Expand All @@ -23,7 +20,7 @@
disabled={{@isDisabled}}
id={{f.inputId}}
local-class="input
{{if (or @isDisabled @isReadOnly) "is-disabled"}}
{{if (or @isDisabled @isReadOnly) 'is-disabled'}}
"
placeholder={{@placeholder}}
readonly={{@isReadOnly}}
Expand Down
9 changes: 3 additions & 6 deletions tests/dummy/app/components/ui/form/textarea.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
@isWide={{@isWide}}
>
<:label as |l|>
<label
data-test-label
for={{l.inputId}}
>
<label data-test-label for={{l.inputId}}>
{{@label}}

{{#if @isRequired}}
Expand All @@ -23,14 +20,14 @@
disabled={{@isDisabled}}
id={{f.inputId}}
local-class="textarea
{{if (or @isDisabled @isReadOnly) "is-disabled"}}
{{if (or @isDisabled @isReadOnly) 'is-disabled'}}
"
placeholder={{@placeholder}}
readonly={{@isReadOnly}}
required={{@isRequired}}
rows="4"
value={{this.value}}
{{on "input" this.updateValue}}
/>
></textarea>
</:field>
</Ui::Form::Field>
6 changes: 1 addition & 5 deletions tests/dummy/app/components/ui/page.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
{{@title}}
</h1>

<div
id="main-content"
local-class="body"
tabindex="-1"
>
<div id="main-content" local-class="body" tabindex="-1">
{{yield}}
</div>
</div>
12 changes: 3 additions & 9 deletions tests/dummy/app/components/widgets/widget-1.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,15 @@

<div local-class="items">
<div local-class="item-1">
<Widgets::Widget-1::Item
@title="Item 1"
/>
<Widgets::Widget-1::Item @title="Item 1" />
</div>

<div local-class="item-2">
<Widgets::Widget-1::Item
@title="Item 2"
/>
<Widgets::Widget-1::Item @title="Item 2" />
</div>

<div local-class="item-3">
<Widgets::Widget-1::Item
@title="Item 3"
/>
<Widgets::Widget-1::Item @title="Item 3" />
</div>
</div>
</ContainerQuery>
14 changes: 3 additions & 11 deletions tests/dummy/app/components/widgets/widget-2.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,12 @@
</header>

{{#unless CQ.features.short}}
<div
data-test-visualization
local-class="visualization"
>
<Widgets::Widget-2::StackedChart
@data={{this.data}}
/>
<div data-test-visualization local-class="visualization">
<Widgets::Widget-2::StackedChart @data={{this.data}} />
</div>
{{/unless}}

<div
data-test-captions
local-class="captions"
>
<div data-test-captions local-class="captions">
<Widgets::Widget-2::Captions
@summaries={{this.summaries}}
/>
Expand Down
Loading

0 comments on commit dcbbeaa

Please sign in to comment.