Skip to content

Commit

Permalink
refactor: 이미지 컴포넌트 마저 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
sap03110 committed Dec 5, 2023
1 parent 28e4122 commit 037aa1d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/components/ui/image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const Image = ({
className={classNames('image', className)}
>
<img
src={src.includes('//') ? src : IMAGE_URL + src}
src={src?.includes('//') ? src : IMAGE_URL + src}
alt={alt}
{...(isLazy && {
loading: 'lazy',
Expand Down
1 change: 1 addition & 0 deletions src/components/ui/my-page/magazine-slide.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const sliderStyle = css`
.image {
width: 100%;
height: 90px;
border-radius: 0;
}
> span {
Expand Down
12 changes: 8 additions & 4 deletions src/components/ui/my-page/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import { VscActivateBreakpoints } from 'react-icons/vsc';
import { FaUserPlus } from 'react-icons/fa';

import { Link } from 'react-router-dom';
import { css } from '@emotion/react';
import Button from '../button';
import ScrapSheet from '@/components/ui/my-page/scrap-sheet';
import { MyProfileAtom } from '@/store/my-profile';
import { ROOT_PATH } from '@/temp/global-variables';
import { formatNumber } from '@/lib/utils';
import { IMAGE_URL } from '@/apis/urls';
import Image from '../image';

const HeaderWrapper = styled.div`
display: flex;
Expand Down Expand Up @@ -46,8 +47,10 @@ const ProfileImageBox = styled.div`
}
`;

const ProfileImage = styled.img`
const imageStyle = css`
border-radius: 6px;
width: 100%;
height: 100%;
`;

const UserInfoArea = styled.div`
Expand Down Expand Up @@ -173,9 +176,10 @@ const MyPageProfile = () => {
return (
<HeaderWrapper>
<ProfileImageBox>
<ProfileImage
src={IMAGE_URL + myProfile.profileUrl}
<Image
src={myProfile.profileUrl}
alt="Profile Image"
css={imageStyle}
/>
<Link to="../profile">
<Button className="edit-button">수정</Button>
Expand Down
3 changes: 2 additions & 1 deletion src/components/ui/my-page/subscriber-update-slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const sliderStyle = css`
border-radius: 4px;
position: relative;
overflow: hidden;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
> img {
width: 100%;
height: 90px;
Expand Down Expand Up @@ -82,6 +82,7 @@ const sliderStyle = css`

const imageStyle = css`
width: 100%;
border-radius: 0;
`;

interface SlideProps {
Expand Down
13 changes: 8 additions & 5 deletions src/components/ui/your-page/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import { Link } from 'react-router-dom';
import { useState, useEffect, useLayoutEffect } from 'react';
import { FaUserPlus } from 'react-icons/fa';
import { useSetAtom, useAtom, useAtomValue } from 'jotai';
import { css } from '@emotion/react';
import { YourProfileAtom } from '@/store/your-profile';
import { titleAtom } from '@/store/page-info';
import { ROOT_PATH } from '@/temp/global-variables';
import { fetch } from '@/apis/api';
import { formatNumber } from '@/lib/utils';
import { postFollow } from '@/apis/consumer';
import { MyProfileAtom } from '@/store/my-profile';
import { IMAGE_URL } from '@/apis/urls';
import Image from '../image';

const HeaderWrapper = styled.div`
display: flex;
Expand Down Expand Up @@ -44,9 +45,10 @@ const ProfileImageBox = styled.div`
}
`;

const ProfileImage = styled.img`
const imageStyle = css`
border-radius: 6px;
min-height: 100px;
width: 100%;
height: 100%;
`;

const UserInfoArea = styled.div`
Expand Down Expand Up @@ -188,9 +190,10 @@ const YourPageProfile = () => {
return (
<HeaderWrapper>
<ProfileImageBox>
<ProfileImage
src={IMAGE_URL + yourProfile.profileUrl}
<Image
src={yourProfile.profileUrl}
alt="Profile Image"
css={imageStyle}
/>
</ProfileImageBox>
<UserInfoArea>
Expand Down

0 comments on commit 037aa1d

Please sign in to comment.