Skip to content

Commit

Permalink
Merge pull request #42 from shiftcode/#23-angular19-new
Browse files Browse the repository at this point in the history
Update to Angular19
  • Loading branch information
michaelwittwer authored Jan 20, 2025
2 parents c739af8 + 03f094c commit 8e7aa50
Show file tree
Hide file tree
Showing 62 changed files with 4,462 additions and 4,035 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# install dependencies
- name: Install
run: HUSKY=0 npm ci
run: HUSKY=0 npm ci --include=optional
# lint
- name: Lint
run: npm run lint:ci
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ apps/**/dist
apps/**/coverage
/out-tsc

#eslint cache
libs/aws/.eslintcache
libs/components/.eslintcache
libs/core/.eslintcache
.eslintcache
# dependencies
/node_modules

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Shows the mapping between the angular version and our lib versions.

| Angular Version | Lib Version |
|-----------------|-------------|
| `^19` | `^7` |
| `^18` | `^6` |
| `^17` | `^5` |
| `^16` | `^4` |
Expand Down
21 changes: 9 additions & 12 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@
"prefix": "sg",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "apps/styleguide/dist",
"outputPath": {
"base": "apps/styleguide/dist"
},
"index": "apps/styleguide/src/index.html",
"main": "apps/styleguide/src/main.ts",
"tsConfig": "apps/styleguide/tsconfig.app.json",
"inlineStyleLanguage": "scss",
"polyfills": [
Expand All @@ -83,16 +84,15 @@
"styles": [
"apps/styleguide/src/styles.scss"
],
"scripts": []
"scripts": [],
"browser": "apps/styleguide/src/main.ts"
},
"configurations": {
"production": {
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
Expand Down Expand Up @@ -166,17 +166,14 @@
"displayBlock": true,
"changeDetection": "OnPush",
"viewEncapsulation": "None",
"skipTests": true,
"standalone": true
"skipTests": true
},
"@schematics/angular:directive": {
"prefix": "sc",
"skipTests": true,
"standalone": true
"skipTests": true
},
"@schematics/angular:pipe": {
"skipTests": true,
"standalone": true
"skipTests": true
},
"@schematics/angular:service": {
"skipTests": true
Expand Down
31 changes: 31 additions & 0 deletions apps/styleguide/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
// automatically extends root eslint-config (which extends @shiftcode/eslint-config-recommended for TS)
extends: ['@shiftcode/eslint-config-recommended/ng-config'],
ignorePatterns: ['src/assets/**/*'],
overrides: [
{
plugins: ['@shiftcode/rules'],
files: ['*.ts'],
rules: {
'import/no-extraneous-dependencies': ['error', { packageDir: '../..' }],
'import/no-internal-modules': [
'error',
{
allow: ['rxjs/*'],
},
],
},
},
],
parserOptions: {
project: ['./tsconfig.eslint.json'],
tsconfigRootDir: __dirname,
ecmaVersion: 'latest',
sourceType: 'module',
env: {
browser: true,
node: true,
es6: true,
},
},
}
8 changes: 8 additions & 0 deletions apps/styleguide/.lintstagedrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"*.{ts,html}":
- npm run prettier:staged
- npm run lint:staged
src/**/*.scss:
- npm run prettier:staged
# sort package.json keys
./package.json:
- sort-package-json
11 changes: 11 additions & 0 deletions apps/styleguide/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@shiftcode/styleguide",
"private": true,
"scripts": {
"lint": "npm run lint:ci -- --fix",
"lint:ci": "eslint ./src",
"lint:staged": "eslint --fix",
"prettier": "prettier --write --config ../../.prettierrc.yml 'src/**/*.{ts,html,scss}'",
"prettier:staged": "prettier --write --config ../../.prettierrc.yml"
}
}
8 changes: 5 additions & 3 deletions apps/styleguide/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
<div class="app">
<nav class="app__nav">
<ul>
<li *ngFor="let link of navItems">
<a [routerLink]="[basePath, link.path]">{{link.title}}</a>
</li>
@for (link of navItems; track link) {
<li>
<a [routerLink]="[basePath, link.path]">{{ link.title }}</a>
</li>
}
</ul>
</nav>
<div class="app__content">
Expand Down
2 changes: 0 additions & 2 deletions apps/styleguide/src/app/app.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
}

li {

}

a {
Expand All @@ -40,7 +39,6 @@
}
}


