Skip to content

feat: enable light mode #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/blog/src/assets/icons/arrow-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<ng-container *transloco="let t; read: 'aboutUsPage'">
<h2 class="py-4 text-[40px] font-bold">
<h2 class="text-al-primary-foreground py-4 text-[40px] font-bold">
{{ t('title') }}
</h2>

<al-card>
<al-card class="bg-transparent">
<section
alCardContent
aria-labelledby="angular-love"
Expand Down Expand Up @@ -35,7 +35,7 @@ <h2 class="py-4 text-[40px] font-bold">
<al-newsletter alCardContent />
</al-card>

<h2 class="mb-8 mt-10 text-[40px] font-bold">
<h2 class="text-al-primary-foreground mb-8 mt-10 text-[40px] font-bold">
{{ t('authorsTitle') }}
</h2>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { CategoryListItem, injectCategories } from './categories.const';
NgClass,
TranslocoDirective,
ArticleRegularCardSkeletonComponent,
CardComponent,
RepeatDirective,
RouterLink,
ButtonComponent,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<a [routerLink]="['/', article().slug] | alLocalize">
<article
class="h-full rounded-lg bg-cover bg-no-repeat transition-transform hover:scale-105 motion-reduce:transition-none motion-reduce:hover:scale-100"
[style.background-image]="
'url(' +
(article().featuredImageUrl || 'assets/article-placeholder.webp') +
')'
"
class="relative h-full overflow-hidden rounded-lg bg-black bg-cover bg-no-repeat transition-transform hover:scale-105 motion-reduce:transition-none motion-reduce:hover:scale-100"
[attr.aria-labelledby]="article().slug"
>
<div
class="bg-al-background relative flex h-full flex-col justify-between opacity-85"
>
<img
alt="Post featured image"
class="absolute h-auto w-full bg-contain opacity-20"
[ngSrc]="article().featuredImageUrl || 'assets/article-placeholder.webp'"
[priority]="imagePriority()"
width="1215"
height="750"
/>
<div class="relative flex h-full flex-col justify-between text-[#fff]">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Use theme variables for text color instead of hardcoded white

You're using a hardcoded white color (text-[#fff]) which won't adapt to different themes.

For proper theme support, use the foreground color variable:

-<div class="relative flex h-full flex-col justify-between text-[#fff]">
+<div class="relative flex h-full flex-col justify-between text-al-foreground">

If the text should remain white regardless of theme, use the Tailwind class:

-<div class="relative flex h-full flex-col justify-between text-[#fff]">
+<div class="relative flex h-full flex-col justify-between text-white">

