aspect ratio in Expo (#347)
This commit is contained in:
parent
dd4dc967bb
commit
70e084c0db
|
@ -107,7 +107,7 @@
|
||||||
height: 0;
|
height: 0;
|
||||||
margin-bottom: 1.6rem;
|
margin-bottom: 1.6rem;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding-bottom: 56.2%;
|
padding-bottom: 56.2%; //16:9
|
||||||
position: relative;
|
position: relative;
|
||||||
transform-origin: 50% 50%;
|
transform-origin: 50% 50%;
|
||||||
transition: transform 1s ease-in-out;
|
transition: transform 1s ease-in-out;
|
||||||
|
@ -267,6 +267,24 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.aspectRatio1x1 {
|
||||||
|
.shoutCardCover {
|
||||||
|
padding-bottom: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.aspectRatio4x3 {
|
||||||
|
.shoutCardCover {
|
||||||
|
padding-bottom: 75%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.aspectRatio16x9 {
|
||||||
|
.shoutCardCover {
|
||||||
|
padding-bottom: 56.25%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.shoutCardType {
|
.shoutCardType {
|
||||||
height: 3.2rem;
|
height: 3.2rem;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
|
@ -46,6 +46,7 @@ export type ArticleCardProps = {
|
||||||
withViewed?: boolean
|
withViewed?: boolean
|
||||||
noAuthorLink?: boolean
|
noAuthorLink?: boolean
|
||||||
}
|
}
|
||||||
|
withAspectRatio?: boolean
|
||||||
desktopCoverSize?: 'XS' | 'S' | 'M' | 'L'
|
desktopCoverSize?: 'XS' | 'S' | 'M' | 'L'
|
||||||
article: Shout
|
article: Shout
|
||||||
}
|
}
|
||||||
|
@ -112,6 +113,22 @@ export const ArticleCard = (props: ArticleCardProps) => {
|
||||||
const [isCoverImageLoading, setIsCoverImageLoading] = createSignal(true)
|
const [isCoverImageLoading, setIsCoverImageLoading] = createSignal(true)
|
||||||
|
|
||||||
const description = getDescription(props.article.body)
|
const description = getDescription(props.article.body)
|
||||||
|
|
||||||
|
const aspectRatio = () => {
|
||||||
|
switch (props.article.layout) {
|
||||||
|
case 'music': {
|
||||||
|
return styles.aspectRatio1x1
|
||||||
|
}
|
||||||
|
case 'image': {
|
||||||
|
return styles.aspectRatio4x3
|
||||||
|
}
|
||||||
|
case 'video':
|
||||||
|
case 'literature': {
|
||||||
|
return styles.aspectRatio16x9
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
class={clsx(styles.shoutCard, props.settings?.additionalClass, {
|
class={clsx(styles.shoutCard, props.settings?.additionalClass, {
|
||||||
|
@ -127,6 +144,7 @@ export const ArticleCard = (props: ArticleCardProps) => {
|
||||||
[styles.shoutCardSingle]: props.settings?.isSingle,
|
[styles.shoutCardSingle]: props.settings?.isSingle,
|
||||||
[styles.shoutCardBeside]: props.settings?.isBeside,
|
[styles.shoutCardBeside]: props.settings?.isBeside,
|
||||||
[styles.shoutCardNoImage]: !props.article.cover,
|
[styles.shoutCardNoImage]: !props.article.cover,
|
||||||
|
[aspectRatio()]: props.withAspectRatio,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Show when={!props.settings?.noimage && !props.settings?.isFeedMode}>
|
<Show when={!props.settings?.noimage && !props.settings?.isFeedMode}>
|
||||||
|
@ -154,7 +172,6 @@ export const ArticleCard = (props: ArticleCardProps) => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Show>
|
</Show>
|
||||||
|
|
||||||
<div class={styles.shoutCardContent}>
|
<div class={styles.shoutCardContent}>
|
||||||
<Show
|
<Show
|
||||||
when={
|
when={
|
||||||
|
|
|
@ -143,7 +143,6 @@ export const Expo = (props: Props) => {
|
||||||
const handleLoadMoreClick = () => {
|
const handleLoadMoreClick = () => {
|
||||||
loadMoreWithoutScrolling(LOAD_MORE_PAGE_SIZE)
|
loadMoreWithoutScrolling(LOAD_MORE_PAGE_SIZE)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class={styles.Expo}>
|
<div class={styles.Expo}>
|
||||||
<Show when={sortedArticles().length > 0} fallback={<Loading />}>
|
<Show when={sortedArticles().length > 0} fallback={<Loading />}>
|
||||||
|
@ -206,6 +205,7 @@ export const Expo = (props: Props) => {
|
||||||
article={shout}
|
article={shout}
|
||||||
settings={{ nodate: true, nosubtitle: true, noAuthorLink: true }}
|
settings={{ nodate: true, nosubtitle: true, noAuthorLink: true }}
|
||||||
desktopCoverSize="XS"
|
desktopCoverSize="XS"
|
||||||
|
withAspectRatio={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -220,6 +220,7 @@ export const Expo = (props: Props) => {
|
||||||
article={shout}
|
article={shout}
|
||||||
settings={{ nodate: true, nosubtitle: true, noAuthorLink: true }}
|
settings={{ nodate: true, nosubtitle: true, noAuthorLink: true }}
|
||||||
desktopCoverSize="XS"
|
desktopCoverSize="XS"
|
||||||
|
withAspectRatio={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -236,6 +237,7 @@ export const Expo = (props: Props) => {
|
||||||
article={shout}
|
article={shout}
|
||||||
settings={{ nodate: true, nosubtitle: true, noAuthorLink: true }}
|
settings={{ nodate: true, nosubtitle: true, noAuthorLink: true }}
|
||||||
desktopCoverSize="XS"
|
desktopCoverSize="XS"
|
||||||
|
withAspectRatio={true}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user