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

✨Introduce singlecolumn option for news #2772 #2775

Merged
merged 1 commit into from
Feb 3, 2025
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
8 changes: 7 additions & 1 deletion sanityv3/schemas/objects/factbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ export default {
type: 'array',
of: [blockContentType],
},
{
name: 'isSingleColumn',
type: 'boolean',
title: 'Single column layout',
description: 'Toggle to use a single-column layout instead of the default two-column layout. This will have no effect if image is selected',
},
{
name: 'image',
title: 'Image',
Expand Down Expand Up @@ -108,4 +114,4 @@ export default {
}
},
},
}
}
3 changes: 0 additions & 3 deletions web/components/src/Fact/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { Image } from './Image'
import { Content } from './Content'

export type FactImagePosition = 'left' | 'right'
// @TODO: Color mapping must be more generic than this!!!
// Find a better way to do this.
// Create a proper type for colors

type FactBoxCompoundProps = typeof FactBoxWrapper & {
Image: typeof Image
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type FactboxProps = {
image: ImageWithAlt
imagePosition: FactImagePosition
dynamicHeight: boolean
isSingleColumn?: boolean
}

type BlockProps = {
Expand All @@ -25,7 +26,7 @@ type BlockProps = {

export const Fact = (block: BlockProps) => {
const { value, className } = block
const { title, content, background, image, imagePosition, dynamicHeight } = value
const { title, content, background, image, imagePosition, dynamicHeight, isSingleColumn } = value

const bgTitle = (background ? background?.title : 'White') as BackgroundColours
if (!content || content.length === 0) {
Expand All @@ -36,7 +37,7 @@ export const Fact = (block: BlockProps) => {

const plainText = content ? toPlainText(content as PortableTextBlock[]) : ''

const hasColumns = !imageSrc && plainText.length > 800
const hasColumns = !imageSrc && !isSingleColumn && plainText.length > 800
const hasImage = imageSrc ? true : false
const hasBgColor = bgTitle !== 'White'

Expand Down
Loading