Skip to content

Commit

Permalink
Add some UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
maksugr committed Jul 12, 2024
1 parent d6900b6 commit e1d3cf9
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 6 deletions.
2 changes: 2 additions & 0 deletions share/constants/word.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const WORDS_PER_PAGE = 10;
export const WORDS_FOLDER_NAME = 'words';
export const WORDS_FILE_EXTENSION = 'mdx';

export const TOO_LONG_WORDS = ['handschuhschneeballwerfer'];
5 changes: 5 additions & 0 deletions share/utils/words.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { CompileMDXResult, compileMDX } from 'next-mdx-remote/rsc';
import { notFound } from 'next/navigation';

import {
TOO_LONG_WORDS,
WORDS_FILE_EXTENSION,
WORDS_FOLDER_NAME,
WORDS_PER_PAGE,
Expand Down Expand Up @@ -135,6 +136,10 @@ export const compileWordMarkdown = async (
});
};

export const isTooLongWord = (word: string): boolean => {
return TOO_LONG_WORDS.includes(word.toLowerCase());
};

const removeWordFileExtension = (wordFileName: string): string => {
return wordFileName.split(`.${WORDS_FILE_EXTENSION}`)[0];
};
10 changes: 8 additions & 2 deletions src/app/toc/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Metadata } from 'next';
import Link from 'next/link';

import { METADATA } from '../../../share/constants/metadata';
import { getAllWords } from '../../../share/utils/words';
import { getAllWords, isTooLongWord } from '../../../share/utils/words';
import { sortGermanWordsByTitle } from '../../../share/utils/sorts';
import { IWord } from '../../../share/interfaces/words';
import { RouteEnum } from '../../../share/enums/route';
Expand Down Expand Up @@ -38,7 +38,13 @@ export default async function TOCPage() {
<Link
href={`/${RouteEnum.WORDS}/${word.slug}`}
key={word.frontmatter.title}
className="font-thunder text-5xl text-main-white outfit hyphens-auto"
className={`font-thunder text-5xl text-main-white mb-6 hyphens-auto ${
isTooLongWord(
word.frontmatter.title
)
? 'break-all'
: ''
}`}
>
{word.frontmatter.title}
</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/components-client/MoreWords/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const MoreWords: React.FC<IMoreWordsProps> = ({ getMore }) => {
}}
hasMore={!isEnd}
loader={
<div className="flex justify-center">
<div className="flex justify-center" key={0}>
<Loader color={ColorEnum.MAIN_WHITE} />
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion src/components-server/Footer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Links } from '../Links';

export const Footer = () => {
return (
<footer className="w-full mt-auto border-t-4 border-main-white p-10">
<footer className="w-full mt-auto border-t-4 border-main-white p-6 md:p-10">
<Links />
</footer>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components-server/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const Layout: React.FC<ILayoutProps> = ({ children }) => {
return (
<>
<Header />
<main className="flex flex-col w-full p-10">{children}</main>
<main className="flex flex-col w-full p-6 md:p-10">{children}</main>
<Footer />
</>
);
Expand Down
7 changes: 6 additions & 1 deletion src/components-server/Word/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RouteEnum } from '../../../share/enums/route';
import { dayjs } from '../../../share//utils/dayjs';
import {
getRelativeLinkText,
isTooLongWord,
wordNameToSlug,
} from '../../../share/utils/words';
import {
Expand All @@ -20,7 +21,11 @@ export const Word: React.FC<IWordProps> = async ({ word }) => {
return (
<section className="font-thunder bg-main-white border-4 border-main-white rounded-lg p-6">
<section className="flex flex-col justify-between items-start gap-4 mdx-content">
<h1 className="outfit text-8xl hyphens-auto">
<h1
className={`text-8xl hyphens-auto ${
isTooLongWord(frontmatter.title) ? 'break-all' : ''
}`}
>
<Link href={`/${RouteEnum.WORDS}/${slug}`}>
{frontmatter.title}
</Link>
Expand Down

0 comments on commit e1d3cf9

Please sign in to comment.