tinywidgets 1.0.14 → 1.0.15
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,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinywidgets",
|
|
3
|
-
"
|
|
4
|
-
"version": "1.0.14",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"prePublishPackage": "eslint . && cspell --quiet . && tsc"
|
|
7
|
-
},
|
|
3
|
+
"version": "1.0.15",
|
|
8
4
|
"author": "jamesgpearce",
|
|
9
5
|
"repository": "github:tinyplex/tinywidgets",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://tinywidgets.org",
|
|
8
|
+
"description": "A collection of tiny, reusable, UI components - wrapped in a helpful app layout with header, side bar, dark mode, and more.",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"tiny",
|
|
11
|
+
"local-first",
|
|
12
|
+
"ui",
|
|
13
|
+
"components",
|
|
14
|
+
"styling",
|
|
15
|
+
"react"
|
|
16
|
+
],
|
|
10
17
|
"type": "module",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"prePublishPackage": "eslint . && cspell --quiet . && tsc"
|
|
20
|
+
},
|
|
11
21
|
"devDependencies": {
|
|
12
22
|
"@types/react": "^18.3.11",
|
|
13
23
|
"@types/react-dom": "^18.3.0",
|
|
@@ -26,7 +36,6 @@
|
|
|
26
36
|
".": "./src/index.ts",
|
|
27
37
|
"./css": "./src/index.css.ts"
|
|
28
38
|
},
|
|
29
|
-
"license": "MIT",
|
|
30
39
|
"dependencies": {
|
|
31
40
|
"@vanilla-extract/css": "^1.16.0",
|
|
32
41
|
"lucide-react": "^0.447.0",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import React, {useCallback} from 'react';
|
|
2
|
+
import {clickable, image, imageVariants} from './index.css.ts';
|
|
3
3
|
import {classNames} from '../../common/functions.tsx';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -46,6 +46,7 @@ export const Image = ({
|
|
|
46
46
|
src,
|
|
47
47
|
onClick,
|
|
48
48
|
variant = 'default',
|
|
49
|
+
href,
|
|
49
50
|
alt,
|
|
50
51
|
className,
|
|
51
52
|
}: {
|
|
@@ -65,6 +66,11 @@ export const Image = ({
|
|
|
65
66
|
* - `icon`
|
|
66
67
|
*/
|
|
67
68
|
readonly variant?: keyof typeof imageVariants;
|
|
69
|
+
/**
|
|
70
|
+
* A URL that can be used instead of an `onClick` to launch a new web
|
|
71
|
+
* page, much like a link.
|
|
72
|
+
*/
|
|
73
|
+
readonly href?: string;
|
|
68
74
|
/**
|
|
69
75
|
* Alternative text shown when the user hovers over the image.
|
|
70
76
|
*/
|
|
@@ -74,12 +80,22 @@ export const Image = ({
|
|
|
74
80
|
*/
|
|
75
81
|
readonly className?: string;
|
|
76
82
|
}) => {
|
|
83
|
+
const hrefClick = useCallback(
|
|
84
|
+
() => (href ? open(href, '_blank', 'noreferrer') : null),
|
|
85
|
+
[href],
|
|
86
|
+
);
|
|
87
|
+
|
|
77
88
|
return (
|
|
78
89
|
<img
|
|
79
90
|
src={src}
|
|
80
|
-
onClick={onClick}
|
|
91
|
+
onClick={onClick ?? hrefClick}
|
|
81
92
|
title={alt}
|
|
82
|
-
className={classNames(
|
|
93
|
+
className={classNames(
|
|
94
|
+
image,
|
|
95
|
+
imageVariants[variant],
|
|
96
|
+
(onClick || href) && clickable,
|
|
97
|
+
className,
|
|
98
|
+
)}
|
|
83
99
|
/>
|
|
84
100
|
);
|
|
85
101
|
};
|
package/src/css/global.css.ts
CHANGED