Skip to content
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

Renamed the helpers by dropping the cq prefix #146

Merged
merged 7 commits into from
Jan 3, 2023
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ API
The addon provides 1 Glimmer component and 3 helpers:

- `<ContainerQuery>`
- `{{cq-aspect-ratio}}`
- `{{cq-height}}`
- `{{cq-width}}`
- `{{aspect-ratio}}`
- `{{height}}`
- `{{width}}`

Starting `v2.1.1`, the addon extracts the core logic into a modifier. This lets you opt out of using the provided component.

Expand Down Expand Up @@ -186,7 +186,7 @@ You can consume these values in your app or addon.


<details>
<summary><code>{{cq-aspect-ratio}}</code>, <code>{{cq-height}}</code>, <code>{{cq-width}}</code></summary>
<summary><code>{{aspect-ratio}}</code>, <code>{{height}}</code>, <code>{{width}}</code></summary>

### Arguments

Expand Down Expand Up @@ -239,8 +239,8 @@ Let's look at the code that created the video demo above.
```hbs
<ContainerQuery
@features={{hash
large=(cq-width min=960)
tall=(cq-height min=400)
large=(width min=960)
tall=(height min=400)
}}
as |CQ|
>
Expand Down Expand Up @@ -280,10 +280,10 @@ Let's look at the code that created the video demo above.
```hbs
<ContainerQuery
@features={{hash
small=(cq-width max=480)
medium=(cq-width min=480 max=640)
large=(cq-width min=640)
tall=(cq-height min=320)
small=(width max=480)
medium=(width min=480 max=640)
large=(width min=640)
tall=(height min=320)
}}
as |CQ|
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { helper } from '@ember/component/helper';
import type { Metadata } from 'ember-container-query/modifiers/container-query';

