Skip to content

Commit

Permalink
Feat: set different font-size in MiniProfile depending on pages
Browse files Browse the repository at this point in the history
  • Loading branch information
hookor authored and cuconveniencestore committed Aug 29, 2024
1 parent 1c63698 commit 2e6f950
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
28 changes: 23 additions & 5 deletions src/components/common/MiniProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
import ImgContainer from '@/components/common/ImgContainer';
import { TEXT } from '@/constants/texts';
import { MiniProfileProps } from '@/types/types';
import { Column, Flex, FlexCenter, Justify } from '@/styles/layout';
import { LineH18, Semibold } from '@/styles/styles';
import { Between, Column, Flex, FlexCenter, Justify } from '@/styles/layout';
import {
LineH18,
Semibold,
MiniUserTitle,
PostsUserContainer
} from '@/styles/styles';
import { styled } from 'styled-system/jsx';
import { cx } from 'styled-system/css';
import { useNavigateTo } from '@/hooks/useNavigateTo';
import NoProfileImg from '@/components/common/NoProfileImg';
import { useLocation } from 'react-router-dom';

const MiniProfile = ({
url,
Expand All @@ -17,6 +23,8 @@ const MiniProfile = ({
mini = false
}: MiniProfileProps) => {
const toProfilePage = useNavigateTo(`/profile/${userId}`);
const { pathname } = useLocation();
const postsTitle = pathname.startsWith('/post');
return (
<>
<Container className={Flex}>
Expand All @@ -37,8 +45,18 @@ const MiniProfile = ({
/>
)}
</div>
<div className={cx(Column, Justify)}>
<UserTitle className={cx(LineH18, Semibold)}>
<div
className={
post && postsTitle
? cx(Column, Between, PostsUserContainer)
: cx(Column, Justify)
}>
<UserTitle
className={
post && postsTitle
? cx(LineH18, Semibold)
: cx(LineH18, Semibold, MiniUserTitle)
}>
<span onClick={toProfilePage}>{nickname}</span>
</UserTitle>
<UserCaffeine
Expand All @@ -56,9 +74,9 @@ const Container = styled.div`
gap: 12px;
`;
const UserTitle = styled.div`
font-size: var(--font-sizes-sm);
color: var(--colors-main-dark);
`;

const UserCaffeine = styled.div`
font-size: var(--font-sizes-xs);
color: var(--colors-mid-grey);
Expand Down
8 changes: 8 additions & 0 deletions src/styles/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -841,3 +841,11 @@ export const RadioBtnContainer = css`
height: 16px;
position: relative;
`;

export const MiniUserTitle = css`
font-size: var(--font-sizes-sm);
`;

export const PostsUserContainer = css`
padding: 3px 0;
`;

0 comments on commit 2e6f950

Please sign in to comment.