@fluidattacks/design 1.1.0 → 1.2.1

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.
@@ -0,0 +1,12 @@
1
+ import { Plugins } from '@cloudinary/html';
2
+ import { default as React } from 'react';
3
+ interface IImageProps {
4
+ alt?: string;
5
+ height?: number | string;
6
+ publicId: string;
7
+ width?: number | string;
8
+ plugins?: Plugins;
9
+ }
10
+ declare const MemoizedImage: React.MemoExoticComponent<({ alt, height, publicId, width, plugins, }: Readonly<IImageProps>) => JSX.Element>;
11
+ export type { IImageProps };
12
+ export default MemoizedImage;
@@ -0,0 +1,2 @@
1
+ import { useCloudinaryImage } from './use-cloudinary-image';
2
+ export { useCloudinaryImage };
@@ -0,0 +1,7 @@
1
+ import { CloudinaryImage } from '@cloudinary/url-gen';
2
+ interface IUseCloudinaryImageProps {
3
+ publicId: string;
4
+ format?: string;
5
+ }
6
+ export declare const useCloudinaryImage: ({ publicId, format, }: IUseCloudinaryImageProps) => CloudinaryImage;
7
+ export {};
@@ -0,0 +1 @@
1
+ export { default as CloudImage } from './components/cloud-image';
@@ -0,0 +1,3 @@
1
+ import { UserConfigExport } from 'vite';
2
+ declare const viteConfig: UserConfigExport;
3
+ export default viteConfig;
package/package.json CHANGED
@@ -14,8 +14,12 @@
14
14
  "devDependencies": {
15
15
  "@types/react": "18.2.0",
16
16
  "@types/react-dom": "18.2.0",
17
- "typescript": "5.6.2"
17
+ "@vitejs/plugin-react-swc": "3.7.1",
18
+ "typescript": "5.6.2",
19
+ "vite-plugin-dts": "4.2.3",
20
+ "vite": "5.4.8"
18
21
  },
22
+ "files": ["dist"],
19
23
  "homepage": "https://gitlab.com/fluidattacks/universe#readme",
20
24
  "keywords": [
21
25
  "components",
@@ -23,13 +27,21 @@
23
27
  "fluidattacks"
24
28
  ],
25
29
  "license": "MPL-2.0",
30
+ "main": "dist/design.js",
31
+ "module": "dist/design.mjs",
32
+ "types": "dist/src/index.d.ts",
26
33
  "name": "@fluidattacks/design",
34
+ "publishConfig": {
35
+ "access": "public"
36
+ },
27
37
  "repository": {
28
38
  "type": "git",
29
39
  "url": "git+https://gitlab.com/fluidattacks/universe.git"
30
40
  },
31
41
  "scripts": {
32
- "test": "echo \"Error: no test specified\" && exit 1"
42
+ "dev": "vite",
43
+ "build": "tsc && vite build",
44
+ "preview": "vite preview"
33
45
  },
34
- "version": "1.1.0"
46
+ "version": "1.2.1"
35
47
  }
@@ -1,38 +0,0 @@
1
- import type { Plugins } from "@cloudinary/html";
2
- import { AdvancedImage, lazyload, placeholder } from "@cloudinary/react";
3
- import React from "react";
4
-
5
- import { useCloudinaryImage } from "hooks";
6
-
7
- interface IImageProps {
8
- alt?: string;
9
- height?: number | string;
10
- publicId: string;
11
- width?: number | string;
12
- plugins?: Plugins;
13
- }
14
-
15
- const CloudImage = ({
16
- alt,
17
- height,
18
- publicId,
19
- width,
20
- plugins = [lazyload(), placeholder()],
21
- }: Readonly<IImageProps>): JSX.Element => {
22
- const image = useCloudinaryImage({ publicId });
23
-
24
- return (
25
- <AdvancedImage
26
- alt={alt ?? "img"}
27
- cldImg={image}
28
- height={height ?? ""}
29
- plugins={plugins}
30
- width={width ?? ""}
31
- />
32
- );
33
- };
34
-
35
- const MemoizedImage = React.memo(CloudImage);
36
-
37
- export type { IImageProps };
38
- export { MemoizedImage as CloudImage };
@@ -1,3 +0,0 @@
1
- import { useCloudinaryImage } from "./use-cloudinary-image";
2
-
3
- export {useCloudinaryImage}
@@ -1,27 +0,0 @@
1
- import type { CloudinaryImage } from "@cloudinary/url-gen";
2
- import { Cloudinary } from "@cloudinary/url-gen";
3
- import { useMemo } from "react";
4
-
5
- interface IUseCloudinaryImageProps {
6
- publicId: string;
7
- format?: string;
8
- }
9
-
10
- export const useCloudinaryImage = ({
11
- publicId,
12
- format = "webp",
13
- }: IUseCloudinaryImageProps): CloudinaryImage => {
14
- const cloudinaryInstance = useMemo((): Cloudinary => {
15
- return new Cloudinary({
16
- cloud: {
17
- cloudName: "fluid-attacks",
18
- },
19
- });
20
- }, []);
21
-
22
- const image = useMemo((): CloudinaryImage => {
23
- return cloudinaryInstance.image(publicId).format(format);
24
- }, [cloudinaryInstance, publicId, format]);
25
-
26
- return image;
27
- };
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "baseUrl": "src",
4
- "esModuleInterop": true,
5
- "jsx": "react",
6
- "lib": ["dom", "es2023"],
7
- "paths": {
8
- "components/*": [ "components/*" ],
9
- "hooks/*": [ "hooks/*" ],
10
- }
11
- }
12
- }