Skip to content

Commit f09585c

Browse files
authored
Merge pull request #3 from tutkli/next
next
2 parents 4089c81 + 25e6390 commit f09585c

40 files changed

+11496
-7254
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.eslintrc.json

Lines changed: 0 additions & 42 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ Thumbs.db
4040

4141
.angular
4242

43-
.nx/cache
43+
.nx/cache
44+
.nx/workspace-data

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.9.0
1+
20.12.2

.prettierignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/coverage
44
.angular
55

6-
/.nx/cache
6+
/.nx/cache
7+
/.nx/workspace-data

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"arrowParens": "avoid",
88
"trailingComma": "es5",
99
"bracketSameLine": true,
10+
"htmlWhitespaceSensitivity": "ignore",
1011
"printWidth": 80,
1112
"endOfLine": "auto",
12-
"plugins": ["prettier-plugin-tailwindcss"]
13+
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-tailwindcss"]
1314
}

README.md

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,38 @@ import {
1818
observeBreakpoints,
1919
} from 'ngx-breakpoint-observer';
2020

21-
const breakpoints = observeBreakpoints(breakpointsTailwind);
22-
23-
const smAndLarger = breakpoints.greaterOrEqual('sm'); // sm and larger
24-
const largerThanSm = breakpoints.greater('sm'); // only larger than sm
25-
const lgAndSmaller = breakpoints.smallerOrEqual('lg'); // lg and smaller
26-
const smallerThanLg = breakpoints.smaller('lg'); // only smaller than lg
21+
@Component({})
22+
export class AppComponent {
23+
breakpoints = observeBreakpoints(breakpointsTailwind);
24+
25+
reactiveStuff = signal<keyof typeof breakpointsTailwind>('sm');
26+
isGreaterThanSignal = this.breakpoints.greaterOrEqual(this.reactiveStuff); // use signal without calling it!
27+
28+
smAndLarger = this.breakpoints.greaterOrEqual('sm'); // sm and larger
29+
largerThanSm = this.breakpoints.greater('sm'); // only larger than sm
30+
lgAndSmaller = this.breakpoints.smallerOrEqual('lg'); // lg and smaller
31+
smallerThanLg = this.breakpoints.smaller('lg'); // only smaller than lg
32+
}
2733
```
2834

2935
```ts
3036
import { observeBreakpoints } from 'ngx-breakpoint-observer';
3137

