Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 39c78be

Browse files
CaerusKaruThomasBurleson
authored andcommitted
feat(docs): add ability to submit PRs for docs
* Add feature to release script that will publish new docs to the Wiki on each release * Add documentation directory to the repo so that contributors can update the Wiki as necessary > Many thanks to the Angular CLI team for developing the code we are using! 👍 Fixes #550, #520.
1 parent c0ea21f commit 39c78be

38 files changed

+2523
-12
lines changed

docs/design/grid-layout.md

Whitespace-only changes.

docs/design/ssr-gen.md

Whitespace-only changes.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
2+
## JavaScript API (Imperative)
3+
4+
Most of the **@angular/flex-layout** functionality is provided via Directives used **declaratively** in template HTML. There are three (3) programmatic features, however, that are published for programmatic usages:
5+
6+
* **[ObservableMedia](https://github.com/angular/flex-layout/wiki/ObservableMedia)**: <br/> Injectable Observable used to subscribe to MediaQuery activation changes.<br/>
7+
`constructor(public media:ObservableMedia ) { ... }`
8+
9+
* **[BREAKPOINTS](https://github.com/angular/flex-layout/wiki/BreakPoints)**: <br/> Opaque token used to override or extend the default breakpoints with custom MediaQuery breakpoints.<br/> `providers: [{provide: BREAKPOINTS, useValue: MY_CUSTOM_BREAKPOINTS }]`
10+
11+
* **[BaseFxDirectiveAdapter](https://github.com/angular/flex-layout/wiki/BaseFxDirectiveAdapter)**: <br/> Adapter class useful to extend existing Directives with MediaQuery activation features. <br/> `export class ClassDirective extends NgClass { ... }`
12+
13+
<br/>
14+
15+
## HTML API (Declarative)
16+
17+
The features of Flex-Layout are best used, however, declaratively in template HTML. This API has two (2) significant feature sets:
18+
19+
* **[Static API](https://github.com/angular/flex-layout/wiki/Declarative-API-Overview)**: Summary of static API features.<br/>
20+
* **[Responsive API](https://github.com/angular/flex-layout/wiki/Responsive-API)**: Introducing Responsive API and BreakPoints details.<br/>
21+
22+
As each directive (aka API) within **@angular/flex-layout** has its own constraints and options, the links below should be used to navigate to the specific the documentation pages for each directive.
23+
24+
<br/>
25+
26+
### Containers
27+
28+
This API set applies flexbox CSS stylings for DOM **container elements** with 1 or more nested flex children:
29+
30+
* [**fxLayout**](https://github.com/angular/flex-layout/wiki/fxLayout-API): <br/>Defines the flow order of child items within a flexbox container.<br/>`<div fxLayout="row" fxLayout.xs="column"> </div>`<br/>&nbsp;
31+
* **[fxLayoutWrap](https://github.com/angular/flex-layout/wiki/fxLayoutWrap-API)** : <br/>Defines if child items appear on a single line or on multiple lines within a flexbox container.<br/>`<div fxLayoutWrap> </div>`<br/>&nbsp;
32+
* **[fxLayoutGap](https://github.com/angular/flex-layout/wiki/fxLayoutGap-API)**:<br/>Defines if child items within a flexbox container should have a gap. <br/>`<div fxLayoutGap="10px"> </div>`<br/>&nbsp;
33+
* **[fxLayoutAlign](https://github.com/angular/flex-layout/wiki/fxLayoutAlign-API)**:<br/>Defines how flexbox items are aligned according to both the main-axis and the cross-axis, within a flexbox container. <br/>`<div fxLayoutAlign="start stretch"> </div>`
34+
35+
36+
<br/>
37+
38+
### Child Elements within Containers
39+
40+
This API set applies flexbox CSS stylings for a DOM element nested within FlexBox DOM container:
41+
42+
* **[fxFlex](https://github.com/angular/flex-layout/wiki/fxFlex-API)**: <br/>This markup specifies the resizing of its host element within a flexbox container flow.<br/>`<div fxFlex="1 2 calc(15em + 20px)"></div>`
43+
44+
* **[fxFlexOrder](https://github.com/angular/flex-layout/wiki/fxFlexOrder-API)**: <br/>Defines the order of a flexbox item. <br/>`<div fxFlexOrder="2"></div>`
45+
46+
* **[fxFlexOffset](https://github.com/angular/flex-layout/wiki/fxFlexOffset-API)**: <br/>Offset a flexbox item in its parent container flow layout. <br/>`<div fxFlexOffset="20px"></div>`
47+
48+
* **[fxFlexAlign](https://github.com/angular/flex-layout/wiki/fxFlexAlign-API)**: <br/>Works like fxLayoutAlign, but applies only to a single flexbox item, instead of all of them. <br/>`<div fxFlexAlign="center"></div>`
49+
50+
* **[fxFlexFill](https://github.com/angular/flex-layout/wiki/fxFlexFill-API)**: <br/> Maximizes width and height of element in a layout container <br/>`<div fxFlexFill></div>`
51+
52+
53+
<br/>
54+
55+
### Special Responsive Features
56+
57+
While the following APIs also add or remove DOM element inline styles, they are NOT FlexBox CSS specific.
58+
59+
Instead these are **Responsive** APIs used to adjust specific, non-flexbox styles when a specific mediaQuery has activated:
60+
61+
* **[fxShow](https://github.com/angular/flex-layout/wiki/fxShow-API)**: <br/>This markup specifies if its host element should be displayed (or not).<br/>`<div fxShow [fxShow.xs]="isVisibleOnMobile()"></div>`
62+
63+
* **[fxHide](https://github.com/angular/flex-layout/wiki/fxHide-API)**: <br/>This markup specifies if its host element should NOT be displayed.<br/>`<div fxHide [fxHide.gt-sm]="isVisibleOnDesktop()"></div>`
64+
65+
66+
* **[ngClass](https://github.com/angular/flex-layout/wiki/ngClass-API)** :
67+
<br/>Enhances the **ngClass** directives with class changes based on mediaQuery activations. <br/>`<div [ngClass.sm]="{'fxClass-sm': hasStyle}"></div>`.
68+
69+
* **[ngStyle](https://github.com/angular/flex-layout/wiki/ngStyle-API)**:
70+
<br/>Enhances the **ngStyle** directive with style updates based on mediaQuery activations. <br/>`<div [ngStyle.xs]="{'font-size.px': 10, color: 'blue'}"></div>`
71+
72+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Several Angular Material 1 applications: **[Material-Adaptive](https://github.com/angular/material-adaptive/tree/master/shrine)** have been implemented using custom Flexbox CSS. These efforts illustrated the needs and features within a responsive, adaptive application.
2+
3+
* [Pesto](https://material-adaptive.firebaseapp.com/pesto/app/dist.html#/home)
4+
* [Shring](https://material-adaptive.firebaseapp.com/shrine/app/dist.html)
5+
6+
![screen shot 2016-11-05 at 7 26 56 am](https://cloud.githubusercontent.com/assets/210413/20029970/44c16d64-a329-11e6-9a9a-bd00561ea936.png)
7+
8+
Different from responsive layouts where components change sizes and positions, the concepts of Adaptive layouts
9+
provide for UX where **different components** may be used for different breakpoints.
10+
11+
Animations can also be extended to support MediaQuery activations: different animations will run for different viewport sizes.
12+
13+
Developers can use the following directives to achieve some Adaptive UX goals:
14+
15+
* `fxHide`
16+
* `fxShow`
17+
* `ngIf`
18+
19+
For examples of `fx-hide` usages in Adaptive layouts, please review the demo **Show & Hide Directives**:
20+
21+
* [Demo](https://tburleson-layouts-demos.firebaseapp.com/#/responsive)
22+
* [Source](https://github.com/angular/flex-layout/blob/master/src/demo-app/app/docs-layout-responsive/responsiveShowHide.demo.ts#L15)
23+
24+
----
25+
26+
#### Core Directives + Responsive Features
27+
28+
Responsive features for core Angular directives:
29+
30+
* `[ngStyle.<alias>]=""`
31+
* `[ngClass.<alias>]=""`
32+
* `*ngIf.<breakpoint alias>=""` is not yet supported.
33+
34+
Here is the current solution solution to enabled responsive/adaptive features with **`*ngIf`**:
35+
36+
```js
37+
import {ObservableMedia} from '@angular/flex-layout';
38+
39+
@Component({
40+
selector : 'my-mobile-component',
41+
template : `
42+
<div *ngIf="media.isActive('xs')">
43+
This content is only shown on Mobile devices
44+
</div>
45+
<footer>
46+
Current state: {{ }}
47+
</footer>
48+
`
49+
})
50+
export class MyMobileComponent {
51+
public state = '';
52+
constructor(public media:ObservableMedia ) {
53+
media.asObservable()
54+
.subscribe((change:MediaChange) => {
55+
this.state = change ? `'${change.mqAlias}' = (${change.mediaQuery})` : ""
56+
});
57+
}
58+
}
59+
```
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
The [Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html) is the
2+
basis for our coding style, with additional guidance here where that style guide is not aligned with
3+
ES6 or TypeScript.
4+
5+
## Coding practices
6+
7+
### General
8+
9+
#### Write useful comments
10+
Comments that explain what some block of code does are nice; they can tell you something in less time than it would take to follow through the code itself.
11+
12+
Comments that explain why some block of code exists at all, or does something the way it does,
13+
are _invaluable_. The "why" is difficult, or sometimes impossible, to track down without seeking out
14+
the original author. When collaborators are in the same room, this hurts productivity.
15+
When collaborators are in different timezones, this can be devastating to productivity.
16+
17+
For example, this is a not-very-useful comment:
18+
```ts
19+
// Set default tabindex.
20+
if (!$attrs['tabindex']) {
21+
$element.attr('tabindex', '-1');
22+
}
23+
```
24+
25+
While this is much more useful:
26+
```ts
27+
// Unless the user specifies so, the calendar should not be a tab stop.
28+
// This is necessary because ngAria might add a tabindex to anything with an ng-model
29+
// (based on whether or not the user has turned that particular feature on/off).
30+
if (!$attrs['tabindex']) {
31+
$element.attr('tabindex', '-1');
32+
}
33+
```
34+
35+
#### Prefer more focused, granular components vs. complex, configurable components.
36+
37+
For example, rather than doing this:
38+
```html
39+
<md-button>Basic button</md-button>
40+
<md-button class="md-fab">FAB</md-button>
41+
<md-button class="md-icon-button">pony</md-button>
42+
```
43+
44+
do this:
45+
```html
46+
<md-button>Basic button</md-button>
47+
<md-fab>FAB</md-fab>
48+
<md-icon-button>pony</md-icon-button>
49+
```
50+
51+
#### Prefer small, focused modules
52+
Keeping modules to a single responsibility makes the code easier to test, consume, and maintain.
53+
ES6 modules offer a straightforward way to organize code into logical, granular units.
54+
Ideally, individual files are 200 - 300 lines of code.
55+
56+
#### Less is more
57+
Once a feature is released, it never goes away. We should avoid adding features that don't offer
58+
high user value for price we pay both in maintenance, complexity, and payload size. When in doubt,
59+
leave it out.
60+
61+
This applies especially so to providing two different APIs to accomplish the same thing. Always
62+
prefer sticking to a _single_ API for accomplishing something.
63+
64+
### TypeScript
65+
66+
#### Provide function descriptions
67+
For functions that are more complicated than a simple getter/setter, provide at least a brief
68+
sentence explaining what the function does and/or _why_ it does something.
69+

docs/documentation/Background.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
### Background
2+
3+
The primary idea behind the flexbox layout is to give HTML DOM elements the ability to alter their width/height (and order) to best fill the available space... to *reflow* and *layout* for different kinds of display devices and different screen sizes.
4+
5+
More importantly, flexbox css is direction-agnostic as opposed to the regular layouts (block which is vertically-based and inline which is horizontally-based). While those work well for some pages, they lack flexibility to support large or complex applications: especially when it comes to orientation changing, resizing, stretching, shrinking, etc. Especially important are *flex* features that resize elements to intelligently fill available spaces. A flex container expands items to fill available free space, or shrinks them to prevent overflow.
6+
7+
Now let's add these complexities the requirements that developers often want combine the CSS Flexbox API with CSS media queries in order to support responsive layouts. e.g.
8+
9+
10+
<a href="" target="_blank">
11+
<img src="https://cloud.githubusercontent.com/assets/210413/20029960/fbbc0e62-a328-11e6-8045-c6532affc857.png">
12+
</a>
13+
14+
<br/>
15+
16+
Unfortunately, developers manually implementing Flexbox CSS must become experts at both the syntax and the workarounds to accommodate browser-specific differences in Flexbox runtime support.
17+
18+
Several Angular Material 1 applications: **[Material-Adaptive](https://github.com/angular/material-adaptive/tree/master/shrine)** have been implemented using custom Flexbox CSS. These efforts illustrated the needs and features within a responsive, adaptive application.
19+
20+
* [Pesto](https://material-adaptive.firebaseapp.com/pesto/app/dist.html#/home)
21+
* [Shring](https://material-adaptive.firebaseapp.com/shrine/app/dist.html)
22+
23+
![screen shot 2016-11-05 at 7 26 56 am](https://cloud.githubusercontent.com/assets/210413/20029970/44c16d64-a329-11e6-9a9a-bd00561ea936.png)
24+
25+
These additional feature ideas - derived from real-world Application implementations - have now been implemented within the Angular Flex-Layout library. Here are some of this libraries more notable features:
26+
27+
* Direct DOM element CSS style injections
28+
* Distinct responsive engine (MediaQuery change notifications with adapters)
29+
* Subscription process for adaptive notifications to trigger custom Layout processes
30+

docs/documentation/BreakPoints.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
The token **BREAKPOINTS** is an opaque token in **@angular/flex-layout** that is used to build a **Provider** for a raw list of breakpoints.
2+
3+
```js
4+
import {OpaqueToken} from '@angular/core';
5+
6+
export const BreakPointsProvider = {
7+
provide: BREAKPOINTS,
8+
useValue: DEFAULT_BREAKPOINTS
9+
};
10+
```
11+
12+
```js
13+
@NgModule({
14+
providers: [
15+
BreakPointsProvider, // Supports developer overrides of list of known breakpoints
16+
// BreakPointRegistry, // Registry of known/used BreakPoint(s)
17+
// MatchMedia, // Low-level service to publish observables w/ window.matchMedia()
18+
// MediaMonitor, // MediaQuery monitor service observes all known breakpoints
19+
// ObservableMediaProvider // easy subscription injectable `media$` matchMedia observable
20+
]
21+
})
22+
export class MediaQueriesModule {
23+
}
24+
```
25+
26+
This provider is used to return a list to ALL known BreakPoint(s)... and, in turn, this list is used internally to register mediaQueries and announce mediaQuery activations.
27+
28+
29+
### Custom BreakPoints
30+
31+
Using the **BREAKPOINTS** OpaqueToken, developers can add custom breakpoints or easily override existing breakpoints.
32+
33+
For example to add mediaQueries that activate when printing:
34+
35+
##### - `custom-breakpoints.ts` -
36+
37+
```js
38+
import {DEFAULT_BREAKPOINTS} from '@angular/flex-layout';
39+
40+
const PRINT_BREAKPOINTS = [{
41+
alias: 'xs.print',
42+
suffix: 'XsPrint',
43+
mediaQuery: 'print and (max-width: 297px)',
44+
overlapping: false
45+
}];
46+
47+
export const CustomBreakPointsProvider = {
48+
provide: BREAKPOINTS,
49+
useValue: [...DEFAULT_BREAKPOINTS,...PRINT_BREAKPOINTS];
50+
};
51+
```
52+
53+
##### - `my-app-module.ts` -
54+
55+
```js
56+
import { CustomBreakPointsProvider } from 'custom-breakpoints.ts';
57+
58+
@NgModule({
59+
imports : [
60+
CommonModule,
61+
FlexLayoutModule,
62+
]
63+
providers: [
64+
CustomBreakPointsProvider, // Adds breakpoints for 'print' mediaQueries
65+
]
66+
})
67+
export class MyAppModule {
68+
}
69+
```
70+
71+
With the above changes, when printing on mobile-sized viewports the **`xs.print`** mediaQuery will activate.
72+
73+
### Custom Breakpoints and Directives
74+
75+
It must be noted that simply registering custom breakpoints will not automatically mean that Flex-Layout API will support those as selectors.
76+
77+
In the above example the custom Breakpoint has been registered, but HTML selectors for **`xs.print`** will not work automatically. Consider the scenario below where some content should be hidden while printing and other content has different layouts while printing:
78+
79+
```html
80+
<section
81+
class="main"
82+
fxShow
83+
fxHide.xs.print="true">
84+
...
85+
</section>
86+
87+
<footer
88+
fxLayout="row"
89+
fxLayout.xs.print="column">
90+
...
91+
</section>
92+
```
93+
94+
> Notice the use of 'xs.print' alias in the selectors above ^.
95+
96+
To enable these custom, **responsive selectors**, developers must **extend** the `ShowHideDirective` and the `LayoutDirective`.
97+
98+
e.g.
99+
100+
```js
101+
import { ShowHideDirective, negativeOf } from '@angular/flex-layout';
102+
103+
@Directive({selector: `
104+
[fxHide.xs.print]
105+
`})
106+
export class CustomShowHideDirective extends ShowHideDirective {
107+
constructor(monitor: MediaMonitor, elRef: ElementRef, renderer: Renderer) {
108+
super(monitor, elRef, renderer);
109+
}
110+
111+
@Input('fxHide.xs.print') set hideXs(val) {
112+
this._cacheInput("showXsPrint", negativeOf(val));
113+
}
114+
}
115+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<a href="http://caniuse.com/#feat=flexbox" target="_blank">
2+
<img src="https://cloud.githubusercontent.com/assets/210413/21288118/917e3faa-c440-11e6-9b08-28aff590c7ae.png">
3+
</a>
4+

docs/documentation/Code-reviews.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Below are the team standards for Flex-Layout Code reviews:
2+
3+
* Before any coding begins on new, large, or breaking work, a design discussion should take place.
4+
* All code changes require a review and approval.
5+
* All behaviors should be covered by unit tests in the same PR.
6+
* Large changes should be accompanied by corresponding e2e tests in the same PR.
7+
* Authors should attempt to keep PRs to 200 - 300 line changes.
8+
9+
## Workflow
10+
1. The code author sends a PR for review. This request should include:
11+
* A mention of the intended reviewer(s) (e.g., `@thomasburleson`)
12+
* A high-level description of the change being made.
13+
* Links to any relevant issues.
14+
* Screenshots (for visual changes or new additions)
15+
2. Reviews provide comments and the author responds / makes changes. Repeat until LGTM.
16+
3. One or more of the reviewers applies the "LGTM" label.
17+
4. The party responsible for merging PRs will do so.

0 commit comments

Comments
 (0)