-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuildFlexClassNames.ts
More file actions
38 lines (34 loc) · 1.15 KB
/
buildFlexClassNames.ts
File metadata and controls
38 lines (34 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { CSSProperties } from 'react';
/** The props type of {@link buildFlexClassNames | 'buildFlexClassNames'}. */
export interface FlexClassNamesParams {
/** flex-direction 속성을 지정합니다. */
direction?: CSSProperties['flexDirection'];
/** flex-wrap 속성을 지정합니다. */
wrap?: CSSProperties['flexWrap'];
/** align-items 속성을 지정합니다. */
align?: CSSProperties['alignItems'];
/** justify-content 속성을 지정합니다. */
justify?: CSSProperties['justifyContent'];
}
/**
* 컴포넌트에 적용할 Flexbox 관련 CSS 클래스명을 반환합니다.
*
* @param props - {@link FlexClassNamesParams}를 참조하세요.
* @returns 컴포넌트에 적용할 Flexbox 관련 CSS 클래스명을 반환합니다.
*/
export const buildFlexClassNames = ({ direction, wrap, align, justify }: FlexClassNamesParams): string => {
const classes: string[] = ['flex'];
if (direction) {
classes.push(`flex-${direction}`);
}
if (wrap) {
classes.push(`flex-${wrap}`);
}
if (align) {
classes.push(`align-${align}`);
}
if (justify) {
classes.push(`justify-${justify}`);
}
return classes.join(' ');
};