From a3a4c50f26b8750ae1c87f1f1103b84b7d2e6315 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Tue, 14 Nov 2023 15:11:22 +0100
Subject: refactor(components): replace LinksListWidget with LinksWidget

* avoid List component repeat
* rewrite tests and CSS
* add an id to LinksWidgetItemData (previously LinksListItems) type
because the label could be duplicated
---
 .../organisms/widgets/links-list-widget.tsx        | 87 ----------------------
 1 file changed, 87 deletions(-)
 delete mode 100644 src/components/organisms/widgets/links-list-widget.tsx

(limited to 'src/components/organisms/widgets/links-list-widget.tsx')

diff --git a/src/components/organisms/widgets/links-list-widget.tsx b/src/components/organisms/widgets/links-list-widget.tsx
deleted file mode 100644
index 17a5884..0000000
--- a/src/components/organisms/widgets/links-list-widget.tsx
+++ /dev/null
@@ -1,87 +0,0 @@
-import type { FC } from 'react';
-import { slugify } from '../../../utils/helpers';
-import { Link, List, ListItem } from '../../atoms';
-import { Collapsible, type CollapsibleProps } from '../../molecules';
-import styles from './links-list-widget.module.scss';
-
-export type LinksListItems = {
-  /**
-   * An array of name/url couple child of this list item.
-   */
-  child?: LinksListItems[];
-  /**
-   * The item name.
-   */
-  name: string;
-  /**
-   * The item url.
-   */
-  url: string;
-};
-
-export type LinksListWidgetProps = Omit<
-  CollapsibleProps,
-  'children' | 'disablePadding' | 'hasBorders'
-> & {
-  className?: string;
-  /**
-   * Should the links be ordered?
-   *
-   * @default false
-   */
-  isOrdered?: boolean;
-  /**
-   * An array of name/url couple.
-   */
-  items: LinksListItems[];
-};
-
-/**
- * LinksListWidget component
- *
- * Render a list of links inside a widget.
- */
-export const LinksListWidget: FC<LinksListWidgetProps> = ({
-  className = '',
-  isOrdered = false,
-  items,
-  ...props
-}) => {
-  const listKindClass = `list--${isOrdered ? 'ordered' : 'unordered'}`;
-
-  /**
-   * Format the widget data to be used as List items.
-   *
-   * @param {LinksListItems[]} data - The widget data.
-   * @returns {ListItem[]} The list items data.
-   */
-  const getListItems = (data: LinksListItems[]) =>
-    data.map((item) => (
-      <ListItem className={styles.list__item} key={slugify(item.name)}>
-        <Link className={styles.list__link} href={item.url}>
-          {item.name}
-        </Link>
-        {item.child?.length ? (
-          <List
-            className={`${styles.list} ${styles[listKindClass]} ${className}`}
-            hideMarker
-            isOrdered={isOrdered}
-          >
-            {getListItems(item.child)}
-          </List>
-        ) : null}
-      </ListItem>
-    ));
-
-  return (
-    <Collapsible {...props} className={styles.widget} disablePadding hasBorders>
-      <List
-        className={`${styles.list} ${styles[listKindClass]} ${className}`}
-        hideMarker
-        isOrdered={isOrdered}
-      >
-        {getListItems(items)}
-      </List>
-    </Collapsible>
-  );
-};
-- 
cgit v1.2.3

