@stackshift-ui/image 1.0.0 → 6.0.3
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 +7 -6
- package/src/helper/index.ts +14 -0
- package/src/image.test.tsx +13 -0
- package/src/image.tsx +28 -0
- package/src/index.ts +4 -0
- package/src/types.ts +11 -0
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackshift-ui/image",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
|
-
"dist/**"
|
|
10
|
+
"dist/**",
|
|
11
|
+
"src"
|
|
11
12
|
],
|
|
12
13
|
"devDependencies": {
|
|
13
14
|
"@testing-library/react": "^16.0.1",
|
|
@@ -26,12 +27,12 @@
|
|
|
26
27
|
"typescript": "^5.6.2",
|
|
27
28
|
"vite-tsconfig-paths": "^5.0.1",
|
|
28
29
|
"vitest": "^2.1.1",
|
|
29
|
-
"@stackshift-ui/eslint-config": "
|
|
30
|
-
"@stackshift-ui/typescript-config": "
|
|
30
|
+
"@stackshift-ui/eslint-config": "6.0.2",
|
|
31
|
+
"@stackshift-ui/typescript-config": "6.0.2"
|
|
31
32
|
},
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@stackshift-ui/scripts": "
|
|
34
|
-
"@stackshift-ui/system": "
|
|
34
|
+
"@stackshift-ui/scripts": "6.0.2",
|
|
35
|
+
"@stackshift-ui/system": "6.0.3"
|
|
35
36
|
},
|
|
36
37
|
"peerDependencies": {
|
|
37
38
|
"@types/react": "16.8 - 19",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Logo } from "../types";
|
|
2
|
+
|
|
3
|
+
export const logoLink = (logo?: Logo) => {
|
|
4
|
+
if (logo?.internalLink && logo?.type === "linkInternal") {
|
|
5
|
+
if (logo?.internalLink?.toLowerCase()?.includes("home")) {
|
|
6
|
+
return "/";
|
|
7
|
+
}
|
|
8
|
+
return `/${logo.internalLink}`;
|
|
9
|
+
} else if (logo?.externalLink && logo?.type === "linkExternal") {
|
|
10
|
+
return logo?.externalLink ?? "/";
|
|
11
|
+
} else {
|
|
12
|
+
return "/";
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { cleanup, render, screen } from "@testing-library/react";
|
|
2
|
+
import { afterEach, describe, test } from "vitest";
|
|
3
|
+
import { Image } from "./image";
|
|
4
|
+
|
|
5
|
+
describe.concurrent("image", () => {
|
|
6
|
+
afterEach(cleanup);
|
|
7
|
+
|
|
8
|
+
test("Dummy test - test if renders without errors", ({ expect }) => {
|
|
9
|
+
const clx = "my-class";
|
|
10
|
+
render(<Image className={clx} />);
|
|
11
|
+
expect(screen.getByTestId("image").classList).toContain(clx);
|
|
12
|
+
});
|
|
13
|
+
});
|
package/src/image.tsx
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { useStackShiftUIComponents } from "@stackshift-ui/system";
|
|
2
|
+
import type { HTMLProps, ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
export interface ImageProps extends HTMLProps<HTMLImageElement> {
|
|
5
|
+
children?: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Image component
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```tsx
|
|
13
|
+
* <Image />
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @source - Source code
|
|
17
|
+
*/
|
|
18
|
+
const displayName = "Image";
|
|
19
|
+
export const Image = ({ children, ...props }: ImageProps) => {
|
|
20
|
+
const components = useStackShiftUIComponents();
|
|
21
|
+
const { [displayName]: Component = "img" } = components;
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Component {...props} data-testid="image">
|
|
25
|
+
{children}
|
|
26
|
+
</Component>
|
|
27
|
+
);
|
|
28
|
+
};
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED