@stackshift-ui/image 6.0.2 → 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 CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@stackshift-ui/image",
3
- "version": "6.0.2",
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",
@@ -31,7 +32,7 @@
31
32
  },
32
33
  "dependencies": {
33
34
  "@stackshift-ui/scripts": "6.0.2",
34
- "@stackshift-ui/system": "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
@@ -0,0 +1,4 @@
1
+ "use client";
2
+
3
+ // component exports
4
+ export * from "./image";
package/src/types.ts ADDED
@@ -0,0 +1,11 @@
1
+ export interface Logo extends ConditionalLink {
2
+ alt?: string;
3
+ linkTarget?: string;
4
+ image?: string;
5
+ }
6
+
7
+ export interface ConditionalLink {
8
+ type?: string;
9
+ internalLink?: string | null;
10
+ externalLink?: string | null;
11
+ }