-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
166 additions
and
120 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,26 +1,18 @@ | ||
import Component from '@glimmer/component'; | ||
import { CallbackArgs, Sizes, Dimension } from './modifier'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { action } from '@ember/object'; | ||
import { ComponentArgs, EQInfo } from 'ember-element-query'; | ||
|
||
interface ElementQueryArgs { | ||
dimension?: Dimension; | ||
isDisabled?: boolean; | ||
prefix?: string; | ||
sizes?: Sizes; | ||
sizesHeight?: Sizes | true; | ||
onResize?: (params: CallbackArgs) => void; | ||
} | ||
export default class ElementQuery extends Component<ElementQueryArgs> { | ||
export default class ElementQuery extends Component<ComponentArgs> { | ||
@tracked | ||
params?: CallbackArgs; | ||
eqInfo?: EQInfo; | ||
|
||
@action | ||
onResize(params: CallbackArgs): void { | ||
this.params = params; | ||
onResize(eqInfo: EQInfo): void { | ||
this.eqInfo = eqInfo; | ||
|
||
if (this.args.onResize) { | ||
this.args.onResize(params); | ||
this.args.onResize(eqInfo); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { ModifierArgs as ModifierArgsBase } from 'ember-modifier'; | ||
|
||
export { default as component } from './-private/component'; | ||
export { default as modifier } from './-private/modifier'; | ||
|
||
export type Dimension = 'width' | 'height' | 'both'; | ||
|
||
export type Sizes = Record<string, number>; | ||
|
||
export interface EQInfo { | ||
element: HTMLElement; | ||
width: number; | ||
height: number; | ||
ratio: number; | ||
size?: string; | ||
sizeHeight?: string; | ||
dimension: Dimension; | ||
prefix?: string; | ||
attributes: string[]; | ||
attributesRecord: Record<string, true>; | ||
} | ||
|
||
export interface ModifierArgs extends ModifierArgsBase { | ||
positional: []; | ||
named: { | ||
onResize?: (eqInfo: EQInfo) => void; | ||
sizes?: Sizes; | ||
sizesHeight?: Sizes; | ||
prefix?: string; | ||
dimension?: Dimension; | ||
isDisabled?: boolean; | ||
}; | ||
} | ||
|
||
export interface ComponentArgs { | ||
dimension?: Dimension; | ||
isDisabled?: boolean; | ||
prefix?: string; | ||
sizes?: Sizes; | ||
sizesHeight?: Sizes | true; | ||
onResize?: (eqInfo: EQInfo) => void; | ||
} | ||
|
||
// prettier-ignore | ||
export const SIZES_DEFAULT: Sizes = { | ||
xxs: 0, | ||
xs: 200, | ||
s: 400, | ||
m: 600, | ||
l: 800, | ||
xl: 1000, | ||
xxl: 1200, | ||
xxxl: 1400, | ||
}; | ||
|
||
// prettier-ignore | ||
export const SIZES_HEIGHT_DEFAULT: Sizes = { | ||
'xxs-height': 0, | ||
'xs-height': 200, | ||
's-height': 400, | ||
'm-height': 600, | ||
'l-height': 800, | ||
'xl-height': 1000, | ||
'xxl-height': 1200, | ||
'xxxl-height': 1400, | ||
}; |
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
Oops, something went wrong.