-
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.
Browse files
Browse the repository at this point in the history
Feat/#45/comment notification
- Loading branch information
Showing
56 changed files
with
2,060 additions
and
1,129 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 @@ | ||
v18.14.2 |
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 |
---|---|---|
|
@@ -37,9 +37,17 @@ export const GlobalStyle = () => { | |
font-weight: normal; | ||
font-style: normal; | ||
} | ||
@font-face { | ||
font-family: 'Pretendard'; | ||
src: url('https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.css'); | ||
font-weight: normal; | ||
font-style: normal; | ||
} | ||
body { | ||
font-family: 'Roboto', sans-serif; | ||
font-family: 'Pretendard', sans-serif; | ||
} | ||
// 모바일에서 tap highlight 제거 | ||
// transparent로 하면 안됨 (투명하게 보이는 경우가 있음) | ||
* { | ||
|
124 changes: 124 additions & 0 deletions
124
packages/client/src/components/common/Toggle/Toggle.styles.ts
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,124 @@ | ||
import { NormalColorType, palette } from '~/lib/styles'; | ||
import styled from '@emotion/styled'; | ||
import { css } from '@emotion/react'; | ||
|
||
export const ToggleLabel = styled.label<{ variant: 'sm' | 'lg' }>` | ||
display: flex; | ||
align-items: center; | ||
${({ variant }) => | ||
variant === 'sm' && | ||
css` | ||
gap: 0.5rem; | ||
`} | ||
${({ variant }) => | ||
variant === 'lg' && | ||
css` | ||
gap: 1rem; | ||
`} | ||
`; | ||
|
||
export const ToggleSwitch = styled.span<{ variant: 'sm' | 'lg' }>` | ||
position: relative; | ||
display: flex; | ||
align-items: center; | ||
background-color: ${palette.gray}; | ||
cursor: pointer; | ||
transition: background-color 0.2s ease; | ||
${({ variant }) => | ||
variant === 'sm' && | ||
css` | ||
width: 2.5rem; | ||
height: 1.5rem; | ||
border-radius: 1rem; | ||
`} | ||
${({ variant }) => | ||
variant === 'lg' && | ||
css` | ||
width: 5rem; | ||
height: 3rem; | ||
border-radius: 2rem; | ||
`} | ||
&::after { | ||
content: ''; | ||
position: absolute; | ||
display: inline-block; | ||
border-radius: 50%; | ||
background-color: ${palette.white}; | ||
transition: transform 0.2s ease, background-color 0.2s ease; | ||
${({ variant }) => | ||
variant === 'sm' && | ||
css` | ||
width: 1rem; | ||
height: 1rem; | ||
`} | ||
${({ variant }) => | ||
variant === 'lg' && | ||
css` | ||
width: 2rem; | ||
height: 2rem; | ||
`} | ||
} | ||
`; | ||
|
||
export const ToggleText = styled.span<{ variant: 'sm' | 'lg' }>` | ||
user-select: none; | ||
${({ variant }) => | ||
variant === 'sm' && | ||
css` | ||
font-size: 1rem; | ||
line-height: 1rem; | ||
`} | ||
${({ variant }) => | ||
variant === 'lg' && | ||
css` | ||
font-size: 2rem; | ||
line-height: 2rem; | ||
`} | ||
`; | ||
|
||
export const ToggleCheckbox = styled.input<{ | ||
color: NormalColorType; | ||
variant: 'sm' | 'lg'; | ||
}>` | ||
display: none; | ||
// Switch Off | ||
& ~ ${ToggleSwitch} { | ||
&::after { | ||
${({ variant }) => | ||
variant === 'sm' && | ||
css` | ||
transform: translateX(0.3rem); | ||
`} | ||
${({ variant }) => | ||
variant === 'lg' && | ||
css` | ||
transform: translateX(0.6rem); | ||
`} | ||
} | ||
} | ||
// Switch On | ||
&:checked { | ||
& ~ ${ToggleSwitch} { | ||
background-color: ${({ color }) => palette[color]}; | ||
&::after { | ||
${({ variant }) => | ||
variant === 'sm' && | ||
css` | ||
transform: translateX(1.2rem); | ||
`} | ||
${({ variant }) => | ||
variant === 'lg' && | ||
css` | ||
transform: translateX(2.4rem); | ||
`} | ||
} | ||
} | ||
} | ||
`; |
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,48 @@ | ||
import { forwardRef, InputHTMLAttributes } from 'react'; | ||
import { NormalColorType } from '~/lib/styles'; | ||
import * as S from './Toggle.styles'; | ||
|
||
export interface ToggleProps extends InputHTMLAttributes<HTMLInputElement> { | ||
labelText?: string; | ||
color?: NormalColorType; | ||
variant?: 'sm' | 'lg'; | ||
} | ||
|
||
/** | ||
* @example | ||
* ```tsx | ||
* <Toggle labelText="Toggle" color="primary" /> | ||
* <Toggle labelText="Toggle" color="success" /> | ||
* <Toggle labelText="Toggle" color="secondary" /> | ||
* <Toggle labelText="Toggle" color="warning" /> | ||
* <Toggle labelText="Toggle" color="error" /> | ||
* ``` | ||
* @example | ||
* ```tsx | ||
* <Toggle labelText="Toggle" color="primary" variant="lg" /> | ||
* <Toggle labelText="Toggle" color="success" variant="lg" /> | ||
* <Toggle labelText="Toggle" color="secondary" variant="lg" /> | ||
* <Toggle labelText="Toggle" color="warning" variant="lg" /> | ||
* <Toggle labelText="Toggle" color="error" variant="lg" /> | ||
* ``` | ||
*/ | ||
const Toggle = forwardRef<HTMLInputElement, ToggleProps>(function Toggle( | ||
{ labelText = '', color = 'primary', variant = 'sm', ...options }, | ||
ref, | ||
) { | ||
return ( | ||
<S.ToggleLabel variant={variant}> | ||
<S.ToggleText variant={variant}>{labelText}</S.ToggleText> | ||
<S.ToggleCheckbox | ||
type="checkbox" | ||
variant={variant} | ||
ref={ref} | ||
color={color} | ||
{...options} | ||
/> | ||
<S.ToggleSwitch variant={variant} /> | ||
</S.ToggleLabel> | ||
); | ||
}); | ||
|
||
export default Toggle; |
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,86 @@ | ||
import styled from '@emotion/styled'; | ||
import { useEffect, useRef } from 'react'; | ||
import { mediaQuery } from '~/lib/styles'; | ||
import { Button } from '../common'; | ||
|
||
interface Props { | ||
isEmailEdit: boolean; | ||
nextEmail: string; | ||
onChangeNextEmail: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
onEdit: () => void; | ||
onCancel: () => void; | ||
} | ||
|
||
const EmailEditor = ({ | ||
isEmailEdit, | ||
nextEmail, | ||
onChangeNextEmail, | ||
onEdit, | ||
onCancel, | ||
}: Props) => { | ||
const inputRef = useRef<HTMLInputElement>(null); | ||
useEffect(() => { | ||
if (isEmailEdit) { | ||
inputRef.current?.focus(); | ||
} | ||
}, [isEmailEdit]); | ||
|
||
return ( | ||
<Container> | ||
<Input | ||
ref={inputRef} | ||
placeholder="Write Email..." | ||
onChange={onChangeNextEmail} | ||
value={nextEmail} | ||
/> | ||
<ButtonsWrapper> | ||
<Button size="sm" color="success" shadow onClick={onEdit}> | ||
Confirm | ||
</Button> | ||
<Button size="sm" color="error" shadow onClick={onCancel}> | ||
Cancel | ||
</Button> | ||
</ButtonsWrapper> | ||
</Container> | ||
); | ||
}; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
width: 100%; | ||
gap: 0.5rem; | ||
${mediaQuery.mobile} { | ||
flex-direction: row; | ||
} | ||
`; | ||
|
||
const ButtonsWrapper = styled.div` | ||
display: flex; | ||
gap: 0.5rem; | ||
width: 100%; | ||
align-items: center; | ||
justify-content: flex-end; | ||
${mediaQuery.mobile} { | ||
width: auto; | ||
justify-content: center; | ||
} | ||
`; | ||
|
||
const Input = styled.input` | ||
width: 100%; | ||
height: 100%; | ||
padding: 0.5rem; | ||
background: transparent; | ||
border-bottom: 2px solid #b4b4b4; | ||
outline: none; | ||
font-size: 1rem; | ||
transition: border-bottom 0.1s ease-in-out; | ||
&:focus { | ||
border-bottom: 2px solid #ffb049; | ||
} | ||
`; | ||
|
||
export default EmailEditor; |
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export { default as useGetMe } from './useGetMe'; | ||
export { default as useGetUserByUsername } from './useGetUserByUsername'; | ||
export { default as useUpdateEmail } from './useUpdateEmail'; | ||
export { default as useUpdateEmailNotification } from './useUpdateEmailNotification'; |
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,11 @@ | ||
import { UserAPI } from '~/lib/api'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import type { UseMutationOptionsOf } from '~/hooks/queries/types'; | ||
|
||
const useUpdateEmail = ( | ||
options: UseMutationOptionsOf<typeof UserAPI.updateEmail> = {}, | ||
) => { | ||
return useMutation(UserAPI.updateEmail, options); | ||
}; | ||
|
||
export default useUpdateEmail; |
11 changes: 11 additions & 0 deletions
11
packages/client/src/hooks/queries/user/useUpdateEmailNotification.ts
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,11 @@ | ||
import { UserAPI } from '~/lib/api'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import type { UseMutationOptionsOf } from '~/hooks/queries/types'; | ||
|
||
const useUpdateEmailNotification = ( | ||
options: UseMutationOptionsOf<typeof UserAPI.updateEmailNotification> = {}, | ||
) => { | ||
return useMutation(UserAPI.updateEmailNotification, options); | ||
}; | ||
|
||
export default useUpdateEmailNotification; |
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
Oops, something went wrong.