aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/organisms/widgets/social-media.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-04-15 17:38:16 +0200
committerArmand Philippot <git@armandphilippot.com>2022-04-15 17:42:28 +0200
commitb3ac82bba9605fa9d9c4b1d29c5a56a52e9de015 (patch)
tree1d3d9dcd6993f7b5ebf04218d57670dc751a239d /src/components/organisms/widgets/social-media.tsx
parenta07729064790df13324dbe7f4d1629892070558b (diff)
chore: add a SocialMedia component
Diffstat (limited to 'src/components/organisms/widgets/social-media.tsx')
-rw-r--r--src/components/organisms/widgets/social-media.tsx41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/components/organisms/widgets/social-media.tsx b/src/components/organisms/widgets/social-media.tsx
new file mode 100644
index 0000000..58b2f73
--- /dev/null
+++ b/src/components/organisms/widgets/social-media.tsx
@@ -0,0 +1,41 @@
+import SocialLink, {
+ type SocialLinkProps,
+} from '@components/atoms/links/social-link';
+import Widget, { type WidgetProps } from '@components/molecules/layout/widget';
+import { FC } from 'react';
+import styles from './social-media.module.scss';
+
+export type Media = SocialLinkProps;
+
+export type SocialMediaProps = Pick<WidgetProps, 'level' | 'title'> & {
+ media: Media[];
+};
+
+/**
+ * Social Media widget component
+ *
+ * Render a social media list with links.
+ */
+const SocialMedia: FC<SocialMediaProps> = ({ media, ...props }) => {
+ /**
+ * Retrieve the social media items.
+ *
+ * @param {SocialMedia[]} links - An array of social media name and url.
+ * @returns {JSX.Element[]} The social links.
+ */
+ const getItems = (links: Media[]): JSX.Element[] => {
+ return links.map((link, index) => (
+ <li key={`media-${index}`}>
+ <SocialLink name={link.name} url={link.url} />
+ </li>
+ ));
+ };
+
+ return (
+ <Widget expanded={true} {...props}>
+ <ul className={styles.list}>{getItems(media)}</ul>
+ </Widget>
+ );
+};
+
+export default SocialMedia;