Skip to content

Commit

Permalink
fix(ArticleDetail): revise variable name
Browse files Browse the repository at this point in the history
  • Loading branch information
wlliaml committed Jan 11, 2024
1 parent 5dfa72b commit fbec1c7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
11 changes: 6 additions & 5 deletions src/components/ArticleDigest/AuthorSidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type ArticleDigestAuthorSidebarProps = {
collectionId?: string
titleTextSize?: ArticleDigestTitleTextSize
titleColor?: 'greyDarker' | 'black'
imageSize?: 44 | 64
imageSize?: 'sm' | 'md'
}

const fragments = {
Expand All @@ -39,15 +39,15 @@ export const ArticleDigestAuthorSidebar = ({

titleTextSize = 'mdS',
titleColor = 'greyDarker',
imageSize = 44,
imageSize = 'sm',
}: ArticleDigestAuthorSidebarProps) => {
const { articleState: state } = article
const isBanned = state === 'banned'
const cover = !isBanned ? article.cover : null
const containerClasses = classNames({
[styles.container]: true,
[styles.hasCover]: !!cover,
[styles[`imageSize${imageSize}`]]: !!cover,
[styles[`imageSize${capitalizeFirstLetter(imageSize)}`]]: !!cover,
})
const path = toPath({
page: 'articleDetail',
Expand All @@ -60,6 +60,7 @@ export const ArticleDigestAuthorSidebar = ({
[styles[`lineHeight${capitalizeFirstLetter(titleTextSize)}`]]:
!!titleTextSize,
})
const imgSize = imageSize === 'sm' ? 44 : 64

return (
<section
Expand All @@ -81,8 +82,8 @@ export const ArticleDigestAuthorSidebar = ({
<aside className={styles.cover}>
<ResponsiveImage
url={cover}
width={imageSize}
height={imageSize}
width={imgSize}
height={imgSize}
disableAnimation={true}
/>
</aside>
Expand Down
4 changes: 2 additions & 2 deletions src/components/ArticleDigest/AuthorSidebar/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
&.hasCover {
position: relative;

&.imageSize44 {
&.imageSizeSm {
min-height: 2.75rem;
padding-right: calc(2.75rem + var(--spacing-loose));

Expand All @@ -45,7 +45,7 @@
}
}

&.imageSize64 {
&.imageSizeMd {
min-height: 4rem;
padding-right: calc(4rem + var(--spacing-loose));

Expand Down
14 changes: 8 additions & 6 deletions src/components/CollectionDigest/AuthorSidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import classNames from 'classnames'
import gql from 'graphql-tag'

import { toPath } from '~/common/utils'
import { capitalizeFirstLetter, toPath } from '~/common/utils'
import {
IconDraft24,
LinkWrapper,
Expand All @@ -14,7 +14,7 @@ import styles from './styles.module.css'

export type CollectionDigestAuthorSidebarProps = {
collection: CollectionDigestAuthorSidebarCollectionFragment
imageSize?: 64
imageSize?: 'md'
}

const fragments = {
Expand All @@ -36,7 +36,7 @@ const fragments = {

export const CollectionDigestAuthorSidebar = ({
collection,
imageSize = 64,
imageSize = 'md',
}: CollectionDigestAuthorSidebarProps) => {
const {
title,
Expand All @@ -48,7 +48,7 @@ export const CollectionDigestAuthorSidebar = ({
const containerClasses = classNames({
[styles.container]: true,
[styles.hasCover]: !!cover,
[styles[`imageSize${imageSize}`]]: !!cover,
[styles[`imageSize${capitalizeFirstLetter(imageSize)}`]]: !!cover,
})

const path = toPath({
Expand All @@ -57,6 +57,8 @@ export const CollectionDigestAuthorSidebar = ({
userName: userName || '',
})

const imgSize = 64

return (
<section className={containerClasses}>
<header>
Expand All @@ -67,8 +69,8 @@ export const CollectionDigestAuthorSidebar = ({
<aside className={styles.cover}>
<ResponsiveImage
url={cover}
width={64}
height={64}
width={imgSize}
height={imgSize}
disableAnimation={true}
/>
<div className={styles.count}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
&.hasCover {
position: relative;

&.imageSize64 {
&.imageSizeMd {
min-height: 4rem;
padding-right: calc(4rem + var(--spacing-loose));

Expand Down
2 changes: 1 addition & 1 deletion src/views/ArticleDetail/AuthorSidebar/FromAuthor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const FromAuthor = ({ article }: FromAuthorProps) => {
article={work}
titleColor="black"
titleTextSize="md"
imageSize={64}
imageSize="md"
/>
)}
{work.__typename === 'Collection' && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const RelatedArticles = ({ article }: RelatedArticlesProps) => {
article={node}
titleColor="black"
titleTextSize="md"
imageSize={64}
imageSize="md"
/>
</List.Item>
))}
Expand Down

0 comments on commit fbec1c7

Please sign in to comment.