@stackshift-ui/social-icons 6.0.2 → 6.0.4-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -7
- package/src/index.ts +4 -0
- package/src/social-icons.test.tsx +13 -0
- package/src/social-icons.tsx +79 -0
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackshift-ui/social-icons",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "6.0.
|
|
4
|
+
"version": "6.0.4-beta.0",
|
|
5
5
|
"private": false,
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"module": "./dist/index.mjs",
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"files": [
|
|
11
|
-
"dist/**"
|
|
11
|
+
"dist/**",
|
|
12
|
+
"src"
|
|
12
13
|
],
|
|
13
14
|
"author": "WebriQ <info@webriq.com>",
|
|
14
15
|
"devDependencies": {
|
|
@@ -28,17 +29,17 @@
|
|
|
28
29
|
"typescript": "^5.6.2",
|
|
29
30
|
"vite-tsconfig-paths": "^5.0.1",
|
|
30
31
|
"vitest": "^2.1.1",
|
|
31
|
-
"@stackshift-ui/typescript-config": "6.0.
|
|
32
|
-
"@stackshift-ui/eslint-config": "6.0.
|
|
32
|
+
"@stackshift-ui/typescript-config": "6.0.3-beta.0",
|
|
33
|
+
"@stackshift-ui/eslint-config": "6.0.3-beta.0"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
36
|
"classnames": "^2.5.1",
|
|
36
37
|
"react-icons": "^5.3.0",
|
|
37
|
-
"@stackshift-ui/
|
|
38
|
-
"@stackshift-ui/
|
|
38
|
+
"@stackshift-ui/scripts": "6.0.3-beta.0",
|
|
39
|
+
"@stackshift-ui/system": "6.0.4-beta.0"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
|
-
"@stackshift-ui/system": ">=
|
|
42
|
+
"@stackshift-ui/system": ">=6.0.4-beta.0",
|
|
42
43
|
"@types/react": "16.8 - 19",
|
|
43
44
|
"next": "10 - 14",
|
|
44
45
|
"react": "16.8 - 19",
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cleanup, render, screen } from "@testing-library/react";
|
|
2
|
+
import { afterEach, describe, test } from "vitest";
|
|
3
|
+
import { SocialIcons } from "./social-icons";
|
|
4
|
+
|
|
5
|
+
describe.concurrent("social-icons", () => {
|
|
6
|
+
afterEach(cleanup);
|
|
7
|
+
|
|
8
|
+
test.skip("Common: Social Icons - test if renders without errors", ({ expect }) => {
|
|
9
|
+
const clx = "socialicons-class";
|
|
10
|
+
render(<SocialIcons className={clx} />);
|
|
11
|
+
expect(screen.getByRole("socialicons").classList).toContain(clx);
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
|
|
2
|
+
import cn from "classnames";
|
|
3
|
+
import type { ElementType, HTMLProps, ReactNode } from "react";
|
|
4
|
+
import { FaFacebook, FaLinkedin, FaYoutube } from "react-icons/fa";
|
|
5
|
+
|
|
6
|
+
type Socials = "facebook" | "instagram" | "youtube" | "linkedin" | "twitter";
|
|
7
|
+
|
|
8
|
+
const FacebookIcon = (props: any) => {
|
|
9
|
+
return (
|
|
10
|
+
<svg className="" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
11
|
+
<path
|
|
12
|
+
fill="#0045d8"
|
|
13
|
+
d="M9 8h-3v4h3v12h5v-12h3.642l.358-4h-4v-1.667c0-.955.192-1.333 1.115-1.333h2.885v-5h-3.808c-3.596 0-5.192 1.583-5.192 4.615v3.385z"
|
|
14
|
+
/>
|
|
15
|
+
</svg>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
const TwitterIcon = (props: any) => {
|
|
19
|
+
return (
|
|
20
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
21
|
+
<path
|
|
22
|
+
fill="#0045d8"
|
|
23
|
+
d="M24 4.557c-.883.392-1.832.656-2.828.775 1.017-.609 1.798-1.574 2.165-2.724-.951.564-2.005.974-3.127 1.195-.897-.957-2.178-1.555-3.594-1.555-3.179 0-5.515 2.966-4.797 6.045-4.091-.205-7.719-2.165-10.148-5.144-1.29 2.213-.669 5.108 1.523 6.574-.806-.026-1.566-.247-2.229-.616-.054 2.281 1.581 4.415 3.949 4.89-.693.188-1.452.232-2.224.084.626 1.956 2.444 3.379 4.6 3.419-2.07 1.623-4.678 2.348-7.29 2.04 2.179 1.397 4.768 2.212 7.548 2.212 9.142 0 14.307-7.721 13.995-14.646.962-.695 1.797-1.562 2.457-2.549z"
|
|
24
|
+
/>
|
|
25
|
+
</svg>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
const InstagramIcon = (props: any) => {
|
|
29
|
+
return (
|
|
30
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
|
|
31
|
+
<path
|
|
32
|
+
fill="#0045d8"
|
|
33
|
+
d="M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zm0-2.163c-3.259 0-3.667.014-4.947.072-4.358.2-6.78 2.618-6.98 6.98-.059 1.281-.073 1.689-.073 4.948 0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98 1.281.058 1.689.072 4.948.072 3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98-1.281-.059-1.69-.073-4.949-.073zm0 5.838c-3.403 0-6.162 2.759-6.162 6.162s2.759 6.163 6.162 6.163 6.162-2.759 6.162-6.163c0-3.403-2.759-6.162-6.162-6.162zm0 10.162c-2.209 0-4-1.79-4-4 0-2.209 1.791-4 4-4s4 1.791 4 4c0 2.21-1.791 4-4 4zm6.406-11.845c-.796 0-1.441.645-1.441 1.44s.645 1.44 1.441 1.44c.795 0 1.439-.645 1.439-1.44s-.644-1.44-1.439-1.44z"
|
|
34
|
+
/>
|
|
35
|
+
</svg>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const SocialIconMap: Record<Socials, (x: any) => JSX.Element> = {
|
|
40
|
+
facebook: FacebookIcon,
|
|
41
|
+
twitter: TwitterIcon,
|
|
42
|
+
instagram: InstagramIcon,
|
|
43
|
+
youtube: FaYoutube,
|
|
44
|
+
linkedin: FaLinkedin,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export interface SocialIconsProps extends Omit<HTMLProps<HTMLElement>, "as"> {
|
|
48
|
+
social?: Socials;
|
|
49
|
+
children?: ReactNode;
|
|
50
|
+
className?: string;
|
|
51
|
+
as?: ElementType;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const displayName = "SocialIcons";
|
|
55
|
+
|
|
56
|
+
export const SocialIcons: React.FC<SocialIconsProps> = ({
|
|
57
|
+
social = "facebook",
|
|
58
|
+
children,
|
|
59
|
+
className,
|
|
60
|
+
as,
|
|
61
|
+
...props
|
|
62
|
+
}) => {
|
|
63
|
+
const { [displayName]: Component = SocialIconMap[social] ?? FaFacebook } =
|
|
64
|
+
useStackShiftUIComponents();
|
|
65
|
+
|
|
66
|
+
const commonClass = `w-8 h-8 text-primary-foreground`;
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Component
|
|
70
|
+
as={as}
|
|
71
|
+
className={cn(commonClass, className)}
|
|
72
|
+
{...props}
|
|
73
|
+
data-testid={displayName.toLowerCase()}>
|
|
74
|
+
{children}
|
|
75
|
+
</Component>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
SocialIcons.displayName = displayName;
|