@slopmachine/react 0.1.9 → 0.1.12

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/Agents.md ADDED
@@ -0,0 +1,34 @@
1
+ # React SDK Conventions
2
+
3
+ This document outlines the coding conventions and patterns used in the `@slopmachine/react` SDK. Future agents should adhere to these guidelines when making modifications or adding new components.
4
+
5
+ ## Dependencies and Styling
6
+
7
+ - **Class Merging:** Use `clsx` and `tailwind-merge` to construct and merge Tailwind CSS classes. A utility function `cn(...inputs: ClassValue[])` is typically used for this purpose.
8
+ - **Styling Approach:** Components use Tailwind CSS classes for styling. However, to ensure components remain robust even if the consumer's environment doesn't perfectly process all Tailwind classes, always include equivalent inline `style` properties as a fallback.
9
+ - **CSS Variables:** Use standard CSS variables for theme-related colors (e.g., `var(--muted, #f3f4f6)`).
10
+ - **Custom Animations/Styles:** If complex animations or specific scoped styles are needed that go beyond Tailwind utility classes, inject them using a scoped `<style>` block within the component.
11
+ - **Core Logic:** Import shared logic, utilities, and base types from `@slopmachine/core`.
12
+
13
+ ## Component Structure
14
+
15
+ - **Functional Components:** Define components as Functional Components (e.g., `React.FC<Props>`).
16
+ - **Prop Forwarding:** Spread the remaining props (`...props`) onto the primary underlying DOM element to allow consumers to pass standard HTML attributes (like `aria-` attributes, data attributes, etc.).
17
+
18
+ ## Prop Typing
19
+
20
+ - **Interfaces:** Define an explicit `Props` interface for each component.
21
+ - **Extending Standard Attributes:** Extend the appropriate React HTML attributes interface (e.g., `React.ImgHTMLAttributes<HTMLImageElement>`).
22
+ - **Overriding Attributes:** Use `Omit` to exclude standard attributes that are managed internally by the component or replaced by custom SDK options (e.g., `Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src" | "alt">`).
23
+ - **Shared Types:** Extend or incorporate types from `@slopmachine/core` (like `SlopImageOptions`).
24
+
25
+ ## IntelliSense and Documentation
26
+
27
+ - **JSDoc Comments:** Always include descriptive JSDoc comments for components and their props to provide rich IntelliSense in IDEs.
28
+ - **Component Documentation:** Component JSDoc blocks should describe what the component does and include a clear `@example` block demonstrating usage, and optionally a `@version` tag if applicable.
29
+ - **Prop Documentation:** Every custom prop in a component's interface should have a JSDoc comment explaining its purpose, default behavior, and any edge cases. This is crucial for developer experience when consuming the SDK.
30
+
31
+ ## Exporting Patterns
32
+
33
+ - **Named Exports:** Use named exports for components and interfaces (e.g., `export const ComponentName = ...`). Avoid default exports.
34
+ - **Entry Point:** Ensure components and their prop types are exported from the package's main entry point if they are meant for public consumption.
package/README.md CHANGED
@@ -14,7 +14,7 @@ pnpm add @slopmachine/react
14
14
 
15
15
  ## Demo
16
16
 
17
- https://slopmachine-dev.github.io/slopmachine-sdk/
17
+ https://slopmachine-dev.github.io/slopmachine-sdk/demo-react/
18
18
 
19
19
  ## Usage
20
20
 
package/dist/index.d.mts CHANGED
@@ -1,8 +1,68 @@
1
1
  import React from 'react';
2
- import { SlopImageOptions } from '@slopmachine/core';
2
+ import { SlopImageOptions, ImageAspectRatio, SlopVideoOptions, VideoAspectRatio } from '@slopmachine/core';
3
+ export { ImageAspectRatio, SlopImageOptions, SlopVideoOptions, VideoAspectRatio } from '@slopmachine/core';
3
4
 
4
- interface SlopImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src" | "alt">, SlopImageOptions {
5
+ interface SlopImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src" | "alt">, Omit<SlopImageOptions, "aspectRatio"> {
6
+ /**
7
+ * The aspect ratio of the generated image. Defaults to "1:1".
8
+ */
9
+ aspectRatio?: ImageAspectRatio;
10
+ /**
11
+ * Custom React node to display while the image is loading.
12
+ * If not provided, a default spinner and shimmer effect will be shown.
13
+ */
14
+ loader?: React.ReactNode;
5
15
  }
16
+ /**
17
+ * Renders an image generated by Slop Machine.
18
+ *
19
+ * This component automatically constructs the correct URL for the Slop Machine API,
20
+ * displays a loading skeleton or custom loader while fetching, and handles errors.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * <SlopImage
25
+ * bucketId="my-bucket"
26
+ * resultId="some-result"
27
+ * aspectRatio="16:9"
28
+ * className="rounded-lg"
29
+ * />
30
+ * ```
31
+ *
32
+ * @version 0.1.12
33
+ */
6
34
  declare const SlopImage: React.FC<SlopImageProps>;
