Skip to content

Commit

Permalink
Merge pull request #233 from angular/main
Browse files Browse the repository at this point in the history
Create a new pull request by comparing changes across two branches
  • Loading branch information
GulajavaMinistudio authored Aug 26, 2024
2 parents 835e3e6 + 7a99815 commit c9d99c2
Show file tree
Hide file tree
Showing 83 changed files with 2,104 additions and 1,786 deletions.
46 changes: 45 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,47 @@
<a name="18.2.1"></a>
# 18.2.1 (2024-08-22)
### core
| Commit | Type | Description |
| -- | -- | -- |
| [9de30a7b1c](https://github.com/angular/angular/commit/9de30a7b1cbda5bd85db607266ad533c1aac0a02) | fix | Allow zoneless scheduler to run inside `fakeAsync` ([#56932](https://github.com/angular/angular/pull/56932)) |
| [286012fb89](https://github.com/angular/angular/commit/286012fb89270bd9330ffeb229f3a14b6e67d2a9) | fix | handle hydration of components that project content conditionally ([#57383](https://github.com/angular/angular/pull/57383)) |
### migrations
| Commit | Type | Description |
| -- | -- | -- |
| [0bb649b8fa](https://github.com/angular/angular/commit/0bb649b8fa22a0db4f383db29995105b0b4adc81) | fix | account for members with doc strings and no modifiers ([#57389](https://github.com/angular/angular/pull/57389)) |
| [3b63082384](https://github.com/angular/angular/commit/3b63082384b396514dd836b7763202536f3f4f23) | fix | avoid migrating route component in tests ([#57317](https://github.com/angular/angular/pull/57317)) |
| [6b4357fae4](https://github.com/angular/angular/commit/6b4357fae45f0c187c8d23649b94a828dd9aaa6e) | fix | preserve type when using inject decorator ([#57389](https://github.com/angular/angular/pull/57389)) |

<!-- CHANGELOG SPLIT MARKER -->

<a name="19.0.0-next.1"></a>
# 19.0.0-next.1 (2024-08-22)
## Breaking Changes
### core
- The `autoDetect` feature of `ComponentFixture` will now
attach the fixture to the `ApplicationRef`. As a result, errors during
automatic change detection of the fixture be reported to the `ErrorHandler`.
This change may cause custom error handlers to observe new failures that were previously unreported.
### compiler-cli
| Commit | Type | Description |
| -- | -- | -- |
| [9e87593055](https://github.com/angular/angular/commit/9e87593055a5314a67090bd15d5552c23b538050) | feat | ensure template style elements are preprocessed as inline styles ([#57429](https://github.com/angular/angular/pull/57429)) |
### core
| Commit | Type | Description |
| -- | -- | -- |
| [b063468027](https://github.com/angular/angular/commit/b0634680272569501146bb7a9cdfe53033e25971) | feat | support TypeScript 5.6 ([#57424](https://github.com/angular/angular/pull/57424)) |
| [3b0dca75d6](https://github.com/angular/angular/commit/3b0dca75d6dab6039253edd00c436715775bd0dd) | fix | Allow zoneless scheduler to run inside `fakeAsync` ([#56932](https://github.com/angular/angular/pull/56932)) |
| [f03d274e87](https://github.com/angular/angular/commit/f03d274e87c919514a70d02c0699523957de7386) | fix | ComponentFixture autoDetect feature works like production ([#55228](https://github.com/angular/angular/pull/55228)) |
| [d4449fce21](https://github.com/angular/angular/commit/d4449fce21bebbb18f9e1341f1675cdbec7e83ac) | fix | handle hydration of components that project content conditionally ([#57383](https://github.com/angular/angular/pull/57383)) |
### migrations
| Commit | Type | Description |
| -- | -- | -- |
| [4ae66f25d0](https://github.com/angular/angular/commit/4ae66f25d01ffd603872b3df3faf5c5c555b6446) | fix | account for members with doc strings and no modifiers ([#57389](https://github.com/angular/angular/pull/57389)) |
| [ac93839d69](https://github.com/angular/angular/commit/ac93839d694929fdf16c610994a369d4efb2823a) | fix | avoid migrating route component in tests ([#57317](https://github.com/angular/angular/pull/57317)) |
| [58a79b6e43](https://github.com/angular/angular/commit/58a79b6e435f2a46a7ab17ff5538083e05340b6f) | fix | preserve type when using inject decorator ([#57389](https://github.com/angular/angular/pull/57389)) |

<!-- CHANGELOG SPLIT MARKER -->

<a name="19.0.0-next.0"></a>
# 19.0.0-next.0 (2024-08-14)
## Breaking Changes
Expand Down Expand Up @@ -3886,4 +3930,4 @@ Adrian Kunz, Alan Agius, AleksanderBodurri, Alex Rickabaugh, AlirezaEbrahimkhani



Earlier changelog entries can be found in CHANGELOG_ARCHIVE.md file.
Earlier changelog entries can be found in CHANGELOG_ARCHIVE.md file.
1 change: 1 addition & 0 deletions adev/shared-docs/components/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ts_library(
"//adev/shared-docs/components/slide-toggle",
"//adev/shared-docs/components/table-of-contents",
"//adev/shared-docs/components/text-field",
"//adev/shared-docs/components/top-level-banner",
"//adev/shared-docs/components/viewers",
],
)
1 change: 1 addition & 0 deletions adev/shared-docs/components/icon/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ng_module(
"//adev/shared-docs/components/navigation-list:__pkg__",
"//adev/shared-docs/components/table-of-contents:__pkg__",
"//adev/shared-docs/components/text-field:__pkg__",
"//adev/shared-docs/components/top-level-banner:__pkg__",
"//adev/shared-docs/components/viewers:__pkg__",
],
deps = [
Expand Down
1 change: 1 addition & 0 deletions adev/shared-docs/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export * from './table-of-contents/table-of-contents.component';
export * from './text-field/text-field.component';
export * from './icon/icon.component';
export * from './search-dialog/search-dialog.component';
export * from './top-level-banner/top-level-banner.component';
49 changes: 49 additions & 0 deletions adev/shared-docs/components/top-level-banner/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
load("//tools:defaults.bzl", "karma_web_test_suite", "ng_module", "ts_library")
load("@io_bazel_rules_sass//:defs.bzl", "sass_binary")

package(default_visibility = ["//visibility:private"])

ng_module(
name = "top-level-banner",
srcs = [
"top-level-banner.component.ts",
],
assets = [
":top-level-banner.component.css",
"top-level-banner.component.html",
],
visibility = [
"//adev/shared-docs/components:__pkg__",
],
deps = [
"//adev/shared-docs/components/icon",
"//adev/shared-docs/directives",
"//adev/shared-docs/providers",
"//packages/common",
"//packages/core",
],
)

sass_binary(
name = "style",
src = "top-level-banner.component.scss",
)

ts_library(
name = "test_lib",
testonly = True,
srcs = glob(
["*.spec.ts"],
),
deps = [
":top-level-banner",
"//adev/shared-docs/providers",
"//packages/core",
"//packages/core/testing",
],
)

karma_web_test_suite(
name = "test",
deps = [":test_lib"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@if (!hasClosed()) {
@if (link()) {
<a [href]="link()" class="docs-top-level-banner">
<h1 tabindex="-1" class="docs-top-level-banner-cta">{{ text() }}</h1>
</a>
} @else {
<div class="docs-top-level-banner">
<h1 tabindex="-1" class="docs-top-level-banner-cta">{{ text() }}</h1>
</div>
}

<button class="docs-top-level-banner-close" type="button" (click)="close()">
<docs-icon class="docs-icon_high-contrast">close</docs-icon>
</button>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
:host {
&:not(:empty) {
z-index: 50;
position: fixed;
height: 2rem;
width: 100vw;
border-bottom: 1px solid var(--septenary-contrast);
text-align: center;
align-content: center;
backdrop-filter: blur(16px);
background-color: color-mix(in srgb, var(--page-background) 70%, transparent);
}

a.docs-top-level-banner {
width: 100%;
display: inherit;
}

h1.docs-top-level-banner-cta {
display: inline;
position: relative;
font-size: 0.875rem;
margin: 0;
background-image: var(--red-to-pink-to-purple-horizontal-gradient);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
width: fit-content;
font-weight: 500;

&::after {
content: '';
position: absolute;
width: 100%;
transform: scaleX(0);
height: 1px;
bottom: -2px;
left: 0;
background: var(--tertiary-contrast);
animation-name: shimmer;
-webkit-animation-duration: 5s;
-moz-animation-duration: 5s;
animation-duration: 5s;
-webkit-animation-iteration-count: infinite;
-moz-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
}

&:hover {
h1.docs-top-level-banner-cta {
&::after {
transform: scaleX(1);
transform-origin: bottom left;
}
}
}

.docs-top-level-banner-close {
position: absolute;
top: 0.25rem;
right: 0.5rem;
color: var(--primary-contrast);
}
}

@keyframes shimmer {
0% {
transform: scaleX(0);
transform-origin: bottom right;
}
100% {
transform: scaleX(1);
transform-origin: bottom left;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import {ComponentFixture, TestBed} from '@angular/core/testing';

import {STORAGE_KEY_PREFIX, TopLevelBannerComponent} from './top-level-banner.component';
import {LOCAL_STORAGE} from '../../providers';

describe('TopLevelBannerComponent', () => {
let component: TopLevelBannerComponent;
let fixture: ComponentFixture<TopLevelBannerComponent>;
let mockLocalStorage: jasmine.SpyObj<Storage>;

const EXAMPLE_TEXT = 'Click Here';
const EXAMPLE_LINK = 'https://example.com';
const EXAMPLE_ID = 'banner-id';

beforeEach(async () => {
mockLocalStorage = jasmine.createSpyObj('Storage', ['getItem', 'setItem']);

await TestBed.configureTestingModule({
imports: [TopLevelBannerComponent],
providers: [{provide: LOCAL_STORAGE, useValue: mockLocalStorage}],
}).compileComponents();

fixture = TestBed.createComponent(TopLevelBannerComponent);
fixture.componentRef.setInput('text', EXAMPLE_TEXT);
fixture.componentRef.setInput('id', EXAMPLE_ID);

component = fixture.componentInstance;
fixture.detectChanges();
});

it('should render an anchor element when link is provided', () => {
fixture.componentRef.setInput('text', EXAMPLE_TEXT);
fixture.componentRef.setInput('link', EXAMPLE_LINK);
fixture.detectChanges();

const bannerElement = fixture.nativeElement.querySelector('a.adev-top-level-banner');
expect(bannerElement).toBeTruthy();
expect(bannerElement.getAttribute('href')).toBe(EXAMPLE_LINK);
expect(bannerElement.textContent).toContain(EXAMPLE_TEXT);
});

it('should render a div element when link is not provided', () => {
const EXAMPLE_TEXT = 'No Link Available';

fixture.componentRef.setInput('text', EXAMPLE_TEXT);
fixture.detectChanges();

const bannerElement = fixture.nativeElement.querySelector('div.adev-top-level-banner');
expect(bannerElement).toBeTruthy();
expect(bannerElement.textContent).toContain(EXAMPLE_TEXT);
});

it('should correctly render the text input', () => {
const EXAMPLE_TEXT = 'Lorem ipsum dolor...';

fixture.componentRef.setInput('text', EXAMPLE_TEXT);
fixture.detectChanges();

const bannerElement = fixture.nativeElement.querySelector('.adev-top-level-banner-cta');
expect(bannerElement).toBeTruthy();
expect(bannerElement.textContent).toBe(EXAMPLE_TEXT);
});

it('should set hasClosed to true if the banner was closed before', () => {
mockLocalStorage.getItem.and.returnValue('true');

component.ngOnInit();

expect(component.hasClosed()).toBeTrue();
expect(mockLocalStorage.getItem).toHaveBeenCalledWith(`${STORAGE_KEY_PREFIX}${EXAMPLE_ID}`);
});

it('should set hasClosed to false if the banner was not closed before', () => {
mockLocalStorage.getItem.and.returnValue('false');

component.ngOnInit();

expect(component.hasClosed()).toBeFalse();
expect(mockLocalStorage.getItem).toHaveBeenCalledWith(`${STORAGE_KEY_PREFIX}${EXAMPLE_ID}`);
});

it('should set hasClosed to false if accessing localStorage throws an error', () => {
mockLocalStorage.getItem.and.throwError('Local storage error');

component.ngOnInit();

expect(component.hasClosed()).toBeFalse();
});

it('should set the banner as closed in localStorage and update hasClosed', () => {
component.close();

expect(mockLocalStorage.setItem).toHaveBeenCalledWith(
`${STORAGE_KEY_PREFIX}${EXAMPLE_ID}`,
'true',
);
expect(component.hasClosed()).toBeTrue();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {ChangeDetectionStrategy, Component, inject, input, OnInit, signal} from '@angular/core';
import {ExternalLink} from '../../directives';
import {LOCAL_STORAGE} from '../../providers';
import {IconComponent} from '../icon/icon.component';

export const STORAGE_KEY_PREFIX = 'docs-was-closed-top-banner-';

@Component({
selector: 'docs-top-level-banner',
standalone: true,
imports: [ExternalLink, IconComponent],
templateUrl: './top-level-banner.component.html',
styleUrl: './top-level-banner.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class TopLevelBannerComponent implements OnInit {
private readonly localStorage = inject(LOCAL_STORAGE);

/**
* Unique identifier for the banner. This ID is required to ensure that
* the state of the banner (e.g., whether it has been closed) is tracked
* separately for different events or instances. Without a unique ID,
* closing one banner could inadvertently hide other banners for different events.
*/
id = input.required<string>();
// Optional URL link that the banner should navigate to when clicked.
link = input<string>();
// Text content to be displayed in the banner.
text = input.required<string>();

// Whether the user has closed the banner.
hasClosed = signal<boolean>(false);

ngOnInit(): void {
// Needs to be in a try/catch, because some browsers will
// throw when using `localStorage` in private mode.
try {
this.hasClosed.set(this.localStorage?.getItem(this.getBannerStorageKey()) === 'true');
} catch {
this.hasClosed.set(false);
}
}

close(): void {
this.localStorage?.setItem(this.getBannerStorageKey(), 'true');
this.hasClosed.set(true);
}

private getBannerStorageKey(): string {
return `${STORAGE_KEY_PREFIX}${this.id()}`;
}
}
2 changes: 1 addition & 1 deletion adev/shared-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"html-entities": "~2.5.2",
"jsdom": "~24.1.0",
"marked": "~14.0.0",
"mermaid": "^10.8.0",
"mermaid": "^11.0.0",
"shiki": "^1.10.3"
},
"exports": {
Expand Down
Loading

0 comments on commit c9d99c2

Please sign in to comment.