Skip to content

fix: 🐛 Update variable declaration in Window example #100

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

Merged
merged 3 commits into from
Dec 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## Unreleased

- `documentation` fixed the `utils/window` example

### 2018-12-11

- `documentation` fixed some issue with the documentation
Expand Down
15 changes: 7 additions & 8 deletions packages/utils/examples/src/utils/pages/window/window.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ <h2 class="h4 u-margin-bottom">Window</h2>
<aui-code-snippet [codeSnippet]="codeExampleJS2"></aui-code-snippet>
</div>

<div class="u-margin-bottom">
<aui-code-snippet [codeSnippet]="codeExampleJS3"></aui-code-snippet>
</div>

<div class="u-margin-bottom">
<aui-code-snippet [codeSnippet]="codeExampleHTML"></aui-code-snippet>
</div>

<p class="u-margin-bottom-xs">
These are the window's current height and width:
</p>
<dl class="a-definition-list u-margin-bottom">
<dt>innerWidth:</dt>
<dd><pre>{{ windowObject.innerWidth }}</pre></dd>
<dt>innerHeight:</dt>
<dd><pre>{{ windowObject.innerHeight }}</pre></dd>
<dt>Height:</dt>
<dd><pre>{{ window?.innerHeight }}</pre></dd>
<dt>Width:</dt>
<dd><pre>{{ window?.innerWidth }}</pre></dd>
</dl>
46 changes: 11 additions & 35 deletions packages/utils/examples/src/utils/pages/window/window.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,9 @@ import { WINDOW } from '@acpaas-ui/ngx-components/utils';

@Component({
templateUrl: './window.page.html',
// fix for `@Inject` and global interface type
// https://github.com/angular/angular/issues/15640
providers: [
{
provide: WINDOW,
useValue: window,
},
],
})
export class UtilsWindowDemoPageComponent {
windowObject: Window;

public importModule = `import { WindowModule } from '@acpaas-ui/ngx-components/utils';
public importModule = `import { WindowModule, WINDOW_PROVIDERS } from '@acpaas-ui/ngx-components/utils';';

@NgModule({
imports: [
Expand All @@ -28,31 +18,17 @@ export class AppModule {};`;

public codeExampleJS1 = `import { WINDOW } from '@acpaas-ui/ngx-components/utils';`;

public codeExampleJS2 = `@Component({
templateUrl: './window.page.html',
// fix for @Inject and global interface type
// https://github.com/angular/angular/issues/15640
providers: [
{
provide: WINDOW,
useValue: window,
},
],
})`;

public codeExampleJS3 = `windowObject: Window;
constructor(@Inject(WINDOW) private window) {
this.windowObject = window;
}`;
public codeExampleJS2 = `constructor(
@Inject(WINDOW) public window
) {}`;

public codeExampleHTML = `<dl>
<dt>innerWidth:</dt>
<dd>{{ windowObject.innerWidth }}</dd>
<dt>innerHeight:</dt>
<dd>{{ windowObject.innerHeight }}</dd>
<dt>Height:</dt>
<dd><pre>{{ window.innerHeight }}</pre></dd>
<dt>Width:</dt>
<dd><pre>{{ window.innerWidth }}</pre></dd>
</dl>`;

constructor(@Inject(WINDOW) private window) {
this.windowObject = window;
}
constructor(
@Inject(WINDOW) public window
) {}
}
2 changes: 2 additions & 0 deletions packages/utils/examples/src/utils/utils.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
FilterModule,
LabelsModule,
WindowModule,
WINDOW_PROVIDERS,
} from '@acpaas-ui/ngx-components/utils';
import { CodeSnippetModule } from '@acpaas-ui/ngx-components/code-snippet';

Expand All @@ -24,5 +25,6 @@ import { Pages } from './pages/index';
declarations: [
Pages,
],
providers: [WINDOW_PROVIDERS],
})
export class UtilsExamplesModule {}
31 changes: 8 additions & 23 deletions packages/utils/lib/src/window/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Visit our [documentation site](https://acpaas-ui.digipolis.be/) for full how-to
### Example

```typescript
import { WindowModule } from '@acpaas-ui/ngx-components/utils';
import { WindowModule, WINDOW_PROVIDERS } from '@acpaas-ui/ngx-components/utils';

@NgModule({
imports: [
Expand All @@ -33,32 +33,17 @@ import { WINDOW } from '@acpaas-ui/ngx-components/utils';
```

```typescript
@Component({
templateUrl: './window.page.html',
// fix for @Inject and global interface type
// https://github.com/angular/angular/issues/15640
providers: [
{
provide: WINDOW,
useValue: window,
},
],
})
```

```typescript
windowObject: Window;
constructor(@Inject(WINDOW) private window) {
this.windowObject = window;
}
constructor(
@Inject(WINDOW) public window
) {}
```

```html
<dl>
<dt>innerWidth:</dt>
<dd>{{ windowObject.innerWidth }}</dd>
<dt>innerHeight:</dt>
<dd>{{ windowObject.innerHeight }}</dd>
<dt>Height:</dt>
<dd><pre>{{ window.innerHeight }}</pre></dd>
<dt>Width:</dt>
<dd><pre>{{ window.innerWidth }}</pre></dd>
</dl>
```

Expand Down