@slopmachine/react 0.0.1 → 0.0.2
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/dist/index.js +5 -1
- package/dist/index.mjs +9 -2
- package/package.json +3 -3
- package/src/components/SlopImage.tsx +11 -2
package/dist/index.js
CHANGED
|
@@ -46,6 +46,10 @@ var SlopImage = ({
|
|
|
46
46
|
() => (0, import_core.buildImageUrl)({ prompt, aspectRatio, variables, baseUrl, model }),
|
|
47
47
|
[prompt, aspectRatio, variables, baseUrl, model]
|
|
48
48
|
);
|
|
49
|
+
const alt = (0, import_react.useMemo)(
|
|
50
|
+
() => (0, import_core.interpolatePrompt)(prompt, variables) ?? "Generated image",
|
|
51
|
+
[prompt, variables]
|
|
52
|
+
);
|
|
49
53
|
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
50
54
|
const [currentSrc, setCurrentSrc] = (0, import_react.useState)(src);
|
|
51
55
|
if (src !== currentSrc) {
|
|
@@ -194,7 +198,7 @@ var SlopImage = ({
|
|
|
194
198
|
"img",
|
|
195
199
|
{
|
|
196
200
|
src,
|
|
197
|
-
alt
|
|
201
|
+
alt,
|
|
198
202
|
onLoad: () => setIsLoading(false),
|
|
199
203
|
className: cn(
|
|
200
204
|
"h-full w-full object-cover transition-opacity duration-500",
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import { useMemo, useState } from "react";
|
|
3
3
|
import { clsx } from "clsx";
|
|
4
4
|
import { twMerge } from "tailwind-merge";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
buildImageUrl,
|
|
7
|
+
interpolatePrompt
|
|
8
|
+
} from "@slopmachine/core";
|
|
6
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
10
|
function cn(...inputs) {
|
|
8
11
|
return twMerge(clsx(inputs));
|
|
@@ -20,6 +23,10 @@ var SlopImage = ({
|
|
|
20
23
|
() => buildImageUrl({ prompt, aspectRatio, variables, baseUrl, model }),
|
|
21
24
|
[prompt, aspectRatio, variables, baseUrl, model]
|
|
22
25
|
);
|
|
26
|
+
const alt = useMemo(
|
|
27
|
+
() => interpolatePrompt(prompt, variables) ?? "Generated image",
|
|
28
|
+
[prompt, variables]
|
|
29
|
+
);
|
|
23
30
|
const [isLoading, setIsLoading] = useState(true);
|
|
24
31
|
const [currentSrc, setCurrentSrc] = useState(src);
|
|
25
32
|
if (src !== currentSrc) {
|
|
@@ -168,7 +175,7 @@ var SlopImage = ({
|
|
|
168
175
|
"img",
|
|
169
176
|
{
|
|
170
177
|
src,
|
|
171
|
-
alt
|
|
178
|
+
alt,
|
|
172
179
|
onLoad: () => setIsLoading(false),
|
|
173
180
|
className: cn(
|
|
174
181
|
"h-full w-full object-cover transition-opacity duration-500",
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slopmachine/react",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "The official React SDK for Slop Machine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
10
11
|
"import": "./dist/index.mjs",
|
|
11
|
-
"require": "./dist/index.js"
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
@@ -2,7 +2,11 @@ import React, { useMemo, useState } from "react";
|
|
|
2
2
|
import { clsx, type ClassValue } from "clsx";
|
|
3
3
|
import { twMerge } from "tailwind-merge";
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
buildImageUrl,
|
|
7
|
+
interpolatePrompt,
|
|
8
|
+
type SlopMachineOptions,
|
|
9
|
+
} from "@slopmachine/core";
|
|
6
10
|
|
|
7
11
|
// Utility for Tailwind classes
|
|
8
12
|
function cn(...inputs: ClassValue[]) {
|
|
@@ -29,6 +33,11 @@ export const SlopImage: React.FC<SlopImageProps> = ({
|
|
|
29
33
|
[prompt, aspectRatio, variables, baseUrl, model],
|
|
30
34
|
);
|
|
31
35
|
|
|
36
|
+
const alt = useMemo(
|
|
37
|
+
() => interpolatePrompt(prompt, variables) ?? "Generated image",
|
|
38
|
+
[prompt, variables],
|
|
39
|
+
);
|
|
40
|
+
|
|
32
41
|
const [isLoading, setIsLoading] = useState(true);
|
|
33
42
|
const [currentSrc, setCurrentSrc] = useState(src);
|
|
34
43
|
|
|
@@ -157,7 +166,7 @@ export const SlopImage: React.FC<SlopImageProps> = ({
|
|
|
157
166
|
<img
|
|
158
167
|
key={src}
|
|
159
168
|
src={src}
|
|
160
|
-
alt={
|
|
169
|
+
alt={alt}
|
|
161
170
|
onLoad={() => setIsLoading(false)}
|
|
162
171
|
className={cn(
|
|
163
172
|
"h-full w-full object-cover transition-opacity duration-500",
|