Skip to content
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

Apply styles for WYSIWYG content #64

Merged
merged 2 commits into from
Apr 25, 2024
Merged
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
9 changes: 5 additions & 4 deletions src/app/[locale]/page/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { notFound } from 'next/navigation';
import { getPage } from '@/api/page';

import SiteFooter from '@/components/site-footer';

type Props = {
params: {
slug: string;
Expand All @@ -16,8 +14,11 @@ export default async function FlatPage({ params: { slug } }: Props) {
}
return (
<>
<h1 className="text-lg font-bold lg:text-2xl">{content.title}</h1>
<div dangerouslySetInnerHTML={{ __html: content.content }} />
<h1 className="text-xl font-bold lg:text-3xl">{content.title}</h1>
<div
className="is-WYSIWYG after:clear-both after:table after:content-['']"
dangerouslySetInnerHTML={{ __html: content.content }}
/>
</>
);
}
82 changes: 82 additions & 0 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,85 @@ just hide all tooltips that aren't the last one
background-position-x: 0%;
}
}

.is-WYSIWYG h2 {
@apply my-6 lg:my-8;
@apply clear-both text-xl font-bold tracking-tight lg:text-2xl;
}

.is-WYSIWYG h3 {
@apply my-4 lg:my-6;
@apply clear-both text-xl tracking-tight lg:text-2xl;
}

.is-WYSIWYG h4 {
@apply my-3 lg:my-5;
@apply text-lg font-bold tracking-tight lg:text-xl;
}

.is-WYSIWYG h5,
.is-WYSIWYG h6 {
@apply my-2 lg:my-4;
@apply text-lg tracking-tight lg:text-xl;
}

.is-WYSIWYG p {
@apply mb-6 lg:mb-8;
}

.is-WYSIWYG blockquote {
@apply my-3 lg:my-5 flex gap-4 text-lg text-foreground/75 italic;
}

.is-WYSIWYG blockquote p:last-child {
@apply mb-0;
}

.is-WYSIWYG blockquote::before {
content: "“";
@apply text-5xl;
}

.is-WYSIWYG .information {
@apply py-2 px-4 lg:py-4 lg:px-8 bg-muted;
}

.is-WYSIWYG iframe,
.is-WYSIWYG video {
@apply my-6 w-full h-auto lg:my-10 aspect-video;
}

.is-WYSIWYG .image {
@apply clear-both overflow-hidden lg:mb-8;
}

.is-WYSIWYG .image:not(.align-left):not(.align-right) img {
@apply w-full;
}

.is-WYSIWYG .align-left {
@apply mb-8 lg:float-start lg:mr-10 lg:mb-8 lg:w-min;
}

.is-WYSIWYG .align-right {
@apply mb-8 lg:float-end lg:ml-10 lg:mb-8 lg:w-min;
}

.is-WYSIWYG .align-left img,
.is-WYSIWYG .align-right img {
@apply mt-2;
max-width: revert-layer;
}

@media (max-width: 1024px) {
.is-WYSIWYG .align-left img,
.is-WYSIWYG .align-right img {
@apply w-auto max-w-full;
}
}

.is-WYSIWYG .align-left figcaption,
.is-WYSIWYG .align-right figcaption,
.is-WYSIWYG .image figcaption {
@apply text-sm mt-1 text-center;
}