Skip to content

Commit f50c559

Browse files
committed
Merge remote-tracking branch 'origin/feature/accordion'
2 parents f8a243b + 50ed1e8 commit f50c559

File tree

4 files changed

+117
-0
lines changed

4 files changed

+117
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const PyConKRCommonMDXComponents: MDXComponents = {
136136
Common__Components__MDX__PrimaryStyledDetails: Common.Components.MDX.PrimaryStyledDetails,
137137
Common__Components__MDX__SecondaryStyledDetails: Common.Components.MDX.SecondaryStyledDetails,
138138
Common__Components__MDX__Map: Common.Components.MDX.Map,
139+
Common__Components__MDX__FAQAccordion: Common.Components.MDX.FAQAccordion,
139140
};
140141

141142
const PythonKRShopMDXComponents: MDXComponents = {

apps/pyconkr/src/consts/mdx_components.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ const PyConKRCommonMDXComponents: MDXComponents = {
136136
Common__Components__MDX__PrimaryStyledDetails: Common.Components.MDX.PrimaryStyledDetails,
137137
Common__Components__MDX__SecondaryStyledDetails: Common.Components.MDX.SecondaryStyledDetails,
138138
Common__Components__MDX__Map: Common.Components.MDX.Map,
139+
Common__Components__MDX__FAQAccordion: Common.Components.MDX.FAQAccordion,
139140
};
140141

141142
const PythonKRShopMDXComponents: MDXComponents = {

packages/common/src/components/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import {
77
NetworkLottiePlayer as NetworkLottiePlayerComponent,
88
} from "./lottie";
99
import { MDXRenderer as MDXRendererComponent } from "./mdx";
10+
import {
11+
FAQAccordion as FAQAccordionComponent,
12+
type FAQAccordionProps as FAQAccordionPropsType,
13+
type FAQItem as FAQItemType,
14+
} from "./mdx_components/faq_accordion";
1015
import type { MapPropType as MapComponentPropType } from "./mdx_components/map";
1116
import { Map as MapComponent } from "./mdx_components/map";
1217
import {
@@ -31,7 +36,10 @@ namespace Components {
3136
export const PrimaryStyledDetails = PrimaryStyledDetailsComponent;
3237
export const SecondaryStyledDetails = SecondaryStyledDetailsComponent;
3338
export const Map = MapComponent;
39+
export const FAQAccordion = FAQAccordionComponent;
3440
export type MapPropType = MapComponentPropType;
41+
export type FAQAccordionProps = FAQAccordionPropsType;
42+
export type FAQItem = FAQItemType;
3543
}
3644
}
3745

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
2+
import { Accordion as MuiAccordion, AccordionDetails, AccordionSummary } from "@mui/material";
3+
import styled from "@emotion/styled";
4+
import * as React from "react";
5+
6+
export interface FAQItem {
7+
id: string;
8+
question: string;
9+
answer: string;
10+
}
11+
12+
export interface FAQAccordionProps {
13+
items: FAQItem[];
14+
}
15+
16+
export const FAQAccordion: React.FC<FAQAccordionProps> = ({ items }) => {
17+
return (
18+
<AccordionWrapper>
19+
{items.map((faq, index) => (
20+
<React.Fragment key={faq.id}>
21+
<StyledAccordion>
22+
<AccordionSummary
23+
expandIcon={<ExpandMoreIcon />}
24+
aria-controls={`panel${faq.id}-content`}
25+
id={`panel${faq.id}-header`}
26+
>
27+
<Number>{faq.id}</Number>
28+
<Question>{faq.question}</Question>
29+
</AccordionSummary>
30+
<StyledAccordionDetails>{faq.answer}</StyledAccordionDetails>
31+
</StyledAccordion>
32+
{index !== items.length - 1 && <Divider />}
33+
</React.Fragment>
34+
))}
35+
</AccordionWrapper>
36+
);
37+
};
38+
39+
const AccordionWrapper = styled.div`
40+
display: flex;
41+
flex-direction: column;
42+
border-top: 1px solid ${({ theme }) => theme.palette.primary.dark};
43+
border-bottom: 1px solid ${({ theme }) => theme.palette.primary.dark};
44+
`;
45+
46+
const Divider = styled.div`
47+
height: 1px;
48+
background-color: ${({ theme }) => theme.palette.primary.light};
49+
margin: 0;
50+
`;
51+
52+
const StyledAccordion = styled(MuiAccordion)`
53+
box-shadow: none;
54+
border-radius: 0;
55+
56+
&:before {
57+
display: none;
58+
}
59+
60+
&.MuiAccordion-root {
61+
margin: 0;
62+
63+
&:first-of-type {
64+
border-top: none;
65+
}
66+
67+
&:last-of-type {
68+
border-bottom: none;
69+
}
70+
}
71+
72+
.MuiAccordionSummary-root {
73+
padding: 10px 35px;
74+
min-height: 60px;
75+
max-height: 60px;
76+
77+
.MuiAccordionSummary-content {
78+
display: flex;
79+
align-items: center;
80+
margin: 0;
81+
}
82+
83+
&.Mui-expanded {
84+
min-height: 60px;
85+
max-height: 60px;
86+
}
87+
}
88+
`;
89+
90+
const Number = styled.span`
91+
font-size: 18px;
92+
font-weight: 400;
93+
`;
94+
95+
const Question = styled.span`
96+
font-size: 18px;
97+
font-weight: 400;
98+
margin-left: 60px;
99+
`;
100+
101+
const StyledAccordionDetails = styled(AccordionDetails)`
102+
background-color: ${({ theme }) => `${theme.palette.primary.light}26`}; // 15% opacity (26 in hex)
103+
color: ${({ theme }) => theme.palette.primary.dark};
104+
font-size: 14px;
105+
font-weight: 400;
106+
padding: 20px 0 20px calc(35px + 18px + 60px); // top right bottom left
107+
`;

0 commit comments

Comments
 (0)