Skip to content

Commit

Permalink
Richtext module adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchell Christ committed Oct 11, 2024
1 parent 6ad21ff commit 5c00b80
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sanitypress",
"version": "4.9.3",
"version": "4.9.4",
"description": "A Next.js + Sanity.io Starter Template",
"author": "nuotsu <mitchell@nuotsu.dev> (https://nuotsu.dev)",
"license": "ISC",
Expand Down
13 changes: 13 additions & 0 deletions sanity/schemas/modules/richtext-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export default defineType({
{ name: 'options', title: 'Options' },
],
fields: [
defineField({
name: 'uid',
title: 'Unique Identifier',
type: 'uid',
group: 'options',
}),
defineField({
name: 'content',
type: 'array',
Expand Down Expand Up @@ -46,6 +52,13 @@ export default defineType({
initialValue: 'right',
group: 'options',
}),
defineField({
name: 'stretch',
type: 'boolean',
initialValue: false,
hidden: ({ parent }) => parent.tableOfContents,
group: 'options',
}),
],
preview: {
select: {
Expand Down
1 change: 0 additions & 1 deletion src/styles/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
.is-external::after {
content: ' ↗';
font-size: 0.7em;
vertical-align: top;
}

/* layout */
Expand Down
6 changes: 3 additions & 3 deletions src/ui/Announcement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export default async function Announcement() {
if (!active) return null

return (
<aside className="flex items-center justify-center gap-x-4 bg-accent p-2 text-center text-canvas max-md:text-sm md:gap-x-6">
<div className="anim-fade-to-r [&_a]:link text-balance">
<aside className="flex items-center justify-center gap-x-4 text-balance bg-accent p-2 text-center text-canvas max-md:text-sm md:gap-x-6">
<div className="anim-fade-to-r [&_a]:link">
<PortableText value={active.content} />
</div>

<CTA className="link anim-fade-to-l shrink-0" link={active.cta} />
<CTA className="link anim-fade-to-l shrink" link={active.cta} />
</aside>
)
}
20 changes: 16 additions & 4 deletions src/ui/modules/RichtextModule/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import moduleProps from '@/lib/moduleProps'
import TableOfContents from './TableOfContents'
import Content from './Content'
import { cn } from '@/lib/utils'
Expand All @@ -7,24 +8,30 @@ export default function RichtextModule({
content,
tableOfContents,
tocPosition = 'right',
stretch,
headings,
...props
}: Partial<{
content: any
tableOfContents: boolean
tocPosition: 'left' | 'right'
stretch: boolean
headings: {
style: string
text: string
}[]
}>) {
const tocRight = tableOfContents && stegaClean(tocPosition) === 'right'
}> &
Sanity.Module) {
const tocRight = stegaClean(tocPosition) === 'right'

return (
<section
className={cn(
'section grid gap-8',
tocRight ? 'lg:grid-cols-[1fr,auto]' : 'lg:grid-cols-[auto,1fr]',
tableOfContents &&
(tocRight ? 'lg:grid-cols-[1fr,auto]' : 'lg:grid-cols-[auto,1fr]'),
)}
{...moduleProps(props)}
>
{tableOfContents && (
<aside
Expand All @@ -37,7 +44,12 @@ export default function RichtextModule({
</aside>
)}

<Content value={content} className="max-w-screen-lg" />
<Content
value={content}
className={cn(
!tableOfContents && (stretch ? 'max-w-screen-lg' : 'max-w-screen-md'),
)}
/>
</section>
)
}

0 comments on commit 5c00b80

Please sign in to comment.