-
-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(news): add a basic 'category' field (#3073)
- Loading branch information
1 parent
671fec5
commit 7790651
Showing
13 changed files
with
205 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Community\Enums; | ||
|
||
use Spatie\TypeScriptTransformer\Attributes\TypeScript; | ||
|
||
#[TypeScript] | ||
enum NewsCategory: string | ||
{ | ||
/** | ||
* Used for new achievement set releases and revisions. | ||
* Examples: | ||
* - "New set: Pokémon XD: Gale of Darkness" | ||
*/ | ||
case AchievementSet = "achievement-set"; | ||
|
||
/** | ||
* Used for community updates, spotlights, milestones, and weekly topics. | ||
* Examples: | ||
* - "Come Celebrate 1 MILLION Users!" | ||
* - "Weekly Topic: Your First Achievement" | ||
* - "Community Spotlight: Top Developers of 2024" | ||
*/ | ||
case Community = "community"; | ||
|
||
/** | ||
* Used for events, competitions, and special occasions. | ||
* Examples: | ||
* - "RetroAchievemas 2024 Event" | ||
* - "Achievement of the Week 2025 Begins" | ||
* - "Summer Games Done Quick Special Event" | ||
*/ | ||
case Events = "events"; | ||
|
||
/** | ||
* Used for achievement guides and tutorials. | ||
* Examples: | ||
* - "Guide Showcase: Harvest Moon DS: Cute" | ||
* - "Achievement Guide: Final Fantasy VII" | ||
* - "How to Get Started Making Achievements" | ||
*/ | ||
case Guide = "guide"; | ||
|
||
/** | ||
* Used for external media coverage and content featuring RetroAchievements. | ||
* Examples: | ||
* - "authorblues and Skybilz at AGDQ 2025" | ||
* - "RetroAchievements Featured on IGN" | ||
* - "Community Race: Mega Man X Any%" | ||
* - "New YouTube Series: Achievement Hunting" | ||
* - "RetroRGB Podcast Interview" | ||
*/ | ||
case Media = "media"; | ||
|
||
/** | ||
* Used by the engineering team for a "What's New" section on the home page. | ||
*/ | ||
case SiteReleaseNotes = "site-release-notes"; | ||
|
||
/** | ||
* Used for site maintenance, updates, and feature announcements. | ||
* Examples: | ||
* - "Upcoming Hardcore Restriction" | ||
* - "Planned Site Maintenance" | ||
*/ | ||
case Technical = "technical"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
database/migrations/2025_01_18_000000_update_news_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class() extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::table('news', function (Blueprint $table) { | ||
$table->string('category', 50)->nullable()->after('image_asset_path'); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::table('news', function (Blueprint $table) { | ||
$table->dropColumn('category'); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...features/home/components/+root/FrontPageNews/NewsCategoryLabel/NewsCategoryLabel.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { render, screen } from '@/test'; | ||
|
||
import { NewsCategoryLabel } from './NewsCategoryLabel'; | ||
|
||
describe('Component: NewsCategoryLabel', () => { | ||
it('renders without crashing', () => { | ||
// ARRANGE | ||
const { container } = render(<NewsCategoryLabel category="events" />); | ||
|
||
// ASSERT | ||
expect(container).toBeTruthy(); | ||
}); | ||
|
||
it('displays the label', () => { | ||
// ARRANGE | ||
render(<NewsCategoryLabel category="events" />); | ||
|
||
// ASSERT | ||
expect(screen.getByText(/events/i)).toBeVisible(); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
...s/js/features/home/components/+root/FrontPageNews/NewsCategoryLabel/NewsCategoryLabel.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import type { FC } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
interface NewsCategoryLabelProps { | ||
category: App.Community.Enums.NewsCategory; | ||
} | ||
|
||
export const NewsCategoryLabel: FC<NewsCategoryLabelProps> = ({ category }) => { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<span> | ||
{/* eslint-disable-next-line @typescript-eslint/no-explicit-any -- this is intentional */} | ||
{t(`news-category.${category}` as any)} | ||
</span> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
resources/js/features/home/components/+root/FrontPageNews/NewsCategoryLabel/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './NewsCategoryLabel'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters