Skip to content

Commit ecd29e9

Browse files
committed
feat: 커뮤니티 선택 탭 모바일 사이즈 대응
1 parent f71137d commit ecd29e9

File tree

9 files changed

+64
-12
lines changed

9 files changed

+64
-12
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"@vanilla-extract/css": "^1.17.0",
3030
"@vanilla-extract/recipes": "^0.5.5",
3131
"axios": "^1.6.8",
32+
"clsx": "^2.1.1",
3233
"country-flag-icons": "^1.5.13",
3334
"date-fns": "^3.6.0",
3435
"embla-carousel-autoplay": "^8.2.0",

src/features/Community/CommunitySelectTab/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as s from './style.css'
22

33
import { Button } from '@/ui/Button'
4+
import { useMediaQueryByName } from '@/util/hooks/useMediaQueryByName'
45
import { useQueryParams } from '@/util/hooks/useQueryParams'
56

67
const boardConfig = [
@@ -34,12 +35,14 @@ export type BoardQueryParam = {
3435

3536
const CommunitySelectTab = () => {
3637
const [queryParam, setQueryParam] = useQueryParams<BoardQueryParam>()
37-
38+
const isMobile = useMediaQueryByName('smDown')
3839
return (
3940
<div className={s.Wrapper}>
4041
{boardConfig.map(board => (
4142
<Button
43+
key={board.boardId}
4244
variant="default"
45+
size={isMobile ? 'sm' : 'default'}
4346
isActive={queryParam.board === board.board}
4447
onClick={() => setQueryParam({ board: board.board, boardId: board.boardId })}
4548
>

src/features/Community/CommunitySelectTab/style.css.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,15 @@ export const Wrapper = style([
88
f.alignCenter,
99
f.background.lightGray2,
1010
{ width: '44.5625rem', padding: '0.625rem', borderRadius: '6px' },
11+
f.smDown({
12+
width: '100%',
13+
overflowX: 'auto',
14+
gap: '0.875rem',
15+
borderRadius: '0px',
16+
selectors: {
17+
'&::-webkit-scrollbar': {
18+
display: 'none',
19+
},
20+
},
21+
}),
1122
])

src/features/Community/HotPostPreview/style.css.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { style } from '@vanilla-extract/css'
22

33
import { f } from '@/style'
44

5-
export const Wrapper = style([f.flex, f.directionColumn, f.alignStart, { width: '22.4375rem', gap: '3rem' }])
5+
export const Wrapper = style([
6+
f.flex,
7+
f.directionColumn,
8+
f.alignStart,
9+
{ width: '22.4375rem', gap: '3rem' },
10+
f.smDown({ display: 'none' }),
11+
])
612

713
export const TitleWrapper = style([f.flex, f.justifyBetween, f.wFull, f.alignEnd])
814

src/features/Community/PostSearch/style.css.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { style } from '@vanilla-extract/css'
22

33
import { f } from '@/style'
44

5-
export const SearchWrapper = style([f.flex, f.directionColumn, f.wFull, { gap: '1.875rem' }])
5+
export const SearchWrapper = style([
6+
f.flex,
7+
f.directionColumn,
8+
f.wFull,
9+
{ gap: '1.875rem' },
10+
f.smDown({ display: 'none' }),
11+
])
612

713
export const Header = style([f.flex, f.alignCenter, f.justifyBetween, f.wFull])
814

src/pages/Community/All/style.css.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import { f } from '@/style'
44

55
export const Wrapper = style([f.flex, f.directionColumn, f.alignCenter, { marginTop: '2.5rem', gap: '2.5rem' }])
66

7-
export const SelectTabWrapper = style([f.flex, f.alignStart, { width: '70.75rem' }])
7+
export const SelectTabWrapper = style([f.flex, f.alignStart, { width: '70.75rem' }, f.smDown({ width: '100%' })])

src/ui/Button/index.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Slot } from '@radix-ui/react-slot'
2+
import clsx from 'clsx'
23
import { forwardRef } from 'react'
34

45
import * as s from './style.css'
@@ -9,19 +10,31 @@ type Props = {
910
children: React.ReactNode
1011
asChild?: boolean
1112
style?: React.CSSProperties
12-
variant?: s.ButtonVariants
13+
variant?: s.ButtonStyleVariants
14+
size?: s.ButtonSizeVariants
1315
isActive?: boolean
1416
} & React.ButtonHTMLAttributes<HTMLButtonElement>
1517

1618
export const Button = forwardRef<HTMLButtonElement, Props>(
17-
({ suffixIcon, prefixIcon, children, asChild, onClick, variant = 'default', isActive, ...props }, ref) => {
19+
(
20+
{ suffixIcon, prefixIcon, children, asChild, onClick, variant = 'default', size = 'default', isActive, ...props },
21+
ref,
22+
) => {
1823
const Component = asChild ? Slot : 'button'
1924

2025
return (
21-
<Component ref={ref} onClick={onClick} {...props} className={s.Button[variant]} data-active={isActive}>
26+
<Component
27+
ref={ref}
28+
onClick={onClick}
29+
{...props}
30+
className={clsx(s.ButtonStyle[variant], s.ButtonSize[size])}
31+
data-active={isActive}
32+
>
2233
<div data-part="content">
2334
{prefixIcon && <span data-part="prefix">{prefixIcon}</span>}
24-
<span data-part="text">{children}</span>
35+
<span data-part="text" style={{ whiteSpace: 'nowrap' }}>
36+
{children}
37+
</span>
2538
{suffixIcon && <span data-part="suffix">{suffixIcon}</span>}
2639
</div>
2740
</Component>

src/ui/Button/style.css.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ export const Base = style([
1010
f.color.static.darkGray2,
1111
f.background.lightGray2,
1212
{
13-
height: '2.875rem',
14-
padding: '0rem 1.875rem',
1513
borderRadius: '6px',
1614
transition: 'all 0.2s ease-in-out',
1715
outline: 'none',
1816
},
1917
])
2018

21-
export const Button = styleVariants({
19+
export const ButtonStyle = styleVariants({
2220
default: [
2321
Base,
2422
{
@@ -66,4 +64,10 @@ export const Button = styleVariants({
6664
gray: [Base, { ':hover': { boxShadow: vars.shadow.p25 }, ':focus': { boxShadow: vars.shadow.p25 } }],
6765
})
6866

69-
export type ButtonVariants = keyof typeof Button
67+
export const ButtonSize = styleVariants({
68+
default: [{ height: '2.875rem', padding: '0rem 1.875rem', ...vars.typography.desktop.body1M }],
69+
sm: [{ height: '1.75rem', padding: '0.5rem 0.625rem', ...vars.typography.mobile.bodyM, flex: '1 0 0' }],
70+
})
71+
72+
export type ButtonStyleVariants = keyof typeof ButtonStyle
73+
export type ButtonSizeVariants = keyof typeof ButtonSize

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3485,6 +3485,13 @@ __metadata:
34853485
languageName: node
34863486
linkType: hard
34873487

3488+
"clsx@npm:^2.1.1":
3489+
version: 2.1.1
3490+
resolution: "clsx@npm:2.1.1"
3491+
checksum: 10c0/c4c8eb865f8c82baab07e71bfa8897c73454881c4f99d6bc81585aecd7c441746c1399d08363dc096c550cceaf97bd4ce1e8854e1771e9998d9f94c4fe075839
3492+
languageName: node
3493+
linkType: hard
3494+
34883495
"code-block-writer@npm:^12.0.0":
34893496
version: 12.0.0
34903497
resolution: "code-block-writer@npm:12.0.0"
@@ -6035,6 +6042,7 @@ __metadata:
60356042
"@vanilla-extract/vite-plugin": "npm:^4.0.19"
60366043
"@vitejs/plugin-react-swc": "npm:^3.5.0"
60376044
axios: "npm:^1.6.8"
6045+
clsx: "npm:^2.1.1"
60386046
country-flag-icons: "npm:^1.5.13"
60396047
date-fns: "npm:^3.6.0"
60406048
embla-carousel-autoplay: "npm:^8.2.0"

0 commit comments

Comments
 (0)