-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
266 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { css } from 'styled-components'; | ||
|
||
import { RadioButtonProps } from '@/Component/Common/RadioButton/RadioButton'; | ||
import { fontSizes } from '@/style/theme/size'; | ||
export const sizeToRadioButtonStyles = ( | ||
buttonSize: RadioButtonProps['buttonSize'] | ||
) => { | ||
switch (buttonSize) { | ||
case 'xs': | ||
return { | ||
fontSize: '12px', | ||
lineHeight: '1.2', | ||
minHeight: '20px', | ||
}; | ||
|
||
case 'sm': | ||
return { | ||
fontSize: fontSizes.xs, | ||
lineHeight: '1.4', | ||
minHeight: '25px', | ||
}; | ||
|
||
case 'md': | ||
return { | ||
fontSize: fontSizes.sm, | ||
lineHeight: '1.6', | ||
minHeight: '30px', | ||
}; | ||
|
||
case 'lg': | ||
return { | ||
fontSize: fontSizes.md, | ||
lineHeight: '1.8', | ||
minHeight: '35px', | ||
}; | ||
|
||
case 'xl': | ||
return { | ||
fontSize: fontSizes.lg, | ||
lineHeight: '2.0', | ||
minHeight: '40px', | ||
}; | ||
|
||
default: | ||
return { | ||
lineHeight: '1.6', | ||
minHeight: '30px', | ||
}; | ||
} | ||
}; | ||
export const getRadioButtonStyle = (props: RadioButtonProps) => { | ||
const size = props?.buttonSize ?? 'sm'; | ||
const getSizeStyle = sizeToRadioButtonStyles(size); | ||
const color = props?.isInValid ? '#E53E3E' : props?.colorScheme ?? 'inherit'; | ||
|
||
return css` | ||
color: ${color}; | ||
border-radius: 0; | ||
${getSizeStyle}; | ||
${props?.isDisabled && | ||
css` | ||
color: #e0e0e0; | ||
cursor: not-allowed; | ||
`} | ||
${props?.isInValid && | ||
css` | ||
color: #e53e3e; | ||
`} | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { BarChart, YAxis, Tooltip, Bar, CartesianGrid } from 'recharts'; | ||
|
||
import Flex from '@/Component/Common/Flex/Flex'; | ||
import useGetUserSessionInfoQuery from '@/hooks/queries/useGetUserSessionInfoQuery'; | ||
|
||
const UserSessionInfo = () => { | ||
const { data } = useGetUserSessionInfoQuery(); | ||
//city,value | ||
|
||
const cityScreenPageViewPerSessionData = data?.rows?.map((row) => { | ||
return { | ||
x: row?.dimensionValues?.[0]?.value, | ||
y: row?.metricValues?.[0]?.value, | ||
}; | ||
}); | ||
|
||
return ( | ||
<Flex flexDirection="column"> | ||
<h2>유저당 한 세션당 방문한 페이지 그래프</h2> | ||
<BarChart | ||
width={730} | ||
height={250} | ||
data={cityScreenPageViewPerSessionData} | ||
> | ||
<CartesianGrid strokeDasharray="3 3" /> | ||
<YAxis tick={{ fontSize: 12 }} /> | ||
<Tooltip | ||
formatter={(_value, _name, props) => { | ||
return `${props.payload.x}에서 ${_value}개의 View`; | ||
}} | ||
></Tooltip> | ||
|
||
<Bar dataKey="y" fill="#8884d8" barSize={200} /> | ||
</BarChart> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default UserSessionInfo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import RadioButton from '@/Component/Common/RadioButton/RadioButton'; | ||
|
||
const meta: Meta<typeof RadioButton> = { | ||
title: '라디오 버튼 컴포넌트', | ||
component: RadioButton, | ||
tags: ['autodocs'], | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
argTypes: { | ||
value: { | ||
defaultValue: '라디오버튼', | ||
description: '라디오버튼에 들어갈 값입니다. 숫자나 문자열이 들어갑니다.', | ||
control: { | ||
type: 'text', | ||
}, | ||
}, | ||
colorScheme: { | ||
description: '라디오 버튼의 색상 스킴입니다.', | ||
control: { | ||
type: 'color', | ||
}, | ||
}, | ||
buttonSize: { | ||
description: '라디오 버튼의 크기를 설정합니다.', | ||
control: { | ||
type: 'select', | ||
options: ['xs', 'sm', 'md', 'lg', 'xl'], | ||
}, | ||
}, | ||
isDisabled: { | ||
description: '라디오 버튼을 비활성화할지 여부입니다.', | ||
control: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
isInValid: { | ||
description: '라디오 버튼이 유효한지 여부를 나타냅니다.', | ||
control: { | ||
type: 'boolean', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof RadioButton>; | ||
|
||
export const BaseRadioButton: Story = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import React, { CSSProperties, ComponentPropsWithoutRef } from 'react'; | ||
|
||
import styled from 'styled-components'; | ||
|
||
import { | ||
getRadioButtonStyle, | ||
sizeToRadioButtonStyles, | ||
} from '@/@types/RadioButton.styles'; | ||
import Flex from '@/Component/Common/Flex/Flex'; | ||
|
||
type ExcludeSizePropsFromInput = Omit< | ||
ComponentPropsWithoutRef<'input'>, | ||
'size' | ||
>; | ||
|
||
type buttonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'; | ||
|
||
export interface RadioButtonProps extends ExcludeSizePropsFromInput { | ||
readonly colorScheme?: CSSProperties['color']; | ||
readonly buttonSize?: buttonSize; | ||
readonly isDisabled?: boolean; | ||
readonly value?: string | number | readonly string[]; | ||
readonly isInValid?: boolean; | ||
} | ||
|
||
const StyledRadioButton = styled.input<RadioButtonProps>` | ||
${(props) => getRadioButtonStyle(props)} | ||
`; | ||
|
||
const StyledRadioButtonLabel = styled.label<RadioButtonProps>` | ||
${(props) => getRadioButtonStyle(props)} | ||
`; | ||
|
||
export default function RadioButton({ | ||
colorScheme, | ||
buttonSize, | ||
value, | ||
isDisabled = false, | ||
isInValid = false, | ||
...rest | ||
}: RadioButtonProps) { | ||
return ( | ||
<Flex | ||
{...rest} | ||
alignItems="center" | ||
gap="2px" | ||
style={{ | ||
cursor: 'pointer', | ||
...rest.style, | ||
}} | ||
> | ||
<StyledRadioButton | ||
type="radio" | ||
colorScheme={colorScheme} | ||
value={value?.toString()} | ||
isInValid={isInValid} | ||
isDisabled={isDisabled} | ||
></StyledRadioButton> | ||
|
||
<StyledRadioButtonLabel | ||
htmlFor={value?.toString()} | ||
colorScheme={colorScheme} | ||
buttonSize={buttonSize} | ||
isInValid={isInValid} | ||
isDisabled={isDisabled} | ||
style={rest.style} | ||
> | ||
{value?.toString()} | ||
</StyledRadioButtonLabel> | ||
</Flex> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { gaQueryOptions } from '@/hooks/queries/queryKey'; | ||
|
||
export default function useGetUserSessionInfoQuery() { | ||
return useQuery(gaQueryOptions.visitedUserSession()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters