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

Fix image width and beam click handler #2294

Merged
merged 4 commits into from
May 27, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ProfileBeamsPage: React.FC<ProfileBeamsPageProps> = props => {
})
}
showNSFWCard={itemData.node.nsfw}
showHiddenContent={true}
showHiddenContent={false}
/>
);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const EntryCard: React.FC<EntryCardProps> = props => {
{entryData.active && (
<ErrorBoundary {...errorBoundaryProps}>
<Card
onClick={!showNSFWContent ? null : onContentClick}
onClick={!showNSFWContent || !noWrapperCard ? null : onContentClick}
customStyle={contentClickableStyle}
type="plain"
>
Expand Down Expand Up @@ -294,7 +294,12 @@ const EntryCard: React.FC<EntryCardProps> = props => {
return noWrapperCard ? (
<> {entryCardUi}</>
) : (
<Card ref={ref} padding="p-0" customStyle={customStyle}>
<Card
ref={ref}
padding="p-0"
customStyle={customStyle}
onClick={!showNSFWContent ? null : onContentClick}
>
{entryCardUi}
</Card>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const ImageBlockGridItem: React.FC<IGridItemProps> = props => {
>
{/* when we have a single image we need to keep the original aspect ratio,
otherwise give images a 1:1 ratio */}
<picture className={tw('flex')}>
<picture className={tw('flex w-full')}>
<source srcSet={imageSrc?.originalSrc} />

<img
Expand All @@ -59,7 +59,7 @@ export const ImageBlockGridItem: React.FC<IGridItemProps> = props => {
loading="lazy"
decoding="async"
alt={'placeholder'}
className={tx(`rounded object-cover w-full ${heightStyle} ${multipleImageStyle}`)}
className={tx(`rounded object-cover w-full ${heightStyle} ${multipleImageStyle}`)}
src={'/images/image-placeholder.webp'}
height={images.length === 1 ? imageSrc?.size?.height : ''}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ const ContentBlockRenderer: React.FC<ContentBlockRendererProps> = props => {
beamIsNsfw,
showBlockName,
onBlockInfoChange,
onContentClick,
} = props;
const { navigateToModal, getExtensionsPlugin, getRoutingPlugin } = useRootComponentProps();
const contentBlockStoreRef = useRef(getExtensionsPlugin()?.contentBlockStore);
Expand All @@ -48,7 +47,6 @@ const ContentBlockRenderer: React.FC<ContentBlockRendererProps> = props => {
}, [contentBlockReq.data]);
const contentBlockPropertyType = blockData?.content?.[0]?.propertyType;
const contentBlockLabel = blockData?.content?.[0]?.label;
const nsfw = !!blockData?.nsfw;
useEffect(() => {
_onBlockInfoChange.current?.({
appName: BLOCK_LABEL_TO_APP_DISPLAY_NAME_MAP[contentBlockLabel],
Expand Down Expand Up @@ -94,17 +92,7 @@ const ContentBlockRenderer: React.FC<ContentBlockRendererProps> = props => {
};

return (
<Card
type="plain"
onClick={() => {
if (!(showNSFWCard && nsfw)) {
if (typeof onContentClick === 'function') {
onContentClick();
}
}
}}
customStyle="w-full"
>
<Card type="plain" customStyle="w-full">
{!showNSFWCard && (
<>
<Transition
Expand Down
2 changes: 1 addition & 1 deletion libs/feed/src/components/cards/beam-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const BeamCard: React.FC<BeamCardProps> = props => {
}
onReflect();
}}
onContentClick={onContentClick}
onEntryFlag={handleFlagBeam}
profileAvatarExt={
<AuthorProfileAvatar
Expand Down Expand Up @@ -139,7 +140,6 @@ const BeamCard: React.FC<BeamCardProps> = props => {
setAppName(blockInfo?.appName);
setBlockNameMap(new Map(blockNameMap.set(blockID, blockInfo?.blockName)));
}}
onContentClick={onContentClick}
/>
</React.Suspense>
)}
Expand Down