Skip to content

Commit 249f77d

Browse files
authored
Refactor: Multiple GUI updates (#176)
* closes #95: updated the CS department contact email * updated the links to have a uniform colour and indicate if they're routing to something external * moved fonts style variables to their own partial sass file * updated multiple pages to use the new link style in their content * updated the executive at large information on the Elections page * Added router links to bring users to the proper route in the app
1 parent 70ccc1a commit 249f77d

36 files changed

+325
-118
lines changed

src/app/app.routes.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import { Routes } from '@angular/router';
22
import { HomeComponent } from 'pages/home/home.component';
33

4+
/**
5+
* Formats the title on the web browser's tab/window.
6+
* @param pageTitle - Title of the page
7+
* @returns Formatted page title.
8+
*/
49
function makeTitle(pageTitle: string): string {
510
return `${pageTitle} | CSSS`;
611
}
@@ -50,5 +55,24 @@ export const routes: Routes = [
5055
title: makeTitle('Elections')
5156
},
5257
{ path: '', component: HomeComponent, title: 'Computing Science Student Society' },
58+
// 404 will go down there
5359
{ path: '**', component: HomeComponent }
54-
];
60+
] as const;
61+
62+
const BASE_ROUTES = routes.reduce((acc, route) => {
63+
if (!route.path || route.path === '**') {
64+
return acc;
65+
}
66+
acc.push(route.path);
67+
return acc;
68+
}, [] as string[]);
69+
70+
/**
71+
* Gets the base route as a string.
72+
*
73+
* @param route - Route to get
74+
* @returns The route if it exists or 404
75+
*/
76+
export function getBaseRoute(route: string): string {
77+
return BASE_ROUTES.find(r => r === route) ?? '404';
78+
}

src/app/components/external-link/link.component.html

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

src/app/components/external-link/link.component.scss

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

src/app/components/external-link/link.component.ts

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

src/app/components/external-link/links.ts

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

src/app/components/nav-bar/nav-entries.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
faRoadBarrier,
77
faUpRightFromSquare
88
} from '@fortawesome/free-solid-svg-icons';
9+
import { EXTERNAL_LINKS } from 'components/url/links.data';
910

1011
export interface NavItem extends CodeListItem<NavItem> {
1112
route?: string; // Internal route
@@ -129,7 +130,7 @@ export const NAVBAR_ENTRIES: NavItem[] = [
129130
key: 'documentation.constitution',
130131
label: 'Constitution',
131132
icon: faUpRightFromSquare,
132-
href: 'https://github.com/CSSS/public-docs/tree/master/constitutions'
133+
href: EXTERNAL_LINKS['constitution']
133134
},
134135
{
135136
key: 'documentation.policies',
@@ -141,7 +142,7 @@ export const NAVBAR_ENTRIES: NavItem[] = [
141142
key: 'documentation.sfss-minutes',
142143
label: 'SFSS Minutes',
143144
icon: faUpRightFromSquare,
144-
href: 'https://sfss.ca/about/meeting-times-minutes/council/'
145+
href: 'https://sfss.ca/about/meeting-times-minutes/council'
145146
}
146147
]
147148
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { ChangeDetectionStrategy, Component, computed, input, Signal } from '@angular/core';
2+
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
3+
import { faUpRightFromSquare } from '@fortawesome/free-solid-svg-icons';
4+
import { capitalize } from 'utils/string-utils';
5+
import { CsssLink } from './links.data';
6+
7+
@Component({
8+
selector: 'cs-external-link',
9+
imports: [FontAwesomeModule],
10+
template: '',
11+
changeDetection: ChangeDetectionStrategy.OnPush
12+
})
13+
export abstract class BaseLinkComponent<T extends CsssLink> {
14+
/**
15+
* The link that should be used from `links.ts`
16+
*/
17+
key = input.required<T>();
18+
19+
/**
20+
* Overrides the label that is displayed.
21+
*/
22+
label = input<string>();
23+
24+
/**
25+
* Label that is displayed in the element.
26+
*/
27+
protected _label = computed(() => this.label() ?? capitalize(this.key()));
28+
29+
/**
30+
* The href used to move the user to the external link/route.
31+
*/
32+
protected abstract _href: Signal<string>;
33+
34+
protected externalLinkIcon = faUpRightFromSquare;
35+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<a class="csss-link" [href]="_href()" target="_blank">
2+
{{ _label() }}
3+
</a>

src/app/components/url/email-link/email-link.component.scss

Whitespace-only changes.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { EmailLinkComponent } from './email-link.component';
4+
5+
describe('EmailLinkComponent', () => {
6+
let component: EmailLinkComponent;
7+
let fixture: ComponentFixture<EmailLinkComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
imports: [EmailLinkComponent]
12+
})
13+
.compileComponents();
14+
15+
fixture = TestBed.createComponent(EmailLinkComponent);
16+
component = fixture.componentInstance;
17+
fixture.detectChanges();
18+
});
19+
20+
it('should create', () => {
21+
expect(component).toBeTruthy();
22+
});
23+
});

0 commit comments

Comments
 (0)