Skip to content

Commit

Permalink
Merge pull request #563 from papermark/feat/collection-card
Browse files Browse the repository at this point in the history
feat: add `card_cover_position` to collection card
  • Loading branch information
transitive-bullshit authored Oct 3, 2024
2 parents e1f03de + 28f5300 commit c862db0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/react-notion-x/src/third-party/collection-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export const CollectionCard: React.FC<CollectionCardProps> = ({
} = ctx
let coverContent = null

const { page_cover_position = 0.5 } = block.format || {}
const { page_cover_position = 0.5, card_cover_position = 0.5 } = block.format || {}

Check failure on line 32 in packages/react-notion-x/src/third-party/collection-card.tsx

View workflow job for this annotation

GitHub Actions / build-minimal

Property 'card_cover_position' does not exist on type '{ page_full_width?: boolean; page_small_text?: boolean; page_cover_position?: number; block_locked?: boolean; block_locked_by?: string; page_cover?: string; page_icon?: string; block_color?: Color; }'.

Check failure on line 32 in packages/react-notion-x/src/third-party/collection-card.tsx

View workflow job for this annotation

GitHub Actions / build-full

Property 'card_cover_position' does not exist on type '{ page_full_width?: boolean; page_small_text?: boolean; page_cover_position?: number; block_locked?: boolean; block_locked_by?: string; page_cover?: string; page_icon?: string; block_color?: Color; }'.

Check failure on line 32 in packages/react-notion-x/src/third-party/collection-card.tsx

View workflow job for this annotation

GitHub Actions / test

Property 'card_cover_position' does not exist on type '{ page_full_width?: boolean; page_small_text?: boolean; page_cover_position?: number; block_locked?: boolean; block_locked_by?: string; page_cover?: string; page_icon?: string; block_color?: Color; }'.
const coverPosition = (1 - page_cover_position) * 100
const cardCoverPosition = (1 - card_cover_position) * 100

if (cover?.type === 'page_content') {
const contentBlockId = block.content?.find((blockId) => {
Expand All @@ -57,7 +58,8 @@ export const CollectionCard: React.FC<CollectionCardProps> = ({
src={src}
alt={caption || 'notion image'}
style={{
objectFit: coverAspect
objectFit: coverAspect,
objectPosition: `center ${cardCoverPosition}%`
}}
/>
)
Expand Down

0 comments on commit c862db0

Please sign in to comment.