<div
class="hover:bg-al-bottom-radial-gradient absolute h-full w-full"
></div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { NgOptimizedImage } from '@angular/common';
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
import { RouterLink } from '@angular/router';
import { FastSvgComponent } from '@push-based/ngx-fast-svg';
Expand All @@ -9,9 +10,17 @@ import { AvatarComponent } from '@angular-love/blog/shared/ui-avatar';
@Component({
selector: 'al-article-compact-card',
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [AvatarComponent, RouterLink, AlLocalizePipe, FastSvgComponent],
standalone: true,
imports: [
AvatarComponent,
RouterLink,
AlLocalizePipe,
FastSvgComponent,
NgOptimizedImage,
],
templateUrl: './article-compact-card.component.html',
})
export class ArticleCompactCardComponent {
readonly article = input.required<ArticleCard>();
readonly imagePriority = input<number | null>(null);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CardComponent } from '@angular-love/blog/shared/ui-card';
selector: 'al-article-hero-card-skeleton',
imports: [NgxSkeletonLoaderModule, CardComponent],
template: `
<al-card>
<al-card class="bg-transparent">
<div alCardContent class="p-2">
<div class="flex flex-row items-center">
<!-- avatar -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<a [routerLink]="['/', article().slug] | alLocalize">
<article
class="group relative flex h-full w-full flex-row rounded-lg shadow-none max-h-52"
class="light:border group relative flex h-full w-full flex-row rounded-lg shadow-none"
[attr.aria-labelledby]="article().slug"
>
<img
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<a [routerLink]="['/', article().slug] | alLocalize">
<article
class="bg-al-card md:hover:shadow-al-primary group relative h-full w-full rounded-lg border border-transparent shadow-none transition-transform motion-reduce:transition-none lg:hover:scale-105 lg:motion-reduce:hover:scale-100"
class="bg-al-card md:hover:shadow-al-primary group relative h-full w-full rounded-lg border shadow-none transition-transform motion-reduce:transition-none lg:hover:scale-105 lg:motion-reduce:hover:scale-100 dark:border-transparent"
[attr.aria-labelledby]="article().slug"
>
<div
Expand All @@ -18,8 +18,12 @@
<div class="rounded-b-lg">
<div class="flex items-center justify-between px-4 pt-4">
<div class="flex items-center gap-2">
<al-avatar [imageSrc]="article().author.avatarUrl" size="32" />
<span class="text-sm/[14px] font-medium">
<al-avatar
[imageSrc]="article().author.avatarUrl"
[priority]="imagePriority()"
size="32"
/>
<span class="text-al-primary-foreground text-sm/[14px] font-medium">
{{ article().author.name }}
</span>
</div>
Expand All @@ -34,10 +38,14 @@
</div>
</div>
<div class="flex flex-col gap-3 px-4 pb-4 pt-3">
<h3 class="text-2xl font-bold" [id]="article().slug">
<h3
class="*:text-al-primary-foreground text-2xl font-bold *:not-italic"
[id]="article().slug"
style="word-break: break-word"
>
{{ article().title }}
</h3>
<p class="line-clamp-2">
<p class="*:text-al-pink line-clamp-2 *:font-medium *:not-italic">
{{ article().excerpt }}
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
/>
}
@case ('compact') {
<al-article-compact-card [article]="article()" />
<al-article-compact-card
[article]="article()"
[imagePriority]="imagePriority()"
/>
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="my-5 flex flex-row items-center justify-between gap-6">
<h2
data-testId="article-list-title"
class="line-clamp-2 max-w-[160px] text-xl font-bold md:line-clamp-1 md:max-w-full lg:text-3xl"
class="text-al-primary-foreground line-clamp-2 max-w-[160px] text-xl font-bold md:line-clamp-1 md:max-w-full lg:text-3xl"
>
{{ title() }}
</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {

@Component({
selector: 'al-author-card-template',
standalone: true,
imports: [CardComponent, CardContentDirective, GradientCardDirective],
host: {
class: 'block @container',
Expand All @@ -19,9 +20,11 @@ import {
class="@3xl:flex-row @3xl:border-none flex w-full flex-col items-center rounded-lg border"
>
<div
class="@3xl:border @3xl:!bg-al-radial-gradient @3xl:bg-al-background @3xl:min-w-[260px] min-w-fit rounded-lg pb-4 pt-6"
alGradientCard
class="@3xl:border dark:@3xl:!bg-al-radial-gradient dark:@3xl:bg-al-background light:@3xl:bg-[#f2f2f2] @3xl:min-w-[260px] min-w-fit rounded-lg pb-4 pt-6"
>
<div
alCardContent
class="@3xl:max-w-[360px] flex w-full flex-col items-center gap-4"
>
<ng-content select="[author-info-card]"></ng-content>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<div class="flex flex-col items-center gap-4">
<al-avatar [imageSrc]="author().avatarUrl" size="96" />
<span
class="line-clamp-2 font-bold leading-none"
class="text-al-foreground line-clamp-2 font-bold leading-none"
[id]="'author-title-' + author().slug"
>
{{ author().name }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h3 id="author-ad-title" class="text-2xl font-bold lg:text-4xl">
href="https://form.typeform.com/to/Zzf1Girt?typeform-source=angular.love"
target="_blank"
>
<p class="text-sm font-bold">
<p class="text-sm font-bold text-white">
{{ t('becomeAuthorCard.buttonText') }}
</p>
</a>
Expand Down Expand Up @@ -61,7 +61,7 @@ <h3 id="author-ad-title" class="text-2xl font-bold lg:text-4xl">
class="bg-al-pink flex h-[46px] w-full items-center justify-center rounded-lg md:w-4/5 lg:w-full"
[routerLink]="'/writing-rules' | alLocalize"
>
<p class="text-center text-sm font-bold">
<p class="text-center text-sm font-bold text-white">
{{ t('articleWritingRules.buttonText') }}
</p>
</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<div
class="my-1 flex h-full w-full items-center border md:my-2"
[ngClass]="{
'bg-al-radial-gradient rounded-lg': layout() === 'curved'
'bg-al-radial-gradient rounded-lg': layout() === 'curved',
}"
>
@if (index()) {
<div
class="bg-al-pink ml-4 mt-5 flex aspect-square h-6 items-center justify-center self-start rounded-full"
>
<p class="text-base font-bold">{{ index() }}</p>
<p class="text-base font-bold text-white">{{ index() }}</p>
</div>
} @else {
<div class="ml-4 mr-2 mt-6 h-4 self-start md:mt-0 md:self-center">
<fast-svg name="tick" size="16" class="text-al-pink " />
<fast-svg name="tick" class="text-al-pink" size="16" />
</div>
}
<p class="ml-4 mr-6 block pb-4 pt-5 md:ml-4 md:py-5 lg:mr-[30px]">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ChangeDetectionStrategy, Component, input } from '@angular/core';
/>
<span class="text-al-primary px-4 text-lg font-bold">angular.love</span>
</div>
<small class="text-al-muted hidden pt-1 text-xs lg:block">
<small class="hidden pt-1 text-xs text-[#bec4ca] lg:block">
Copyright &#169; {{ currentYear() }}
</small>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SocialMediaIconsComponent } from '@angular-love/blog/shared/ui-social-m
<div class="flex flex-col items-start">
<h3
id="social-media-title"
class="mb-4 hidden text-sm font-bold lg:block"
class="mb-4 hidden text-sm font-bold text-[#fff] lg:block"
>
Social media
</h3>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<footer class="bg-al-card w-full">
<footer class="w-full bg-[#191a22]">
<div
class="al-container mx-auto grid max-w-screen-xl gap-y-4 px-6 py-4 xl:px-0"
>
<al-footer-logo class="self-center" [currentYear]="currentYear" />
<al-navigation />
<al-navigation [whiteFont]="true" />
<div
class="social-media-container flex items-center justify-self-end md:max-lg:justify-self-center"
>
<al-footer-social-media-icons />
</div>

<small class="copyright text-al-muted text-center text-xs lg:hidden">
<small class="copyright text-center text-xs text-[#6a798b] lg:hidden">
Copyright &#169; {{ currentYear }}
</small>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
>
<a
[attr.data-testid]="item.dataTestId"
class="text-al-foreground p-2 font-medium md:p-6"
class="p-2 font-medium md:p-6"
[ngClass]="whiteFont() ? 'text-white' : 'text-al-foreground'"
[routerLinkActive]="'text-al-pink'"
[routerLink]="item.link | alLocalize"
(click)="navigated.emit()"
Expand All @@ -33,7 +34,8 @@
<li>
<a
[attr.data-testid]="item.dataTestId"
class="text-al-foreground p-2 font-medium md:p-6"
class="p-2 font-medium md:p-6"
[ngClass]="whiteFont() ? 'text-white' : 'text-al-foreground'"
[href]="item.link"
target="_blank"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type NavItem = {
})
export class NavigationComponent {
readonly layout = input<'vertical' | 'horizontal'>('horizontal');
readonly whiteFont = input<boolean>(false);

readonly navItems: NavItem[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="flex flex-col">
<h2
id="newsletter-title"
class="text-4xl font-bold lg:text-2xl xl:text-4xl"
class="text-al-primary-foreground text-4xl font-bold lg:text-2xl xl:text-4xl"
>
{{ t('title') }}
</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
>
@for (partner of partnersList(); track partner.asset_URL) {
<a
class="aspect-[2/1] w-full max-w-[160px] rounded-lg bg-white md:max-w-[200px] lg:transition-transform lg:hover:scale-105 lg:hover:cursor-pointer lg:motion-reduce:transition-none lg:motion-reduce:hover:scale-100"
class="light:border light:rounded-lg aspect-[2/1] w-full max-w-[160px] rounded-lg bg-white md:max-w-[200px] lg:transition-transform lg:hover:scale-105 lg:hover:cursor-pointer lg:motion-reduce:transition-none lg:motion-reduce:hover:scale-100"
[href]="partner.link_URL"
[title]="partner.title"
target="_blank"
Expand Down
4 changes: 2 additions & 2 deletions libs/blog/shared/ui-card/src/lib/card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class CardLinkableDirective {
export class GradientCardDirective {
@HostBinding('class')
get hostClasses() {
return 'border !bg-al-radial-gradient bg-al-background';
return 'bg-al-radial-gradient dark:bg-al-background';
}
}

Expand Down Expand Up @@ -97,5 +97,5 @@ export class CardComponent {
ref: ElementRef<HTMLElement> = inject(ElementRef);

@HostBinding('class')
hostClasses = 'block rounded-lg border shadow-sm overflow-hidden';
hostClasses = 'block rounded-lg border bg-al-card shadow-sm overflow-hidden';
}
2 changes: 1 addition & 1 deletion libs/blog/shared/ui-card/src/lib/card.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const content =
export const regular: Story = {
render: () => ({
template: wrapper(`
<al-card>
<al-card class="bg-transparent">
<div alCardHeader>Header</div>
<div alCardContent>${content}</div>
<div alCardFooter>Footer</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export type UiDifficulty = 'beginner' | 'intermediate' | 'advanced';
<div
class="flex items-center self-stretch rounded-l-md pl-1 text-center align-middle xl:pl-2"
[ngClass]="{
'bg-al-background': isColorBackground(),
'bg-al-border': !isColorBackground(),
'dark:bg-al-background bg-transparent': isColorBackground(),
'bg-al-grey': !isColorBackground(),
}"
>
<span
Expand All @@ -44,7 +44,8 @@ export type UiDifficulty = 'beginner' | 'intermediate' | 'advanced';
<div
class="mx-0.5 inline-block h-4 w-4 rounded-full bg-transparent lg:mx-1"
[ngClass]="{
'shadow-al-full-background': isColorBackground(),
'dark:shadow-al-full-background shadow-transparent':
isColorBackground(),
'shadow-al-full-border': !isColorBackground(),
}"
></div>
Expand Down Expand Up @@ -76,8 +77,8 @@ export type UiDifficulty = 'beginner' | 'intermediate' | 'advanced';
<div
class="flex items-center self-stretch rounded-r-md pr-1 text-center align-middle"
[ngClass]="{
'bg-al-background': isColorBackground(),
'bg-al-border': !isColorBackground(),
'dark:bg-al-background bg-transparent': isColorBackground(),
'bg-al-grey': !isColorBackground(),
}"
></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion libs/blog/shared/ui-pill/src/lib/pill.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const pillVariants = cva(
{
variants: {
variant: <Record<AlPillVariant, string>>{
flat: 'bg-al-primary/90',
flat: 'bg-al-primary/90 text-white',
outline: 'bg-al-background',
},
size: <Record<AlPillSize, string>>{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<ul aria-label="Social media" class="flex items-center justify-center">
@for (social of socials; track $index) {
<li>
<al-social-media-icon-item [socialMediaConfig]="social" />
<al-social-media-icon-item
class="text-[#fff]"
[socialMediaConfig]="social"
/>
</li>
}
</ul>
Loading