interface CqAspectRatioHelperSignature {
interface AspectRatioHelperSignature {
Args: {
Named: {
max?: number;
Expand All @@ -12,7 +12,7 @@ interface CqAspectRatioHelperSignature {
Return: Metadata;
}

const CqAspectRatioHelper = helper<CqAspectRatioHelperSignature>(
const AspectRatioHelper = helper<AspectRatioHelperSignature>(
(_positional, named) => {
const dimension = 'aspectRatio';
const max = named.max ?? Infinity;
Expand All @@ -22,4 +22,4 @@ const CqAspectRatioHelper = helper<CqAspectRatioHelperSignature>(
}
);

export default CqAspectRatioHelper;
export default AspectRatioHelper;
6 changes: 3 additions & 3 deletions addon/helpers/cq-height.ts → addon/helpers/height.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { helper } from '@ember/component/helper';
import type { Metadata } from 'ember-container-query/modifiers/container-query';

interface CqHeightHelperSignature {
interface HeightHelperSignature {
Args: {
Named: {
max?: number;
Expand All @@ -12,12 +12,12 @@ interface CqHeightHelperSignature {
Return: Metadata;
}

const CqHeightHelper = helper<CqHeightHelperSignature>((_positional, named) => {
const HeightHelper = helper<HeightHelperSignature>((_positional, named) => {
const dimension = 'height';
const max = named.max ?? Infinity;
const min = named.min ?? 0;

return { dimension, max, min };
});

export default CqHeightHelper;
export default HeightHelper;
6 changes: 3 additions & 3 deletions addon/helpers/cq-width.ts → addon/helpers/width.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { helper } from '@ember/component/helper';
import type { Metadata } from 'ember-container-query/modifiers/container-query';

interface CqWidthHelperSignature {
interface WidthHelperSignature {
Args: {
Named: {
max?: number;
Expand All @@ -12,12 +12,12 @@ interface CqWidthHelperSignature {
Return: Metadata;
}

const CqWidthHelper = helper<CqWidthHelperSignature>((_positional, named) => {
const WidthHelper = helper<WidthHelperSignature>((_positional, named) => {
const dimension = 'width';
const max = named.max ?? Infinity;
const min = named.min ?? 0;

return { dimension, max, min };
});

export default CqWidthHelper;
export default WidthHelper;
15 changes: 9 additions & 6 deletions addon/template-registry.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import type ContainerQueryComponent from 'ember-container-query/components/container-query';
import type CqAspectRatioHelper from 'ember-container-query/helpers/cq-aspect-ratio';
import type CqHeightHelper from 'ember-container-query/helpers/cq-height';
import type CqWidthHelper from 'ember-container-query/helpers/cq-width';
import type AspectRatioHelper from 'ember-container-query/helpers/aspect-ratio';
import type HeightHelper from 'ember-container-query/helpers/height';
import type WidthHelper from 'ember-container-query/helpers/width';
import type ContainerQueryModifier from 'ember-container-query/modifiers/container-query';

export default interface EmberContainerQueryRegistry {
ContainerQuery: typeof ContainerQueryComponent;
'aspect-ratio': typeof AspectRatioHelper;
'container-query': typeof ContainerQueryModifier;
'cq-aspect-ratio': typeof CqAspectRatioHelper;
'cq-height': typeof CqHeightHelper;
'cq-width': typeof CqWidthHelper;
'cq-aspect-ratio': typeof AspectRatioHelper;
'cq-height': typeof HeightHelper;
'cq-width': typeof WidthHelper;
Comment on lines +11 to +13
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder

Remove these lines in the future pull request, which will remove {{cq-aspect-ratio}}, {{cq-height}}, and {{cq-width}} helpers.

height: typeof HeightHelper;
width: typeof WidthHelper;
}
1 change: 1 addition & 0 deletions app/helpers/aspect-ratio.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-container-query/helpers/aspect-ratio';
19 changes: 18 additions & 1 deletion app/helpers/cq-aspect-ratio.js
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
export { default } from 'ember-container-query/helpers/cq-aspect-ratio';
import { deprecate } from '@ember/debug';

deprecate(
'The {{cq-aspect-ratio}} helper has been renamed to {{aspect-ratio}}. Please update the helper name in your template.',
false,
{
for: 'ember-container-query',
id: 'ember-container-query.rename-cq-aspect-ratio-helper',
since: {
available: '3.2.0',
enabled: '3.2.0',
},
until: '4.0.0',
url: 'https://github.com/ijlee2/ember-container-query/tree/3.2.0#api',
}
);

export { default } from 'ember-container-query/helpers/aspect-ratio';
Comment on lines +1 to +18
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder

Remove these lines in the future pull request, which will remove {{cq-aspect-ratio}}, {{cq-height}}, and {{cq-width}} helpers.

19 changes: 18 additions & 1 deletion app/helpers/cq-height.js
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
export { default } from 'ember-container-query/helpers/cq-height';
import { deprecate } from '@ember/debug';

deprecate(
'The {{cq-height}} helper has been renamed to {{height}}. Please update the helper name in your template.',
false,
{
for: 'ember-container-query',
id: 'ember-container-query.rename-cq-height-helper',
since: {
available: '3.2.0',
enabled: '3.2.0',
},
until: '4.0.0',
url: 'https://github.com/ijlee2/ember-container-query/tree/3.2.0#api',
}
);

export { default } from 'ember-container-query/helpers/height';
Comment on lines +1 to +18
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder

Remove these lines in the future pull request, which will remove {{cq-aspect-ratio}}, {{cq-height}}, and {{cq-width}} helpers.

19 changes: 18 additions & 1 deletion app/helpers/cq-width.js
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
export { default } from 'ember-container-query/helpers/cq-width';
import { deprecate } from '@ember/debug';

deprecate(
'The {{cq-width}} helper has been renamed to {{width}}. Please update the helper name in your template.',
false,
{
for: 'ember-container-query',
id: 'ember-container-query.rename-cq-width-helper',
since: {
available: '3.2.0',
enabled: '3.2.0',
},
until: '4.0.0',
url: 'https://github.com/ijlee2/ember-container-query/tree/3.2.0#api',
}
);

export { default } from 'ember-container-query/helpers/width';
Comment on lines +1 to +18
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder

Remove these lines in the future pull request, which will remove {{cq-aspect-ratio}}, {{cq-height}}, and {{cq-width}} helpers.

1 change: 1 addition & 0 deletions app/helpers/height.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-container-query/helpers/height';
1 change: 1 addition & 0 deletions app/helpers/width.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from 'ember-container-query/helpers/width';
8 changes: 4 additions & 4 deletions tests/dummy/app/components/tracks.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<ContainerQuery
@features={{hash
small=(cq-width max=480)
medium=(cq-width min=480 max=640)
large=(cq-width min=640)
tall=(cq-height min=320)
small=(width max=480)
medium=(width min=480 max=640)
large=(width min=640)
tall=(height min=320)
}}
as |CQ|
>
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/components/ui/form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/>

<ContainerQuery
@features={{hash wide=(cq-width min=480)}}
@features={{hash wide=(width min=480)}}
as |CQ|
>
{{yield
Expand Down
6 changes: 3 additions & 3 deletions tests/dummy/app/components/widgets/widget-1.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<ContainerQuery
@features={{hash
tall=(cq-aspect-ratio max=0.8)
square=(cq-aspect-ratio min=0.8 max=1.25)
wide=(cq-aspect-ratio min=1.25)
tall=(aspect-ratio max=0.8)
square=(aspect-ratio min=0.8 max=1.25)
wide=(aspect-ratio min=1.25)
}}
@tagName="section"
local-class="container"
Expand Down
6 changes: 3 additions & 3 deletions tests/dummy/app/components/widgets/widget-2.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<ContainerQuery
@features={{hash
short=(cq-height max=240)
tall=(cq-height min=240 max=480)
very-tall=(cq-height min=480)
short=(height max=240)
tall=(height min=240 max=480)
very-tall=(height min=480)
}}
@tagName="section"
local-class="container"
Expand Down
5 changes: 1 addition & 4 deletions tests/dummy/app/components/widgets/widget-2/captions.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<ContainerQuery
@features={{hash
large=(cq-width min=320)
tall=(cq-height min=80)
}}
@features={{hash large=(width min=320) tall=(height min=80)}}
as |CQ|
>
<div
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ContainerQuery
@features={{hash small=(cq-width max=400)}}
@features={{hash small=(width max=400)}}
@dataAttributePrefix="cq"
local-class="container"
>
Expand Down
6 changes: 3 additions & 3 deletions tests/dummy/app/components/widgets/widget-4/memo.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<ContainerQuery
@features={{hash
small=(cq-width max=200)
large=(cq-width min=200)
short=(cq-height max=200)
small=(width max=200)
large=(width min=200)
short=(height max=200)
}}
@tagName="article"
local-class="container"
Expand Down
5 changes: 1 addition & 4 deletions tests/dummy/app/components/widgets/widget-5.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<ContainerQuery
@features={{hash
large=(cq-width min=224)
tall=(cq-height min=120)
}}
@features={{hash large=(width min=224) tall=(height min=120)}}
@tagName="section"
local-class="container"
as |CQ|
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/album.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<Ui::Page @title={{@model.name}}>
<ContainerQuery
@features={{hash
large=(cq-width min=960)
tall=(cq-height min=400)
large=(width min=960)
tall=(height min=400)
}}
as |CQ|
>
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/app/templates/not-found.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div local-class="animation">
<ContainerQuery
@features={{hash small=(cq-width max=350)}}
@features={{hash small=(width max=350)}}
as |CQ|
>
<div
Expand Down
Loading