::ng-deep {
h2 {
font-size: 24px;
Expand Down
4 changes: 1 addition & 3 deletions apps/styleguide/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { NgFor } from '@angular/common'
import { ChangeDetectionStrategy, Component, inject } from '@angular/core'
import { RouterLink, RouterOutlet } from '@angular/router'
import { FlyingFocusComponent } from '@shiftcode/ngx-components'
Expand All @@ -7,8 +6,7 @@ import { SUB_ROUTES } from '../routes/routes.const'

@Component({
selector: 'sg-root',
standalone: true,
imports: [NgFor, RouterLink, RouterOutlet, FlyingFocusComponent],
imports: [RouterLink, RouterOutlet, FlyingFocusComponent],
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
52 changes: 26 additions & 26 deletions apps/styleguide/src/index.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Styleguide</title>
<base href="/">
<head>
<meta charset="utf-8" />
<title>Styleguide</title>
<base href="/" />

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<style type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/x-icon" href="favicon.ico" />
<style type="text/css">
html {
box-sizing: border-box;
}

html {
box-sizing: border-box;
}
body,
html {
width: 100%;
height: 100%;
margin: 0;
}

body, html {
width: 100%;
height: 100%;
margin: 0
}

html {
overflow-x: hidden;
overflow-y: scroll;
-webkit-overflow-scrolling: touch
}
</style>
</head>
<body>
<sg-root></sg-root>
</body>
html {
overflow-x: hidden;
overflow-y: scroll;
-webkit-overflow-scrolling: touch;
}
</style>
</head>
<body>
<sg-root></sg-root>
</body>
</html>
8 changes: 3 additions & 5 deletions apps/styleguide/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ bootstrapApplication(AppComponent, {
provideRouter(ROUTES),

provideLocalStorage({ prefix: 'sg.' }),
provideLogger(
withBrowserConsoleTransport(() => ({ logLevel: LogLevel.DEBUG })),
),
provideLogger(withBrowserConsoleTransport(() => ({ logLevel: LogLevel.DEBUG }))),
provideNavigationClassHandler('sg-navigating'),
provideSgConfig(),
],
})
.catch((err) => console.error(err))
// eslint-disable-next-line no-console
}).catch((err) => console.error(err))
1 change: 0 additions & 1 deletion apps/styleguide/src/provide-sg-config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core'
import { TOOLTIP_DEFAULT_OPTIONS, TooltipOptions } from '@shiftcode/ngx-components'


export function provideSgConfig(): EnvironmentProviders {
return makeEnvironmentProviders([
// tooltip
Expand Down
5 changes: 1 addition & 4 deletions apps/styleguide/src/routes/routes.const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ export const SUB_ROUTES = [
export const ROUTES = [
{
path: 'styleguide',
children: [
...SUB_ROUTES,
{ path: '**', redirectTo: SUB_ROUTES[0].path },
],
children: [...SUB_ROUTES, { path: '**', redirectTo: SUB_ROUTES[0].path }],
},
{ path: '**', redirectTo: 'styleguide' },
] satisfies Routes
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h2 scAutoFocus>Autofocus</h2>
<p> can be used to set the focus on route change to any element (like titles for a11y)</p>
<p>can be used to set the focus on route change to any element (like titles for a11y)</p>

<button tabindex="0">button 0</button>
<button tabindex="0">button 1</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

button {
padding: 12px;

}

*:focus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AutoFocusDirective } from '@shiftcode/ngx-components'
selector: 'sg-sg-autofocus',
templateUrl: './sg-autofocus.component.html',
styleUrls: ['./sg-autofocus.component.scss'],
standalone: true,
imports: [AutoFocusDirective],
encapsulation: ViewEncapsulation.Emulated,
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
12 changes: 7 additions & 5 deletions apps/styleguide/src/routes/sg-button/sg-button.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ <h2>SC Button (custom button component)</h2>
<p>Why is that? Check out the behaviour in Safari &#64; MacOS (does not gain focus on click) vs. Firefox/Chrome.</p>

<div class="sg-button__buttons">

<button id="btn-1" class="sg-button__btn" (click)="counter1 = counter1 + 1">native button (clicked: {{counter1}})
<button id="btn-1" class="sg-button__btn" (click)="counter1 = counter1 + 1">
native button (clicked: {{ counter1 }})
</button>

<sc-button id="btn-2" class="sg-button__btn" (action)="counter2 = counter2 + 1">sc-button (clicked: {{counter2}})
<sc-button id="btn-2" class="sg-button__btn" (action)="counter2 = counter2 + 1"
>sc-button (clicked: {{ counter2 }})
</sc-button>

<sc-button id="btn-3" class="sg-button__btn" (action)="counter3 = counter3 + 1">sc-button (clicked: {{counter3}})
<sc-button id="btn-3" class="sg-button__btn" (action)="counter3 = counter3 + 1"
>sc-button (clicked: {{ counter3 }})
</sc-button>
</div>
<p>active element: {{activeEl}}</p>
<p>active element: {{ activeEl }}</p>
35 changes: 23 additions & 12 deletions apps/styleguide/src/routes/sg-button/sg-button.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,42 @@
padding: 4px 12px;
}


&:hover {
&:after {content: 'hover';}
&:after {
content: 'hover';
}
}
&:active { // overrides focus and hover
&:after {content: 'active';}
&:active {
// overrides focus and hover
&:after {
content: 'active';
}
}
&:focus {
&:after {content: 'focus';}
&:after {
content: 'focus';
}
}

&:hover:active {
&:after {content: 'hover, active';}
&:after {
content: 'hover, active';
}
}
&:focus:hover {
&:after {content: 'focus, hover';}
&:after {
content: 'focus, hover';
}
}
&:focus:active {
&:after {content: 'focus, active';}
&:after {
content: 'focus, active';
}
}
&:hover:focus:active {
&:after {content: 'focus, hover, active';}
&:after {
content: 'focus, hover, active';
}
}


}

}
6 changes: 2 additions & 4 deletions apps/styleguide/src/routes/sg-button/sg-button.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { DOCUMENT } from '@angular/common'
import { ChangeDetectionStrategy, Component, Inject, OnDestroy, Optional } from '@angular/core'
import { ButtonComponent, SvgComponent, TooltipDirective } from '@shiftcode/ngx-components'
import { ButtonComponent } from '@shiftcode/ngx-components'

@Component({
selector: 'sg-button',
standalone: true,
imports: [ButtonComponent, SvgComponent, TooltipDirective],
imports: [ButtonComponent],
templateUrl: './sg-button.component.html',
styleUrls: ['./sg-button.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
Expand All @@ -27,7 +26,6 @@ export class SgButtonComponent implements OnDestroy {
this.intervalId = setInterval(this.updateActiveEl, 100)
}


ngOnDestroy(): void {
clearInterval(this.intervalId)
}
Expand Down
Loading

0 comments on commit 8e7aa50

Please sign in to comment.