32-
const breakpoints = observeBreakpoints({
33-
tablet: 640,
34-
laptop: 1024,
35-
desktop: 1280,
36-
});
37-
38-
const laptop = breakpoints.between('laptop', 'desktop');
38+
@Component({})
39+
export class AppComponent {
40+
breakpoints = observeBreakpoints({
41+
mobile: 0, // optional
42+
tablet: 640,
43+
laptop: 1024,
44+
desktop: 1280,
45+
});
46+
47+
// Can be 'mobile' or 'tablet' or 'laptop' or 'desktop'
48+
activeBreakpoint = this.breakpoints.active();
49+
50+
// true or false
51+
laptop = this.breakpoints.between('laptop', 'desktop');
52+
}
3953
```
4054

4155
## License

apps/demo/.eslintrc.json

Lines changed: 0 additions & 38 deletions
This file was deleted.

apps/demo/eslint.config.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const { FlatCompat } = require('@eslint/eslintrc');
2+
const baseConfig = require('../../eslint.config.js');
3+
const js = require('@eslint/js');
4+
5+
const compat = new FlatCompat({
6+
baseDirectory: __dirname,
7+
recommendedConfig: js.configs.recommended,
8+
});
9+
10+
module.exports = [
11+
...baseConfig,
12+
...compat
13+
.config({
14+
extends: [
15+
'plugin:@nx/angular',
16+
'plugin:@angular-eslint/template/process-inline-templates',
17+
],
18+
})
19+
.map(config => ({
20+
...config,
21+
files: ['**/*.ts'],
22+
rules: {
23+
...config.rules,
24+
'@angular-eslint/directive-selector': [
25+
'error',
26+
{
27+
type: 'attribute',
28+
prefix: 'demo',
29+
style: 'camelCase',
30+
},
31+
],
32+
'@angular-eslint/component-selector': [
33+
'error',
34+
{
35+
type: 'element',
36+
prefix: 'demo',
37+
style: 'kebab-case',
38+
},
39+
],
40+
'@angular-eslint/component-class-suffix': ['off'],
41+
'@angular-eslint/directive-class-suffix': ['off'],
42+
},
43+
})),
44+
...compat
45+
.config({ extends: ['plugin:@nx/angular-template'] })
46+
.map(config => ({
47+
...config,
48+
files: ['**/*.html'],
49+
rules: {
50+
...config.rules,
51+
},
52+
})),
53+
];

apps/demo/project.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
"outputPath": "dist/apps/demo",
1414
"index": "apps/demo/src/index.html",
1515
"main": "apps/demo/src/main.ts",
16-
"polyfills": ["zone.js"],
16+
"polyfills": [],
1717
"tsConfig": "apps/demo/tsconfig.app.json",
1818
"assets": ["apps/demo/src/favicon.ico", "apps/demo/src/assets"],
19-
"styles": ["apps/demo/src/styles.css"],
19+
"styles": [
20+
"apps/demo/src/styles.css",
21+
"node_modules/highlight.js/styles/github.min.css"
22+
],
2023
"scripts": []
2124
},
2225
"configurations": {

apps/demo/src/app/app.component.ts

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,25 @@
11
import { ChangeDetectionStrategy, Component } from '@angular/core';
2-
import {
3-
breakpointsTailwind,
4-
observeBreakpoints,
5-
} from 'ngx-breakpoint-observer';
6-
import { JsonPipe } from '@angular/common';
7-
import { provideIcons } from '@ng-icons/core';
8-
import { DemoSnipped } from './components/snipped';
9-
import { simpleGithub } from '@ng-icons/simple-icons';
10-
import { DemoHeader } from './components/header';
11-
import { DemoBreakpoint } from './components/breakpoint';
2+
import { Demo } from './components/demo';
3+
import { Footer } from './components/footer';
4+
import { Header } from './components/header';
5+
import { Installation } from './components/installation';
6+
import { Usage } from './components/usage';
127

138
@Component({
149
standalone: true,
15-
imports: [JsonPipe, DemoSnipped, DemoHeader, DemoBreakpoint],
10+
imports: [Header, Installation, Demo, Usage, Footer],
1611
selector: 'demo-root',
17-
viewProviders: [provideIcons({ simpleGithub })],
1812
template: `
19-
<div class="m-auto h-screen max-w-[1000px] overflow-auto p-4 sm:p-10">
20-
<main class="flex flex-col items-center justify-center gap-5">
21-
<demo-header />
13+
<main
14+
class="container m-auto flex flex-col gap-10 px-4 pb-4 pt-16 sm:px-10 sm:pb-10 sm:pt-24">
15+
<demo-header />
2216
23-
<div class="flex flex-col text-center font-medium">
24-
<p class="py-5">
25-
Resize your window to see breakpoints value changes.
26-
</p>
27-
28-
<div>Current breakpoints: {{ current() | json }}</div>
29-
<demo-breakpoint name="xs" [value]="xs()" />
30-
<demo-breakpoint name="sm" [value]="sm()" />
31-
<demo-breakpoint name="md" [value]="md()" />
32-
<demo-breakpoint name="lg" [value]="lg()" />
33-
<demo-breakpoint name="xl" [value]="xl()" />
34-
<demo-breakpoint name="2xl" [value]="xxl()" />
35-
</div>
36-
37-
<demo-snipped class="w-full" />
38-
</main>
39-
</div>
17+
<demo-installation />
18+
<demo-demo />
19+
<demo-usage />
20+
<demo-footer />
21+
</main>
4022
`,
4123
changeDetection: ChangeDetectionStrategy.OnPush,
4224
})
43-
export class AppComponent {
44-
breakpoints = observeBreakpoints(breakpointsTailwind);
45-
46-
current = this.breakpoints.current();
47-
xs = this.breakpoints.smallerOrEqual('sm');
48-
sm = this.breakpoints.between('sm', 'md');
49-
md = this.breakpoints.between('md', 'lg');
50-
lg = this.breakpoints.between('lg', 'xl');
51-
xl = this.breakpoints.between('xl', '2xl');
52-
xxl = this.breakpoints.greaterOrEqual('2xl');
53-
}
25+
export class AppComponent {}

apps/demo/src/app/app.config.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
2-
import { HighlightJsModule } from 'ngx-highlight-js';
3-
import { provideNgIconsConfig } from '@ng-icons/core';
1+
import {
2+
ApplicationConfig,
3+
provideExperimentalZonelessChangeDetection,
4+
} from '@angular/core';
5+
import { provideRouter, Routes } from '@angular/router';
6+
7+
export const routes: Routes = [];
48

59
export const appConfig: ApplicationConfig = {
610
providers: [
7-
importProvidersFrom(HighlightJsModule),
8-
provideNgIconsConfig({
9-
size: '1em',
10-
}),
11+
provideExperimentalZonelessChangeDetection(),
12+
provideRouter(routes),
1113
],
1214
};
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
import { Component, Input, Signal } from '@angular/core';
2-
import { input } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
32

43
@Component({
54
selector: 'demo-breakpoint',
65
standalone: true,
7-
template: ` <p>
8-
{{ name() }}:
9-
<span [class]="value() ? 'text-green-500' : 'text-red-500'">
10-
{{ value() }}
11-
</span>
12-
</p>`,
6+
template: `
7+
<p>
8+
{{ name() }}:
9+
<span [class]="value() ? 'text-green-500' : 'text-red-500'">
10+
{{ value() }}
11+
</span>
12+
</p>
13+
`,
14+
changeDetection: ChangeDetectionStrategy.OnPush,
1315
})
14-
export class DemoBreakpoint {
16+
export class Breakpoint {
1517
name = input.required<string>();
1618
value = input.required<boolean>();
1719
}

0 commit comments

Comments
 (0)