Skip to content

Commit

Permalink
Merge branch 'main' into vaash/2528
Browse files Browse the repository at this point in the history
  • Loading branch information
VarunVAshrit authored Oct 23, 2024
2 parents 262da2b + 76108b1 commit d59882a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
21 changes: 21 additions & 0 deletions sanityv3/migrations/issue-2533/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { at, defineMigration, unset, insertBefore } from 'sanity/migrate'

export default defineMigration({
title: 'Issue 2533',
documentTypes: ['page', 'magazine'],

migrate: {
array(node, path, _context) {
if (path[0] === 'content')
return node
.filter((it) => (it._type === 'textBlock' || it._type === 'accordion') && it.anchor != null)
.filter((e) => !!e)
.map((item) => {
return [
insertBefore([{ _type: 'anchorLink', anchorReference: item.anchor }], { _key: item._key }),
at([{ _key: item._key }, 'anchor'], unset()),
]
})
},
},
})
13 changes: 0 additions & 13 deletions sanityv3/schemas/objects/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { AccordionComponent } from '../../icons'
import CompactBlockEditor from '../components/CompactBlockEditor'
import { configureTitleBlockContent } from '../editors'
import { configureBlockContent } from '../editors/blockContentType'
import { validateComponentAnchor } from '../validations/validateAnchorReference'
import type { ColorSelectorValue } from '../components/ColorSelector'

export type Accordion = {
Expand Down Expand Up @@ -80,18 +79,6 @@ export default {
hotspot: true,
},
},
{
name: 'anchor',
type: 'anchorReferenceField',
title: 'Anchor reference',
validation: (Rule: Rule) => [
Rule.max(0).warning('Clear this field and use anchor link component instead.'),
// @ts-ignore
Rule.custom((value: string, context: any) => validateComponentAnchor(value, context)),
],
fieldset: 'anchor',
readOnly: ({ value }: { value?: string }) => !value,
},
{
title: 'Accordion items',
name: 'accordion',
Expand Down
5 changes: 4 additions & 1 deletion web/components/src/Backgrounds/ImageBackgroundContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const ImageBackgroundContainer = forwardRef<HTMLDivElement, ImageBackgrou
className = '',
scrimClassName = '',
dontSplit = false,
...rest
},
ref,
) {
Expand Down Expand Up @@ -79,6 +80,7 @@ export const ImageBackgroundContainer = forwardRef<HTMLDivElement, ImageBackgrou
'--color-on-background': `var(--inverted-text)`,
} as CSSProperties
}
{...rest}
>
{/** Scrim */}
<div
Expand All @@ -95,7 +97,7 @@ export const ImageBackgroundContainer = forwardRef<HTMLDivElement, ImageBackgrou
</div>
</div>
) : isMobile && !dontSplit ? (
<div ref={ref}>
<div ref={ref} {...rest}>
<div
className={twMerge(`aspect-video`, backgroundClassNames)}
style={{
Expand All @@ -111,6 +113,7 @@ export const ImageBackgroundContainer = forwardRef<HTMLDivElement, ImageBackgrou
style={{
backgroundImage: `url(${src})`,
}}
{...rest}
>
{/** Scrim */}
<div
Expand Down
1 change: 0 additions & 1 deletion web/lib/queries/common/pageContentFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ _type == "keyNumbers" =>{
${markDefs},
}
},
anchor,
"designOptions": {
${background},
}
Expand Down
2 changes: 1 addition & 1 deletion web/pageComponents/topicPages/Accordion/AccordionBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const AccordionBlock = ({ data, anchor, className }: AccordionBlockProps) => {

return (
<>
<StyledTextBlockWrapper {...designOptions} id={anchor || data.anchor} renderFragmentWhenPossible>
<StyledTextBlockWrapper {...designOptions} id={anchor} renderFragmentWhenPossible>
<div
className={twMerge(
`flex flex-col gap-6 max-w-viewport mx-auto pb-page-content px-layout-lg [&_svg]:inline [&_svg]:align-baseline`,
Expand Down
1 change: 0 additions & 1 deletion web/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ export type AccordionData = {
title: PortableTextBlock[]
ingress: PortableTextBlock[]
accordion: AccordionListData[]
anchor?: string
designOptions: DesignOptions
enableStructuredMarkup?: boolean
}
Expand Down

0 comments on commit d59882a

Please sign in to comment.