From 5a39f44096a758942e94558396fde1090ee7cca1 Mon Sep 17 00:00:00 2001 From: Konrad Koller Date: Fri, 29 Nov 2024 08:15:49 +0100 Subject: [PATCH] refactor(features): change feature split structure --- src/components/molecules/MarqueeText.tsx | 2 +- src/components/templates/MainLayout.tsx | 6 ++++-- .../PageTitleExperienceHost.tsx | 0 .../components/ArrayPagedTitle.tsx | 0 .../components/GlitchyTitle.tsx | 0 .../components/MarqueeTitle.tsx | 2 +- .../{context_menu => browser_core}/hooks/useContextMenu.tsx | 0 src/features/{page_title => browser_core}/index.ts | 1 + .../utils/__test__/string_marquee.test.ts | 2 +- .../{page_title => browser_core}/utils/string_marquee.ts | 0 .../{articles => content}/components/CoverPlaceholder.tsx | 0 .../{articles => content}/components/DenseTextList.tsx | 2 +- .../{articles => content}/components/LargeCoverItem.tsx | 2 +- .../components/PartitionalLockedContent.tsx | 0 .../{articles => content}/components/SmallCoverListItem.tsx | 2 +- .../{articles => content}/components/TextListItem.tsx | 2 +- src/features/{articles => content}/index.ts | 1 + .../{articles => content}/services/ArticleService.ts | 2 +- src/features/{articles => content}/types.ts | 0 src/features/content_limiter/index.ts | 1 - src/features/context_menu/index.ts | 1 - src/features/dead_pixel/index.ts | 1 - .../{dead_pixel => obstruction_decor}/DeadPixelHost.tsx | 0 .../StickyVideoExperienceHost.tsx | 0 src/features/{sticky_video => obstruction_decor}/index.ts | 1 + src/lib/providers/ExperienceProvider.tsx | 4 ++-- src/pages/articles/[slug].tsx | 3 +-- src/pages/index.tsx | 2 +- src/pages/search.tsx | 2 +- 29 files changed, 20 insertions(+), 19 deletions(-) rename src/features/{page_title => browser_core}/PageTitleExperienceHost.tsx (100%) rename src/features/{page_title => browser_core}/components/ArrayPagedTitle.tsx (100%) rename src/features/{page_title => browser_core}/components/GlitchyTitle.tsx (100%) rename src/features/{page_title => browser_core}/components/MarqueeTitle.tsx (90%) rename src/features/{context_menu => browser_core}/hooks/useContextMenu.tsx (100%) rename src/features/{page_title => browser_core}/index.ts (68%) rename src/features/{page_title => browser_core}/utils/__test__/string_marquee.test.ts (94%) rename src/features/{page_title => browser_core}/utils/string_marquee.ts (100%) rename src/features/{articles => content}/components/CoverPlaceholder.tsx (100%) rename src/features/{articles => content}/components/DenseTextList.tsx (88%) rename src/features/{articles => content}/components/LargeCoverItem.tsx (96%) rename src/features/{content_limiter => content}/components/PartitionalLockedContent.tsx (100%) rename src/features/{articles => content}/components/SmallCoverListItem.tsx (95%) rename src/features/{articles => content}/components/TextListItem.tsx (89%) rename src/features/{articles => content}/index.ts (82%) rename src/features/{articles => content}/services/ArticleService.ts (99%) rename src/features/{articles => content}/types.ts (100%) delete mode 100644 src/features/content_limiter/index.ts delete mode 100644 src/features/context_menu/index.ts delete mode 100644 src/features/dead_pixel/index.ts rename src/features/{dead_pixel => obstruction_decor}/DeadPixelHost.tsx (100%) rename src/features/{sticky_video => obstruction_decor}/StickyVideoExperienceHost.tsx (100%) rename src/features/{sticky_video => obstruction_decor}/index.ts (58%) diff --git a/src/components/molecules/MarqueeText.tsx b/src/components/molecules/MarqueeText.tsx index 04e258a..3ce0ca5 100644 --- a/src/components/molecules/MarqueeText.tsx +++ b/src/components/molecules/MarqueeText.tsx @@ -2,7 +2,7 @@ import Link from 'next/link'; import { FunctionComponent, useState } from 'react'; import MarqueePlugin from 'react-fast-marquee'; -import { ArticleService } from '@/features/articles'; +import { ArticleService } from '@/features/content'; import { useRuntimeStore } from '@/lib/state/runtime'; export type MarqueeTextProps = { diff --git a/src/components/templates/MainLayout.tsx b/src/components/templates/MainLayout.tsx index 3085e99..4af61a6 100644 --- a/src/components/templates/MainLayout.tsx +++ b/src/components/templates/MainLayout.tsx @@ -5,10 +5,12 @@ import CookieBar from '@/components/organisms/CookieConsent'; import Footer from '@/components/organisms/Footer'; import Header from '@/components/organisms/Header'; import { ChatBubbleHost } from '@/features/chat_bubble'; -import { DeadPixelHost } from '@/features/dead_pixel'; import { ContainerGiftFlaps } from '@/features/gifts'; import { AdblockerSuspectBar } from '@/features/gifts'; -import { StickyVideoExperienceHost } from '@/features/sticky_video'; +import { + DeadPixelHost, + StickyVideoExperienceHost, +} from '@/features/obstruction_decor'; import { WheelOfFortuneHost } from '@/features/wheel_of_fortune'; import { useExperienceFlagsStore } from '@/lib/state/experience_flags'; diff --git a/src/features/page_title/PageTitleExperienceHost.tsx b/src/features/browser_core/PageTitleExperienceHost.tsx similarity index 100% rename from src/features/page_title/PageTitleExperienceHost.tsx rename to src/features/browser_core/PageTitleExperienceHost.tsx diff --git a/src/features/page_title/components/ArrayPagedTitle.tsx b/src/features/browser_core/components/ArrayPagedTitle.tsx similarity index 100% rename from src/features/page_title/components/ArrayPagedTitle.tsx rename to src/features/browser_core/components/ArrayPagedTitle.tsx diff --git a/src/features/page_title/components/GlitchyTitle.tsx b/src/features/browser_core/components/GlitchyTitle.tsx similarity index 100% rename from src/features/page_title/components/GlitchyTitle.tsx rename to src/features/browser_core/components/GlitchyTitle.tsx diff --git a/src/features/page_title/components/MarqueeTitle.tsx b/src/features/browser_core/components/MarqueeTitle.tsx similarity index 90% rename from src/features/page_title/components/MarqueeTitle.tsx rename to src/features/browser_core/components/MarqueeTitle.tsx index 34ca9b4..cb14755 100644 --- a/src/features/page_title/components/MarqueeTitle.tsx +++ b/src/features/browser_core/components/MarqueeTitle.tsx @@ -1,7 +1,7 @@ import Head from 'next/head'; import { useEffect, useState } from 'react'; -import string_marquee from '@/features/page_title/utils/string_marquee'; +import { string_marquee } from '@/features/browser_core'; type MarqueeTitleProps = { enabled: boolean; diff --git a/src/features/context_menu/hooks/useContextMenu.tsx b/src/features/browser_core/hooks/useContextMenu.tsx similarity index 100% rename from src/features/context_menu/hooks/useContextMenu.tsx rename to src/features/browser_core/hooks/useContextMenu.tsx diff --git a/src/features/page_title/index.ts b/src/features/browser_core/index.ts similarity index 68% rename from src/features/page_title/index.ts rename to src/features/browser_core/index.ts index f0ca341..653b3d0 100644 --- a/src/features/page_title/index.ts +++ b/src/features/browser_core/index.ts @@ -1,2 +1,3 @@ +export { default as useContextMenu } from './hooks/useContextMenu'; export { default as PageTitleExperienceHost } from './PageTitleExperienceHost'; export { default as string_marquee } from './utils/string_marquee'; diff --git a/src/features/page_title/utils/__test__/string_marquee.test.ts b/src/features/browser_core/utils/__test__/string_marquee.test.ts similarity index 94% rename from src/features/page_title/utils/__test__/string_marquee.test.ts rename to src/features/browser_core/utils/__test__/string_marquee.test.ts index 350b34d..e5a2c9d 100644 --- a/src/features/page_title/utils/__test__/string_marquee.test.ts +++ b/src/features/browser_core/utils/__test__/string_marquee.test.ts @@ -1,7 +1,7 @@ /** * @jest-environment jsdom */ -import string_marquee from '@/features/page_title/utils/string_marquee'; +import { string_marquee } from '@/features/browser_core'; describe('String Marquee', () => { const base = { diff --git a/src/features/page_title/utils/string_marquee.ts b/src/features/browser_core/utils/string_marquee.ts similarity index 100% rename from src/features/page_title/utils/string_marquee.ts rename to src/features/browser_core/utils/string_marquee.ts diff --git a/src/features/articles/components/CoverPlaceholder.tsx b/src/features/content/components/CoverPlaceholder.tsx similarity index 100% rename from src/features/articles/components/CoverPlaceholder.tsx rename to src/features/content/components/CoverPlaceholder.tsx diff --git a/src/features/articles/components/DenseTextList.tsx b/src/features/content/components/DenseTextList.tsx similarity index 88% rename from src/features/articles/components/DenseTextList.tsx rename to src/features/content/components/DenseTextList.tsx index f7507b0..b7e827d 100644 --- a/src/features/articles/components/DenseTextList.tsx +++ b/src/features/content/components/DenseTextList.tsx @@ -1,6 +1,6 @@ import { FunctionComponent } from 'react'; -import { type ArticleDatum, TextListItem } from '@/features/articles'; +import { type ArticleDatum, TextListItem } from '@/features/content'; type DenseTextListProps = JSXProxyProps<'ul'> & { items: ArticleDatum[]; diff --git a/src/features/articles/components/LargeCoverItem.tsx b/src/features/content/components/LargeCoverItem.tsx similarity index 96% rename from src/features/articles/components/LargeCoverItem.tsx rename to src/features/content/components/LargeCoverItem.tsx index 4220563..92dc388 100644 --- a/src/features/articles/components/LargeCoverItem.tsx +++ b/src/features/content/components/LargeCoverItem.tsx @@ -5,7 +5,7 @@ import { FunctionComponent } from 'react'; import { CoverPlaceholder } from './CoverPlaceholder'; -import { type ArticleDatum } from '@/features/articles'; +import { type ArticleDatum } from '@/features/content'; type LargeCoverItemProps = JSXProxyProps<'div'> & { article: ArticleDatum; diff --git a/src/features/content_limiter/components/PartitionalLockedContent.tsx b/src/features/content/components/PartitionalLockedContent.tsx similarity index 100% rename from src/features/content_limiter/components/PartitionalLockedContent.tsx rename to src/features/content/components/PartitionalLockedContent.tsx diff --git a/src/features/articles/components/SmallCoverListItem.tsx b/src/features/content/components/SmallCoverListItem.tsx similarity index 95% rename from src/features/articles/components/SmallCoverListItem.tsx rename to src/features/content/components/SmallCoverListItem.tsx index 3825176..60f5fde 100644 --- a/src/features/articles/components/SmallCoverListItem.tsx +++ b/src/features/content/components/SmallCoverListItem.tsx @@ -5,7 +5,7 @@ import { FunctionComponent } from 'react'; import { CoverPlaceholder } from './CoverPlaceholder'; -import { type ArticleDatum } from '@/features/articles'; +import { type ArticleDatum } from '@/features/content'; type SmallCoverListItemProps = { article: ArticleDatum; diff --git a/src/features/articles/components/TextListItem.tsx b/src/features/content/components/TextListItem.tsx similarity index 89% rename from src/features/articles/components/TextListItem.tsx rename to src/features/content/components/TextListItem.tsx index e9e0a37..cff54ee 100644 --- a/src/features/articles/components/TextListItem.tsx +++ b/src/features/content/components/TextListItem.tsx @@ -1,7 +1,7 @@ import Link from 'next/link'; import { FunctionComponent } from 'react'; -import { type ArticleDatum } from '@/features/articles'; +import { type ArticleDatum } from '@/features/content'; type TextListItemProps = { article: ArticleDatum; diff --git a/src/features/articles/index.ts b/src/features/content/index.ts similarity index 82% rename from src/features/articles/index.ts rename to src/features/content/index.ts index 33c87d2..e0d2784 100644 --- a/src/features/articles/index.ts +++ b/src/features/content/index.ts @@ -5,3 +5,4 @@ export { LargeCoverItem } from './components/LargeCoverItem'; export { SmallCoverListItem } from './components/SmallCoverListItem'; export { TextListItem } from './components/TextListItem'; export { ArticleServiceSingleton as ArticleService } from './services/ArticleService'; +export { default as PartitionalLockedContent } from './components/PartitionalLockedContent'; diff --git a/src/features/articles/services/ArticleService.ts b/src/features/content/services/ArticleService.ts similarity index 99% rename from src/features/articles/services/ArticleService.ts rename to src/features/content/services/ArticleService.ts index 7b71418..d4b330b 100644 --- a/src/features/articles/services/ArticleService.ts +++ b/src/features/content/services/ArticleService.ts @@ -5,7 +5,7 @@ import { ArticleLookupIdentifier, ArticleSearchFilter, ArticleSearchResult, -} from '@/features/articles'; +} from '@/features/content'; import { ArticleIndexEntrySchema } from '@/lib/schemas/article-index-entry'; import { fuzzy_search } from '@/lib/utils/string'; import articlesRaw from '@/public/assets/articles/index.json'; diff --git a/src/features/articles/types.ts b/src/features/content/types.ts similarity index 100% rename from src/features/articles/types.ts rename to src/features/content/types.ts diff --git a/src/features/content_limiter/index.ts b/src/features/content_limiter/index.ts deleted file mode 100644 index bed9db2..0000000 --- a/src/features/content_limiter/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as PartitionalLockedContent } from './components/PartitionalLockedContent'; diff --git a/src/features/context_menu/index.ts b/src/features/context_menu/index.ts deleted file mode 100644 index 0b3845f..0000000 --- a/src/features/context_menu/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as useContextMenu } from './hooks/useContextMenu'; diff --git a/src/features/dead_pixel/index.ts b/src/features/dead_pixel/index.ts deleted file mode 100644 index f9eb8e7..0000000 --- a/src/features/dead_pixel/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as DeadPixelHost } from './DeadPixelHost'; diff --git a/src/features/dead_pixel/DeadPixelHost.tsx b/src/features/obstruction_decor/DeadPixelHost.tsx similarity index 100% rename from src/features/dead_pixel/DeadPixelHost.tsx rename to src/features/obstruction_decor/DeadPixelHost.tsx diff --git a/src/features/sticky_video/StickyVideoExperienceHost.tsx b/src/features/obstruction_decor/StickyVideoExperienceHost.tsx similarity index 100% rename from src/features/sticky_video/StickyVideoExperienceHost.tsx rename to src/features/obstruction_decor/StickyVideoExperienceHost.tsx diff --git a/src/features/sticky_video/index.ts b/src/features/obstruction_decor/index.ts similarity index 58% rename from src/features/sticky_video/index.ts rename to src/features/obstruction_decor/index.ts index 77e6590..f85a908 100644 --- a/src/features/sticky_video/index.ts +++ b/src/features/obstruction_decor/index.ts @@ -1 +1,2 @@ export { default as StickyVideoExperienceHost } from './StickyVideoExperienceHost'; +export { default as DeadPixelHost } from './DeadPixelHost'; diff --git a/src/lib/providers/ExperienceProvider.tsx b/src/lib/providers/ExperienceProvider.tsx index da67e19..4763593 100644 --- a/src/lib/providers/ExperienceProvider.tsx +++ b/src/lib/providers/ExperienceProvider.tsx @@ -3,11 +3,11 @@ import { FunctionComponent, PropsWithChildren, useEffect } from 'react'; import { useBeforeUnload } from 'react-use'; import CopyMarker from '@/components/atoms/CopyMarker'; -import { useContextMenu } from '@/features/context_menu'; +import { useContextMenu } from '@/features/browser_core'; +import { PageTitleExperienceHost } from '@/features/browser_core'; import useAdblockerDetector from '@/features/gifts/hooks/useAdblockerDetector'; import { NewsletterModalExperienceHost } from '@/features/newsletter'; import { NotificationPermissionExperienceHost } from '@/features/notification'; -import { PageTitleExperienceHost } from '@/features/page_title'; import { useExperienceFlagsStore } from '@/lib/state/experience_flags'; import { useUserGrantsStore } from '@/lib/state/user_grants'; diff --git a/src/pages/articles/[slug].tsx b/src/pages/articles/[slug].tsx index 8dd8f40..84a997e 100644 --- a/src/pages/articles/[slug].tsx +++ b/src/pages/articles/[slug].tsx @@ -5,8 +5,7 @@ import Head from 'next/head'; import Image from 'next/image'; import { useTranslation } from 'next-i18next'; -import { ArticleService } from '@/features/articles'; -import { PartitionalLockedContent } from '@/features/content_limiter'; +import { ArticleService, PartitionalLockedContent } from '@/features/content'; import { useExperienceFlagsStore } from '@/lib/state/experience_flags'; import { getI18nProps } from '@/lib/utils/i18n'; import styles from '@/styles/content.module.css'; diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 66b3ab5..d9708a0 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -6,7 +6,7 @@ import { DenseTextList, LargeCoverItem, SmallCoverListItem, -} from '@/features/articles'; +} from '@/features/content'; import { OneByOneGift } from '@/features/gifts'; import { makeI18nStaticProps } from '@/lib/utils/i18n'; diff --git a/src/pages/search.tsx b/src/pages/search.tsx index def89af..967d79e 100644 --- a/src/pages/search.tsx +++ b/src/pages/search.tsx @@ -8,7 +8,7 @@ import DotDotDotText from '@/components/atoms/DotDotDotText'; import PageHeadline from '@/components/atoms/PageHeadline'; import SiteTitle from '@/components/atoms/SiteTitle'; import SearchForm from '@/components/organisms/SearchForm'; -import { ArticleSearchResult, ArticleService } from '@/features/articles'; +import { ArticleSearchResult, ArticleService } from '@/features/content'; import { useExperienceFlagsStore } from '@/lib/state/experience_flags'; import { arrayShuffle } from '@/lib/utils/array'; import { makeI18nStaticProps } from '@/lib/utils/i18n';