Skip to content

Commit

Permalink
✨Introduce singlecolumn option for news #2772 (#2775)
Browse files Browse the repository at this point in the history
  • Loading branch information
millianapia authored Feb 3, 2025
1 parent 5c7e1de commit 6146e1e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
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

0 comments on commit 6146e1e

Please sign in to comment.