Skip to content

Commit ebbce67

Browse files
authored
Merge pull request #130 from CenterForOpenScience/fix/tokens
Fix/tokens
2 parents 6c1ed86 + d9de912 commit ebbce67

File tree

52 files changed

+513
-550
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+513
-550
lines changed

src/app/core/components/breadcrumb/breadcrumb.component.spec.ts

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,32 @@ import { MockProvider } from 'ng-mocks';
33
import { of } from 'rxjs';
44

55
import { ComponentFixture, TestBed } from '@angular/core/testing';
6-
import { NavigationEnd, Router } from '@angular/router';
6+
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
77

88
import { BreadcrumbComponent } from './breadcrumb.component';
99

1010
describe('BreadcrumbComponent', () => {
1111
let component: BreadcrumbComponent;
1212
let fixture: ComponentFixture<BreadcrumbComponent>;
13-
let router: Router;
1413

1514
const mockRouter = {
1615
url: '/test/path',
1716
events: of(new NavigationEnd(1, '/test/path', '/test/path')),
1817
};
1918

19+
const mockActivatedRoute = {
20+
snapshot: {
21+
data: { skipBreadcrumbs: false },
22+
},
23+
firstChild: null,
24+
};
25+
2026
beforeEach(async () => {
2127
await TestBed.configureTestingModule({
2228
imports: [BreadcrumbComponent],
23-
providers: [MockProvider(Router, mockRouter)],
29+
providers: [MockProvider(Router, mockRouter), { provide: ActivatedRoute, useValue: mockActivatedRoute }],
2430
}).compileComponents();
2531

26-
router = TestBed.inject(Router);
2732
fixture = TestBed.createComponent(BreadcrumbComponent);
2833
component = fixture.componentInstance;
2934
fixture.detectChanges();
@@ -34,25 +39,4 @@ describe('BreadcrumbComponent', () => {
3439
expect(component['url']()).toBe('/test/path');
3540
expect(component['parsedUrl']()).toEqual(['test', 'path']);
3641
});
37-
38-
it('should not show breadcrumb for home page', () => {
39-
Object.defineProperty(router, 'url', { value: '/home' });
40-
component['url'].set('/home');
41-
fixture.detectChanges();
42-
43-
const compiled = fixture.nativeElement as HTMLElement;
44-
expect(compiled.querySelector('.breadcrumbs')).toBeNull();
45-
});
46-
47-
it('should show breadcrumb for valid path', () => {
48-
Object.defineProperty(router, 'url', { value: '/settings/profile' });
49-
component['url'].set('/settings/profile');
50-
fixture.detectChanges();
51-
52-
const compiled = fixture.nativeElement as HTMLElement;
53-
const breadcrumbs = compiled.querySelector('.breadcrumbs');
54-
expect(breadcrumbs).toBeTruthy();
55-
expect(breadcrumbs?.textContent).toContain('settings');
56-
expect(breadcrumbs?.textContent).toContain('profile');
57-
});
5842
});
Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,47 @@
11
@use "assets/styles/mixins" as mix;
22
@use "assets/styles/variables" as var;
33

4-
:host {
5-
display: block;
6-
height: auto;
4+
.footer-nav,
5+
.footer-secondary-nav {
6+
color: var.$dark-blue-1;
7+
padding: 0 1.5rem;
78

8-
.footer-nav,
9-
.footer-secondary-nav {
10-
color: var.$dark-blue-1;
11-
padding: 0 1.5rem;
12-
13-
.separator {
14-
margin: 0 mix.rem(6px);
15-
}
9+
.separator {
10+
margin: 0 mix.rem(6px);
11+
}
1612

17-
a {
18-
color: var.$dark-blue-1;
19-
text-align: center;
20-
}
13+
a {
14+
color: var.$dark-blue-1;
15+
text-align: center;
16+
}
2117

22-
.social-link {
23-
background-color: var.$pr-blue-1;
24-
border-radius: mix.rem(6px);
25-
color: var.$white;
26-
padding: mix.rem(6px);
27-
width: mix.rem(36px);
28-
height: mix.rem(36px);
29-
30-
&:hover {
31-
background-color: var.$pr-blue-3;
32-
text-decoration: none;
33-
}
18+
.social-link {
19+
background-color: var.$pr-blue-1;
20+
border-radius: mix.rem(6px);
21+
color: var.$white;
22+
padding: mix.rem(6px);
23+
width: mix.rem(36px);
24+
height: mix.rem(36px);
25+
26+
&:hover {
27+
background-color: var.$pr-blue-3;
28+
text-decoration: none;
3429
}
3530
}
31+
}
3632

37-
.footer-links {
38-
gap: mix.rem(6px);
39-
}
33+
.footer-links {
34+
gap: mix.rem(6px);
35+
}
4036

41-
.footer-nav {
42-
background-color: var.$bg-blue-3;
37+
.footer-nav {
38+
background-color: var.$bg-blue-3;
4339

44-
.footer-socials {
45-
gap: mix.rem(8px);
46-
}
40+
.footer-socials {
41+
gap: mix.rem(8px);
4742
}
43+
}
4844

49-
.footer-secondary-nav {
50-
background: var.$bg-blue-2;
51-
}
45+
.footer-secondary-nav {
46+
background: var.$bg-blue-2;
5247
}

src/app/core/components/forbidden-page/forbidden-page.component.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { TranslatePipe } from '@ngx-translate/core';
2+
import { MockPipe } from 'ng-mocks';
3+
14
import { ComponentFixture, TestBed } from '@angular/core/testing';
25

36
import { ForbiddenPageComponent } from './forbidden-page.component';
@@ -8,7 +11,7 @@ describe('ForbiddenPageComponent', () => {
811

912
beforeEach(async () => {
1013
await TestBed.configureTestingModule({
11-
imports: [ForbiddenPageComponent],
14+
imports: [ForbiddenPageComponent, MockPipe(TranslatePipe)],
1215
}).compileComponents();
1316

1417
fixture = TestBed.createComponent(ForbiddenPageComponent);
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
@use "assets/styles/variables" as var;
21
@use "assets/styles/mixins" as mix;
32

4-
:host {
5-
.nav-menu {
6-
width: 250px;
7-
max-width: 250px;
3+
.nav-menu {
4+
width: 250px;
5+
max-width: 250px;
86

9-
.active {
10-
background-color: var.$dark-blue-2;
11-
border-radius: mix.rem(8px);
12-
font-weight: 700;
13-
}
7+
.active {
8+
background-color: var(--dark-blue-2);
9+
border-radius: mix.rem(8px);
10+
font-weight: 700;
1411
}
1512
}

src/app/core/components/nav-menu/nav-menu.component.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Component, computed, inject, output } from '@angular/core';
99
import { toSignal } from '@angular/core/rxjs-interop';
1010
import { ActivatedRoute, NavigationEnd, Router, RouterLink, RouterLinkActive } from '@angular/router';
1111

12-
import { NAV_ITEMS, PROJECT_MENU_ITEMS } from '@core/constants/nav-items.constant';
12+
import { NAV_ITEMS, PROJECT_MENU_ITEMS } from '@core/constants';
1313
import { IconComponent } from '@osf/shared/components';
1414
import { NavItem } from '@osf/shared/models';
1515

@@ -20,29 +20,29 @@ import { NavItem } from '@osf/shared/models';
2020
styleUrl: './nav-menu.component.scss',
2121
})
2222
export class NavMenuComponent {
23-
readonly #router = inject(Router);
24-
readonly #route = inject(ActivatedRoute);
23+
private readonly router = inject(Router);
24+
private readonly route = inject(ActivatedRoute);
2525
protected readonly navItems = NAV_ITEMS;
2626
protected readonly myProjectMenuItems = PROJECT_MENU_ITEMS;
27-
protected readonly mainMenuItems = this.navItems.map((item) => this.#convertToMenuItem(item));
27+
protected readonly mainMenuItems = this.navItems.map((item) => this.convertToMenuItem(item));
2828

2929
closeMenu = output<void>();
3030

3131
protected readonly currentRoute = toSignal(
32-
this.#router.events.pipe(
32+
this.router.events.pipe(
3333
filter((event): event is NavigationEnd => event instanceof NavigationEnd),
34-
map(() => this.#getRouteInfo())
34+
map(() => this.getRouteInfo())
3535
),
3636
{
37-
initialValue: this.#getRouteInfo(),
37+
initialValue: this.getRouteInfo(),
3838
}
3939
);
4040

4141
protected readonly currentProjectId = computed(() => this.currentRoute().projectId);
4242
protected readonly isProjectRoute = computed(() => !!this.currentProjectId());
4343

44-
#convertToMenuItem(item: NavItem): MenuItem {
45-
const currentUrl = this.#router.url;
44+
convertToMenuItem(item: NavItem): MenuItem {
45+
const currentUrl = this.router.url;
4646
const isExpanded =
4747
item.isCollapsible &&
4848
(currentUrl.startsWith(item.path) ||
@@ -53,13 +53,13 @@ export class NavMenuComponent {
5353
icon: item.icon ? `osf-icon-${item.icon}` : '',
5454
expanded: isExpanded,
5555
routerLink: item.isCollapsible ? undefined : item.path,
56-
items: item.items?.map((subItem) => this.#convertToMenuItem(subItem)),
56+
items: item.items?.map((subItem) => this.convertToMenuItem(subItem)),
5757
};
5858
}
5959

60-
#getRouteInfo() {
61-
const projectId = this.#route.firstChild?.snapshot.params['id'] || null;
62-
const section = this.#route.firstChild?.firstChild?.snapshot.url[0]?.path || 'overview';
60+
getRouteInfo() {
61+
const projectId = this.route.firstChild?.snapshot.params['id'] || null;
62+
const section = this.route.firstChild?.firstChild?.snapshot.url[0]?.path || 'overview';
6363

6464
return { projectId, section };
6565
}

src/app/core/components/page-not-found/page-not-found.component.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import { TranslatePipe } from '@ngx-translate/core';
2+
import { MockPipe } from 'ng-mocks';
3+
14
import { ComponentFixture, TestBed } from '@angular/core/testing';
25

36
import { PageNotFoundComponent } from './page-not-found.component';
@@ -8,7 +11,7 @@ describe('PageNotFoundComponent', () => {
811

912
beforeEach(async () => {
1013
await TestBed.configureTestingModule({
11-
imports: [PageNotFoundComponent],
14+
imports: [PageNotFoundComponent, MockPipe(TranslatePipe)],
1215
}).compileComponents();
1316

1417
fixture = TestBed.createComponent(PageNotFoundComponent);

src/app/core/components/request-access/request-access.component.spec.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1+
import { TranslatePipe } from '@ngx-translate/core';
2+
import { MockPipe, MockProvider } from 'ng-mocks';
3+
4+
import { of } from 'rxjs';
5+
6+
import { provideHttpClient } from '@angular/common/http';
7+
import { provideHttpClientTesting } from '@angular/common/http/testing';
18
import { ComponentFixture, TestBed } from '@angular/core/testing';
9+
import { ActivatedRoute } from '@angular/router';
10+
11+
import { ToastService } from '@osf/shared/services';
212

313
import { RequestAccessComponent } from './request-access.component';
414

@@ -8,7 +18,13 @@ describe('RequestAccessComponent', () => {
818

919
beforeEach(async () => {
1020
await TestBed.configureTestingModule({
11-
imports: [RequestAccessComponent],
21+
imports: [RequestAccessComponent, MockPipe(TranslatePipe)],
22+
providers: [
23+
provideHttpClient(),
24+
provideHttpClientTesting(),
25+
MockProvider(ToastService),
26+
MockProvider(ActivatedRoute, { params: of({}) }),
27+
],
1228
}).compileComponents();
1329

1430
fixture = TestBed.createComponent(RequestAccessComponent);

src/app/core/components/root/root.component.scss

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,43 @@
55
display: flex;
66
height: 100vh;
77
max-width: 100vw;
8+
}
9+
10+
.layout-desktop {
11+
display: flex;
12+
flex: 1;
13+
background-color: var.$dark-blue-1;
14+
max-width: 100vw;
815

9-
.layout-desktop {
16+
.content-wrapper {
17+
position: relative;
18+
background-color: var.$bg-blue-3;
19+
border-radius: mix.rem(12px);
20+
margin: mix.rem(6px);
1021
display: flex;
22+
flex-direction: column;
1123
flex: 1;
12-
background-color: var.$dark-blue-1;
13-
max-width: 100vw;
14-
15-
.content-wrapper {
16-
position: relative;
17-
background-color: var.$bg-blue-3;
18-
border-radius: mix.rem(12px);
19-
margin: mix.rem(6px);
20-
display: flex;
21-
flex-direction: column;
22-
flex: 1;
23-
overflow-y: auto;
24-
}
24+
overflow-y: auto;
2525
}
26+
}
27+
28+
.layout-tablet {
29+
@include mix.flex-center;
30+
flex: 1;
31+
max-width: 100vw;
2632

27-
.layout-tablet {
28-
@include mix.flex-center;
33+
.content-wrapper {
34+
@include mix.flex-column;
35+
width: 100%;
36+
height: 100%;
2937
flex: 1;
30-
max-width: 100vw;
38+
overflow-y: auto;
39+
background-color: var.$bg-blue-3;
3140

32-
.content-wrapper {
41+
.content {
42+
position: relative;
3343
@include mix.flex-column;
34-
width: 100%;
35-
height: 100%;
3644
flex: 1;
37-
overflow-y: auto;
38-
background-color: var.$bg-blue-3;
39-
40-
.content {
41-
position: relative;
42-
@include mix.flex-column;
43-
flex: 1;
44-
}
4545
}
4646
}
4747
}

0 commit comments

Comments
 (0)