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

추가 변경사항 합병 #172

Merged
merged 7 commits into from
Sep 29, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Fix(main): 티어 그래프 관련 스타일 수정
Dobbymin committed Sep 29, 2024
commit 49e496c03e2825797a8ac9351434e619fc15a224
56 changes: 38 additions & 18 deletions src/pages/main/components/tier/index.tsx
Original file line number Diff line number Diff line change
@@ -6,9 +6,10 @@ import ProfileImg from '@/assets/main/ZZAN-Profile.png';
import { getTierDetails } from '@/constants/data/tierSchema';
import { useInfoStore } from '@/store/useInfoStore';
import * as Base from '@/styles/baseStyles';
import { Box } from '@chakra-ui/react';
import styled from '@emotion/styled';

const Tier = () => {
// const [userInfo, setUserInfo] = useState<UserData | null>(null);
const { userInfo, setUserInfo } = useInfoStore();

useEffect(() => {
@@ -17,6 +18,7 @@ const Tier = () => {
const response = await getUserInfo();
const userData = response.data;
setUserInfo(userData);
console.log(userData);
} catch (error) {
console.error('fetchUserInfo error: ', error);
}
@@ -28,6 +30,10 @@ const Tier = () => {
? getTierDetails(userInfo?.tierInfo.tier)
: { color: 'var(--color-class-02)' };

const currentExp = userInfo?.tierInfo.currentExp || 0;
const totalExp = userInfo?.tierInfo.totalExp || 1;
const expPercentage = (currentExp / totalExp) * 100;

return (
<>
<Base.Text
@@ -61,29 +67,43 @@ const Tier = () => {
<Base.Text color={tierDetails?.color} fontWeight='700'>
{userInfo?.tierInfo.tier}
</Base.Text>
<Base.Text color={tierDetails?.color} fontWeight='1rem'>
{userInfo?.tierInfo.currentExp}
</Base.Text>
</Base.Container>
</Base.Container>
</S.InfoContainer>
<Base.TotalTierGraph
width='100%'
mgColumn='1rem'
mgRow='0'
height='0.3125rem'
radius='0.125rem'
>
<Base.CurrentTierGraph
width='1rem'
height='0.3125rem'
radius='0.125rem'
bgColor={tierDetails?.color}
/>
</Base.TotalTierGraph>
<Box margin={4} position='relative'>
<TotalGraph>
<CurrentGraph
width={`${expPercentage}%`}
backgroundColor={tierDetails?.color || '#000'}
/>
</TotalGraph>
</Box>
</S.TierLayout>
</>
);
};

export default Tier;

const TotalGraph = styled(Box)`
position: 'relative';
display: flex;
text-align: center;
align-items: center;
margin: 1rem 0;
height: 1rem;
border-radius: 0.5rem;
background-color: #000;
box-shadow: 0px 4px 4px 0px rgba(0, 0, 0, 0.25);
`;

const CurrentGraph = styled(Box)<{ backgroundColor: string }>`
height: 1rem;
position: 'absolute';
border-radius: 0.25rem;
background-color: ${(props) => props.backgroundColor};
/* background-color: ${(props) =>
`linear-gradient(45deg, #4e4e4e 0%, ${props.backgroundColor} 50%)` ||
`linear-gradient(90deg, ${props.backgroundColor} 0%, #b28854 50%)`}; */
width: ${(props) => props.width};
`;
2 changes: 1 addition & 1 deletion src/pages/main/components/tier/styles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from '@emotion/styled';

export const TierLayout = styled.div<{ height?: string }>`
height: 9.3125rem;
height: 10rem;
flex-shrink: 0;
margin: 1rem 1rem 3rem 1rem;
border-radius: 1.25rem;