7
35
 
8
- export { SlopImage };
36
+ interface SlopVideoProps extends Omit<React.VideoHTMLAttributes<HTMLVideoElement>, "src">, Omit<SlopVideoOptions, "aspectRatio"> {
37
+ /**
38
+ * The aspect ratio of the generated video. Defaults to "16:9".
39
+ */
40
+ aspectRatio?: VideoAspectRatio;
41
+ /**
42
+ * Custom React node to display while the video is loading.
43
+ * If not provided, a default spinner and shimmer effect will be shown.
44
+ */
45
+ loader?: React.ReactNode;
46
+ }
47
+ /**
48
+ * Renders a video generated by Slop Machine.
49
+ *
50
+ * This component automatically constructs the correct URL for the Slop Machine API,
51
+ * displays a loading skeleton or custom loader while fetching, and handles errors.
52
+ *
53
+ * @example
54
+ * ```tsx
55
+ * <SlopVideo
56
+ * bucketId="my-bucket"
57
+ * resultId="some-result"
58
+ * aspectRatio="16:9"
59
+ * className="rounded-lg"
60
+ * autoPlay
61
+ * loop
62
+ * muted
63
+ * />
64
+ * ```
65
+ */
66
+ declare const SlopVideo: React.FC<SlopVideoProps>;
67
+
68
+ export { SlopImage, type SlopImageProps, SlopVideo, type SlopVideoProps };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,68 @@
1
1
  import React from 'react';
2
- import { SlopImageOptions } from '@slopmachine/core';
2
+ import { SlopImageOptions, ImageAspectRatio, SlopVideoOptions, VideoAspectRatio } from '@slopmachine/core';
3
+ export { ImageAspectRatio, SlopImageOptions, SlopVideoOptions, VideoAspectRatio } from '@slopmachine/core';
3
4
 
4
- interface SlopImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src" | "alt">, SlopImageOptions {
5
+ interface SlopImageProps extends Omit<React.ImgHTMLAttributes<HTMLImageElement>, "src" | "alt">, Omit<SlopImageOptions, "aspectRatio"> {
6
+ /**
7
+ * The aspect ratio of the generated image. Defaults to "1:1".
8
+ */
9
+ aspectRatio?: ImageAspectRatio;
10
+ /**
11
+ * Custom React node to display while the image is loading.
12
+ * If not provided, a default spinner and shimmer effect will be shown.
13
+ */
14
+ loader?: React.ReactNode;
5
15
  }
16
+ /**
17
+ * Renders an image generated by Slop Machine.
18
+ *
19
+ * This component automatically constructs the correct URL for the Slop Machine API,
20
+ * displays a loading skeleton or custom loader while fetching, and handles errors.
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * <SlopImage
25
+ * bucketId="my-bucket"
26
+ * resultId="some-result"
27
+ * aspectRatio="16:9"
28
+ * className="rounded-lg"
29
+ * />
30
+ * ```
31
+ *
32
+ * @version 0.1.12
33
+ */
6
34
  declare const SlopImage: React.FC<SlopImageProps>;
7
35
 
8
- export { SlopImage };
36
+ interface SlopVideoProps extends Omit<React.VideoHTMLAttributes<HTMLVideoElement>, "src">, Omit<SlopVideoOptions, "aspectRatio"> {
37
+ /**
38
+ * The aspect ratio of the generated video. Defaults to "16:9".
39
+ */
40
+ aspectRatio?: VideoAspectRatio;
41
+ /**
42
+ * Custom React node to display while the video is loading.
43
+ * If not provided, a default spinner and shimmer effect will be shown.
44
+ */
45
+ loader?: React.ReactNode;
46
+ }
47
+ /**
48
+ * Renders a video generated by Slop Machine.
49
+ *
50
+ * This component automatically constructs the correct URL for the Slop Machine API,
51
+ * displays a loading skeleton or custom loader while fetching, and handles errors.
52
+ *
53
+ * @example
54
+ * ```tsx
55
+ * <SlopVideo
56
+ * bucketId="my-bucket"
57
+ * resultId="some-result"
58
+ * aspectRatio="16:9"
59
+ * className="rounded-lg"
60
+ * autoPlay
61
+ * loop
62
+ * muted
63
+ * />
64
+ * ```
65
+ */
66
+ declare const SlopVideo: React.FC<SlopVideoProps>;
67
+
68
+ export { SlopImage, type SlopImageProps, SlopVideo, type SlopVideoProps };