@stackshift-ui/youtube-video 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 CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@stackshift-ui/youtube-video",
3
3
  "description": "",
4
- "version": "6.0.2",
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,19 +29,19 @@
28
29
  "typescript": "^5.6.2",
29
30
  "vite-tsconfig-paths": "^5.0.1",
30
31
  "vitest": "^2.1.1",
31
- "@stackshift-ui/eslint-config": "6.0.2",
32
- "@stackshift-ui/typescript-config": "6.0.2"
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
- "@stackshift-ui/system": "6.0.2",
36
- "@stackshift-ui/scripts": "6.0.2"
36
+ "@stackshift-ui/scripts": "6.0.3-beta.0",
37
+ "@stackshift-ui/system": "6.0.4-beta.0"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "@types/react": "16.8 - 19",
40
41
  "next": "10 - 14",
41
42
  "react": "16.8 - 19",
42
43
  "react-dom": "16.8 - 19",
43
- "@stackshift-ui/system": ">=0.0.0"
44
+ "@stackshift-ui/system": ">=6.0.4-beta.0"
44
45
  },
45
46
  "peerDependenciesMeta": {
46
47
  "next": {
package/src/index.ts ADDED
@@ -0,0 +1,4 @@
1
+ "use client";
2
+
3
+ // component exports
4
+ export * from "./youtube-video";
@@ -0,0 +1,13 @@
1
+ import { cleanup, render, screen } from "@testing-library/react";
2
+ import { afterEach, describe, test } from "vitest";
3
+ import { YoutubeVideo } from "./youtube-video";
4
+
5
+ describe.concurrent("youtube-video", () => {
6
+ afterEach(cleanup);
7
+
8
+ test("Common: YouTube Video - test if renders without errors", ({ expect }) => {
9
+ const clx = "aspect-video";
10
+ render(<YoutubeVideo className={clx} />);
11
+ expect(screen.getByTestId("div").classList).toContain(clx);
12
+ });
13
+ });
@@ -0,0 +1,39 @@
1
+ import { DefaultComponent, useStackShiftUIComponents } from "@stackshift-ui/system";
2
+ import type { ElementType, HTMLProps, ReactNode } from "react";
3
+
4
+ export interface YoutubeVideoProps extends Omit<HTMLProps<HTMLElement>, "as"> {
5
+ videoLinkId?: string;
6
+ title?: string;
7
+ children?: ReactNode;
8
+ className?: string;
9
+ as?: ElementType;
10
+ }
11
+
12
+ const displayName = "YoutubeVideo";
13
+
14
+ export const YoutubeVideo: React.FC<YoutubeVideoProps> = ({
15
+ videoLinkId,
16
+ title,
17
+ children,
18
+ className,
19
+ as,
20
+ ...props
21
+ }) => {
22
+ const { [displayName]: Component = DefaultComponent } = useStackShiftUIComponents();
23
+ const defaultClass = "aspect-video";
24
+
25
+ return (
26
+ <Component as={as} className={defaultClass} {...props} data-testid={displayName}>
27
+ <iframe
28
+ aria-label="Show Video Frame"
29
+ className="w-full h-full rounded-lg"
30
+ src={`https://www.youtube.com/embed/${videoLinkId}`}
31
+ srcDoc={`<style>*{padding:0;margin:0;overflow:hidden;border-radius:8px}html,body{height:100%}img,span{position:absolute;width:100%;top:0;bottom:0;margin:auto}span{height:1.5em;text-align:center;font:48px/1.5 sans-serif;color:white;text-shadow:0 0 0.5em black}</style><a href=${`https://www.youtube.com/embed/${videoLinkId}`}><img src=${`https://i.ytimg.com/vi_webp/${videoLinkId}/maxresdefault.webp`} alt=${title} loading="lazy" /><span>▶</span></a>`}
32
+ frameBorder="0"
33
+ loading="lazy"
34
+ allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"></iframe>
35
+ </Component>
36
+ );
37
+ };
38
+
39
+ YoutubeVideo.displayName = displayName;