From fb29b0f017fae162ffa7ad6bdfc80099346802de Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Mon, 13 Nov 2023 19:03:44 +0100
Subject: refactor(components): replace SocialMedia with SocialMediaWidget

* the goal is to make the name of the widgets coherent
* remove useless CSS
* replace Media type with SocialMediaData
---
 .../social-media-widget/social-media-widget.tsx    | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 src/components/organisms/widgets/social-media-widget/social-media-widget.tsx

(limited to 'src/components/organisms/widgets/social-media-widget/social-media-widget.tsx')

diff --git a/src/components/organisms/widgets/social-media-widget/social-media-widget.tsx b/src/components/organisms/widgets/social-media-widget/social-media-widget.tsx
new file mode 100644
index 0000000..d75f48f
--- /dev/null
+++ b/src/components/organisms/widgets/social-media-widget/social-media-widget.tsx
@@ -0,0 +1,43 @@
+import { forwardRef, type ForwardRefRenderFunction } from 'react';
+import {
+  List,
+  ListItem,
+  SocialLink,
+  type SocialLinkProps,
+} from '../../../atoms';
+import { Collapsible, type CollapsibleProps } from '../../../molecules';
+
+export type SocialMediaData = Required<
+  Pick<SocialLinkProps, 'icon' | 'id' | 'label' | 'url'>
+>;
+
+export type SocialMediaProps = Omit<CollapsibleProps, 'children'> & {
+  media: SocialMediaData[];
+};
+
+const SocialMediaWidgetWithRef: ForwardRefRenderFunction<
+  HTMLDivElement,
+  SocialMediaProps
+> = ({ media, ...props }, ref) => (
+  <Collapsible {...props} ref={ref}>
+    <List
+      hideMarker
+      isInline
+      // eslint-disable-next-line react/jsx-no-literals
+      spacing="xs"
+    >
+      {media.map(({ id, ...link }) => (
+        <ListItem key={id}>
+          <SocialLink {...link} />
+        </ListItem>
+      ))}
+    </List>
+  </Collapsible>
+);
+
+/**
+ * Social Media widget component
+ *
+ * Render a social media list with links.
+ */
+export const SocialMediaWidget = forwardRef(SocialMediaWidgetWithRef);
-- 
cgit v1.2.3

