Browse Source

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

eliam.ruiz 2 years ago
parent
commit
a92ce928f8

+ 3
- 0
src/components/DropdownComponent.css View File

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

+ 34
- 0
src/components/DropdownComponent.tsx View File

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 View File

7
 
7
 
8
 .ListItemText {
8
 .ListItemText {
9
     font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
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 View File

1
-import { IonContent, IonItem, IonLabel, IonListHeader } from "@ionic/react";
1
+import { IonItem, IonLabel, IonList, IonListHeader } from "@ionic/react";
2
 import "../components/ListComponent.css";
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
   const title = props.title;
7
   const title = props.title;
6
-  const laws = props.laws;
8
+  const items = props.items;
7
   return (
9
   return (
8
-    <IonContent>
10
+    <IonList>
9
       {title ? (
11
       {title ? (
10
         <IonListHeader>
12
         <IonListHeader>
11
           <IonLabel>{title}</IonLabel>
13
           <IonLabel>{title}</IonLabel>
12
         </IonListHeader>
14
         </IonListHeader>
13
       ) : null}
15
       ) : null}
14
 
16
 
15
-      {laws.map((lawName: string) => {
17
+      {items.map((itemName: string) => {
16
         return (
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
           </IonItem>
21
           </IonItem>
20
         );
22
         );
21
       })}
23
       })}
22
-    </IonContent>
24
+    </IonList>
23
   );
25
   );
24
 };
26
 };
25
 export default ListComponent;
27
 export default ListComponent;

+ 15
- 2
src/pages/AdviceListPage.tsx View File

5
   IonTitle,
5
   IonTitle,
6
   IonToolbar,
6
   IonToolbar,
7
 } from "@ionic/react";
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
 const AdviceListPage: React.FC = () => {
22
 const AdviceListPage: React.FC = () => {
11
   return (
23
   return (
21
             <IonTitle size="large">Consejos</IonTitle>
33
             <IonTitle size="large">Consejos</IonTitle>
22
           </IonToolbar>
34
           </IonToolbar>
23
         </IonHeader>
35
         </IonHeader>
24
-        <ListComponent laws={["Consejo 1", "Consejo 2"]} />
36
+
37
+        <DropdownComponent category={categories} />
25
       </IonContent>
38
       </IonContent>
26
     </IonPage>
39
     </IonPage>
27
   );
40
   );

+ 1
- 1
src/pages/Home.tsx View File

31
         </div>
31
         </div>
32
 
32
 
33
         <ListComponent
33
         <ListComponent
34
-          laws={["Articulo 1", "Articulo 2"]}
34
+          items={["Articulo 1", "Articulo 2"]}
35
           title="Articulos Recientes"
35
           title="Articulos Recientes"
36
         />
36
         />
37
       </IonContent>
37
       </IonContent>

+ 1
- 1
src/pages/LawListPage.tsx View File

21
             <IonTitle size="large">Leyes</IonTitle>
21
             <IonTitle size="large">Leyes</IonTitle>
22
           </IonToolbar>
22
           </IonToolbar>
23
         </IonHeader>
23
         </IonHeader>
24
-        <ListComponent laws={["Law 1", "Law 2"]} />
24
+        <ListComponent items={["Law 1", "Law 2"]} />
25
       </IonContent>
25
       </IonContent>
26
     </IonPage>
26
     </IonPage>
27
   );
27
   );

+ 4
- 0
src/types.ts View File

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