igniteui-angular-sovn
Version:
Ignite UI for Angular is a dependency-free Angular toolkit for building modern web apps
237 lines (218 loc) • 5.76 kB
text/typescript
import { Directive, HostBinding, Input } from '@angular/core';
export class IgxLayoutDirective {
/**
* Sets the default flow direction of the container's children.
*
* Defaults to `rows`.
*
* ```html
* <div
* igxLayout
* igxLayoutDir="row">
* <div igxFlex>1</div>
* <div igxFlex>2</div>
* <div igxFlex>3</div>
* </div>
* ```
*/
public dir = 'row';
/**
* Defines the direction flex children are placed in the flex container.
*
* When set to `true`, the `rows` direction goes right to left and `columns` goes bottom to top.
*
* ```html
* <div
* igxLayout
* igxLayoutReverse="true">
* <div igxFlex>1</div>
* <div igxFlex>2</div>
* <div igxFlex>3</div>
* </div>
* ```
*/
public reverse = false;
/**
* By default the immediate children will all try to fit onto one line.
*
* The default value `nowrap` sets this behavior.
*
* Other accepted values are `wrap` and `wrap-reverse`.
*
* ```html
* <div
* igxLayout
* igxLayoutDir="row"
* igxLayoutWrap="wrap">
* <div igxFlex igxFlexGrow="0">1</div>
* <div igxFlex igxFlexGrow="0">2</div>
* <div igxFlex igxFlexGrow="0">3</div>
* </div>
* ```
*/
public wrap = 'nowrap';
/**
* Defines the alignment along the main axis.
*
* Defaults to `flex-start` which packs the children toward the start line.
*
* Other possible values are `flex-end`, `center`, `space-between`, `space-around`.
*
* ```html
* <div
* igxLayout
* igxLayoutDir="column"
* igxLayoutJustify="space-between">
* <div>1</div>
* <div>2</div>
* <div>3</div>
* </div>
* ```
*/
public justify = 'flex-start';
/**
* Defines the default behavior for how children are laid out along the corss axis of the current line.
*
* Defaults to `flex-start`.
*
* Other possible values are `flex-end`, `center`, `baseline`, and `stretch`.
*
* ```html
* <div
* igxLayout
* igxLayoutDir="column"
* igxLayoutItemAlign="start">
* <div igxFlex igxFlexGrow="0">1</div>
* <div igxFlex igxFlexGrow="0">2</div>
* <div igxFlex igxFlexGrow="0">3</div>
* </div>
* ```
*/
public itemAlign = 'stretch';
/**
* @hidden
*/
public display = 'flex';
/**
* @hidden
*/
public get flexwrap() {
return this.wrap;
}
/**
* @hidden
*/
public get justifycontent() {
return this.justify;
}
/**
* @hidden
*/
public get align() {
return this.itemAlign;
}
/**
* @hidden
*/
public get direction() {
if (this.reverse) {
return (this.dir === 'row') ? 'row-reverse' : 'column-reverse';
}
return (this.dir === 'row') ? 'row' : 'column';
}
}
export class IgxFlexDirective {
/**
* Applies the `grow` attribute to an element that uses the directive.
*
* Default value is `1`.
*
* ```html
* <div>
* <div igxFlex igxFlexGrow="0">Content1</div>
* <div igxFlex igxFlexGrow="1">Content2</div>
* <div igxFlex igxFlexGrow="0">Content3</div>
* </div>
* ```
*/
public grow = 1;
/**
* Applies the `shrink` attribute to an element that uses the directive.
*
* Default value is `1`.
*
* ```html
* <div>
* <div igxFlex igxFlexShrink="1">Content1</div>
* <div igxFlex igxFlexShrink="0">Content2</div>
* <div igxFlex igxFlexShrink="1">Content3</div>
* </div>
* ```
*/
public shrink = 1;
/**
* Applies the directive to an element.
*
* Possible values include `igxFlexGrow`, `igxFlexShrink`, `igxFlexOrder`, `igxFlexBasis`.
*
* ```html
* <div igxFlex>Content</div>
* ```
*/
public flex = '';
/**
* Applies the `order` attribute to an element that uses the directive.
*
* Default value is `0`.
*
* ```html
* <div>
* <div igxFlex igxFlexOrder="1">Content1</div>
* <div igxFlex igxFlexOrder="0">Content2</div>
* <div igxFlex igxFlexOrder="2">Content3</div>
* </div>
* ```
*/
public order = 0;
/**
* Applies the `flex-basis` attribute to an element that uses the directive.
*
* Default value is `auto`.
*
* Other possible values include `content`, `max-content`, `min-content`, `fit-content`.
*
* ```html
* <div igxFlex igxFlexBasis="fit-content">Content</div>
* ```
*/
public basis = 'auto';
/**
* @hidden
*/
public get style() {
if (this.flex) {
return `${this.flex}`;
}
return `${this.grow} ${this.shrink} ${this.basis}`;
}
/**
* @hidden
*/
public get itemorder() {
return this.order || 0;
}
}