Explorar el Código

Merge branch 'eliam-sprint-1' of sergio.mattei/RenacerSocial into main

eliam.ruiz hace 2 años
padre
commit
a92ce928f8

+ 3
- 0
src/components/DropdownComponent.css Ver fichero

@@ -0,0 +1,3 @@
1
+.accordion-list-container {
2
+    width: 100%;
3
+}

+ 34
- 0
src/components/DropdownComponent.tsx Ver fichero

@@ -0,0 +1,34 @@
1
+import {
2
+  IonAccordion,
3
+  IonAccordionGroup,
4
+  IonItem,
5
+  IonLabel,
6
+} from "@ionic/react";
7
+import ListComponent from "../components/ListComponent";
8
+import { Category } from "../types";
9
+import "./DropdownComponent.css";
10
+
11
+const DropdownComponent: React.FC<{
12
+  category: Category[];
13
+}> = (props) => {
14
+  const category = props.category;
15
+  return (
16
+    <IonAccordionGroup>
17
+      {category.map((catItem: Category, index) => {
18
+        return (
19
+          <IonAccordion value={`${index}`}>
20
+            <IonItem slot="header" color="light">
21
+              <IonLabel>{catItem.name}</IonLabel>
22
+            </IonItem>
23
+            <IonItem slot="content">
24
+              <div className="accordion-list-container">
25
+                <ListComponent items={catItem.listItems} />
26
+              </div>
27
+            </IonItem>
28
+          </IonAccordion>
29
+        );
30
+      })}
31
+    </IonAccordionGroup>
32
+  );
33
+};
34
+export default DropdownComponent;

+ 1
- 5
src/components/ListComponent.css Ver fichero

@@ -7,8 +7,4 @@
7 7
 
8 8
 .ListItemText {
9 9
     font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
10
-}
11
-
12
-ion-list-header {
13
-    /* color: "primary"; */
14
-}
10
+}

+ 10
- 8
src/components/ListComponent.tsx Ver fichero

@@ -1,25 +1,27 @@
1
-import { IonContent, IonItem, IonLabel, IonListHeader } from "@ionic/react";
1
+import { IonItem, IonLabel, IonList, IonListHeader } from "@ionic/react";
2 2
 import "../components/ListComponent.css";
3 3
 
4
-const ListComponent: React.FC<{ title?: string; laws: string[] }> = (props) => {
4
+const ListComponent: React.FC<{ title?: string; items: string[] }> = (
5
+  props
6
+) => {
5 7
   const title = props.title;
6
-  const laws = props.laws;
8
+  const items = props.items;
7 9
   return (
8
-    <IonContent>
10
+    <IonList>
9 11
       {title ? (
10 12
         <IonListHeader>
11 13
           <IonLabel>{title}</IonLabel>
12 14
         </IonListHeader>
13 15
       ) : null}
14 16
 
15
-      {laws.map((lawName: string) => {
17
+      {items.map((itemName: string) => {
16 18
         return (
17
-          <IonItem routerLink={`/article/${encodeURIComponent(lawName)}`}>
18
-            <p className="ListItemText">{lawName}</p>
19
+          <IonItem routerLink={`/article/${encodeURIComponent(itemName)}`}>
20
+            <p className="ListItemText">{itemName}</p>
19 21
           </IonItem>
20 22
         );
21 23
       })}
22
-    </IonContent>
24
+    </IonList>
23 25
   );
24 26
 };
25 27
 export default ListComponent;

+ 15
- 2
src/pages/AdviceListPage.tsx Ver fichero

@@ -5,7 +5,19 @@ import {
5 5
   IonTitle,
6 6
   IonToolbar,
7 7
 } from "@ionic/react";
8
-import ListComponent from "../components/ListComponent";
8
+import DropdownComponent from "../components/DropdownComponent";
9
+import "../types";
10
+
11
+const categories = [
12
+  {
13
+    name: "Paternidad",
14
+    listItems: ["Consejo de Paternidad 1", "Consejo de Paternidad 2"],
15
+  },
16
+  {
17
+    name: "Abuso Sexual",
18
+    listItems: ["Consejo de Abuso Sexual 1", "Consejo de Abuso Sexual 2"],
19
+  },
20
+];
9 21
 
10 22
 const AdviceListPage: React.FC = () => {
11 23
   return (
@@ -21,7 +33,8 @@ const AdviceListPage: React.FC = () => {
21 33
             <IonTitle size="large">Consejos</IonTitle>
22 34
           </IonToolbar>
23 35
         </IonHeader>
24
-        <ListComponent laws={["Consejo 1", "Consejo 2"]} />
36
+
37
+        <DropdownComponent category={categories} />
25 38
       </IonContent>
26 39
     </IonPage>
27 40
   );

+ 1
- 1
src/pages/Home.tsx Ver fichero

@@ -31,7 +31,7 @@ const Home: React.FC = () => {
31 31
         </div>
32 32
 
33 33
         <ListComponent
34
-          laws={["Articulo 1", "Articulo 2"]}
34
+          items={["Articulo 1", "Articulo 2"]}
35 35
           title="Articulos Recientes"
36 36
         />
37 37
       </IonContent>

+ 1
- 1
src/pages/LawListPage.tsx Ver fichero

@@ -21,7 +21,7 @@ const LawListPage: React.FC = () => {
21 21
             <IonTitle size="large">Leyes</IonTitle>
22 22
           </IonToolbar>
23 23
         </IonHeader>
24
-        <ListComponent laws={["Law 1", "Law 2"]} />
24
+        <ListComponent items={["Law 1", "Law 2"]} />
25 25
       </IonContent>
26 26
     </IonPage>
27 27
   );

+ 4
- 0
src/types.ts Ver fichero

@@ -0,0 +1,4 @@
1
+export interface Category {
2
+    name: string;
3
+    listItems: string[];
4
+}