Skip to content

Commit c4dd6a0

Browse files
committed
feat: 전체 너비 버튼 추가
1 parent 13e9517 commit c4dd6a0

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

apps/pyconkr-admin/src/consts/mdx_components.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ const PyConKRCommonMDXComponents: MDXComponents = {
137137
Common__Components__MDX__SecondaryStyledDetails: Common.Components.MDX.SecondaryStyledDetails,
138138
Common__Components__MDX__Map: Common.Components.MDX.Map,
139139
Common__Components__MDX__FAQAccordion: Common.Components.MDX.FAQAccordion,
140+
Common__Components__MDX__FullWidthStyledButton: Common.Components.MDX.StyledFullWidthButton,
140141
};
141142

142143
const PythonKRShopMDXComponents: MDXComponents = {

apps/pyconkr/src/components/layout/Header/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const Header: React.FC = () => {
6262
<>
6363
<Stack direction="row" alignItems="center" justifyContent="center" spacing={2}>
6464
{Object.values(siteMapNode.children).map((r) => (
65-
<Link to={r.route_code} onClick={resetDepths}>
65+
<Link key={r.id} to={r.route_code} onClick={resetDepths}>
6666
<Button key={r.id} onMouseEnter={() => setDepth1(r)} sx={{ minWidth: 0, textTransform: "none" }}>
6767
{r.name}
6868
</Button>

apps/pyconkr/src/consts/mdx_components.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ const PyConKRCommonMDXComponents: MDXComponents = {
137137
Common__Components__MDX__SecondaryStyledDetails: Common.Components.MDX.SecondaryStyledDetails,
138138
Common__Components__MDX__Map: Common.Components.MDX.Map,
139139
Common__Components__MDX__FAQAccordion: Common.Components.MDX.FAQAccordion,
140+
Common__Components__MDX__FullWidthStyledButton: Common.Components.MDX.StyledFullWidthButton,
140141
};
141142

142143
const PythonKRShopMDXComponents: MDXComponents = {

packages/common/src/components/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CenteredPage as CenteredPageComponent } from "./centered_page";
22
import { CommonContextProvider as CommonContextProviderComponent } from "./common_context";
33
import { ErrorFallback as ErrorFallbackComponent } from "./error_handler";
4+
import { LinkHandler as LinkHandlerComponent } from "./link_handler";
45
import {
56
LottieDebugPanel as LottieDebugPanelComponent,
67
LottiePlayer as LottiePlayerComponent,
@@ -14,10 +15,12 @@ import {
1415
} from "./mdx_components/faq_accordion";
1516
import type { MapPropType as MapComponentPropType } from "./mdx_components/map";
1617
import { Map as MapComponent } from "./mdx_components/map";
18+
import { OneDetailsOpener as OneDetailsOpenerComponent } from "./mdx_components/one_details_opener";
1719
import {
1820
PrimaryStyledDetails as PrimaryStyledDetailsComponent,
1921
HighlightedStyledDetails as SecondaryStyledDetailsComponent,
2022
} from "./mdx_components/styled_details";
23+
import { StyledFullWidthButton as StyledFullWidthButtonComponent } from "./mdx_components/styled_full_width_button";
2124
import { MDXEditor as MDXEditorComponent } from "./mdx_editor";
2225
import { PythonKorea as PythonKoreaComponent } from "./pythonkorea";
2326

@@ -31,12 +34,15 @@ namespace Components {
3134
export const LottiePlayer = LottiePlayerComponent;
3235
export const NetworkLottiePlayer = NetworkLottiePlayerComponent;
3336
export const ErrorFallback = ErrorFallbackComponent;
37+
export const LinkHandler = LinkHandlerComponent;
3438

3539
export namespace MDX {
40+
export const StyledFullWidthButton = StyledFullWidthButtonComponent;
3641
export const PrimaryStyledDetails = PrimaryStyledDetailsComponent;
3742
export const SecondaryStyledDetails = SecondaryStyledDetailsComponent;
3843
export const Map = MapComponent;
3944
export const FAQAccordion = FAQAccordionComponent;
45+
export const OneDetailsOpener = OneDetailsOpenerComponent;
4046
export type MapPropType = MapComponentPropType;
4147
export type FAQAccordionProps = FAQAccordionPropsType;
4248
export type FAQItem = FAQItemType;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { Button, ButtonProps, Typography } from "@mui/material";
2+
import * as React from "react";
3+
import * as R from "remeda";
4+
5+
import { LinkHandler } from "../link_handler";
6+
7+
type StyledFullWidthButtonPropType = ButtonProps & {
8+
link?: string;
9+
setBackgroundColor?: boolean;
10+
transparency: number;
11+
};
12+
13+
export const StyledFullWidthButton: React.FC<StyledFullWidthButtonPropType> = ({
14+
link,
15+
setBackgroundColor,
16+
transparency,
17+
...props
18+
}) => {
19+
let children = props.children;
20+
if (React.isValidElement(children) && R.isString((children.props as { children: unknown }).children))
21+
children = (children.props as { children: unknown }).children as string;
22+
if (children) children = <Typography variant="h5" fontSize="1.5rem" children={children} />;
23+
24+
const button = (
25+
<Button
26+
fullWidth
27+
variant="outlined"
28+
sx={({ palette }) => ({
29+
borderRadius: "0.5rem",
30+
textTransform: "none",
31+
color: palette.primary.dark,
32+
borderColor: palette.primary.dark,
33+
backgroundColor: setBackgroundColor
34+
? `color-mix(in srgb, ${palette.primary.light} ${transparency || 10}%, transparent)`
35+
: "transparent",
36+
"&:hover": {
37+
backgroundColor: setBackgroundColor
38+
? `color-mix(in srgb, ${palette.primary.light} ${transparency || 20}%, transparent)`
39+
: `color-mix(in srgb, ${palette.primary.light} ${transparency || 10}%, transparent)`,
40+
},
41+
"&.MuiButton-sizeLarge": { height: "3.5rem" },
42+
})}
43+
{...props}
44+
children={children}
45+
/>
46+
);
47+
48+
return link ? <LinkHandler href={link} children={button} /> : button;
49+
};

0 commit comments

Comments
 (0)