@uniweb/kit 0.19.13 → 0.19.14
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/README.md +2 -2
- package/package.json +4 -4
- package/src/components/Link/Link.jsx +16 -26
package/README.md
CHANGED
|
@@ -53,7 +53,7 @@ function Hero({ content }) {
|
|
|
53
53
|
|
|
54
54
|
### Link
|
|
55
55
|
|
|
56
|
-
Smart link component with routing, downloads,
|
|
56
|
+
Smart link component with routing and downloads. A link that leaves the site, downloads a file, writes an email or places a call gets a tooltip saying so; an internal link gets none.
|
|
57
57
|
|
|
58
58
|
```jsx
|
|
59
59
|
import { Link } from '@uniweb/kit'
|
|
@@ -67,7 +67,7 @@ import { Link } from '@uniweb/kit'
|
|
|
67
67
|
| Prop | Type | Description |
|
|
68
68
|
|------|------|-------------|
|
|
69
69
|
| `to` / `href` | `string` | Destination URL |
|
|
70
|
-
| `title` | `string` | Tooltip
|
|
70
|
+
| `title` | `string` | Tooltip. If omitted, one is generated only where the link leaves the site, downloads, writes an email or places a call |
|
|
71
71
|
| `target` | `string` | Link target |
|
|
72
72
|
| `download` | `boolean` | Force download behavior |
|
|
73
73
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/kit",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.14",
|
|
4
4
|
"description": "Standard component library for Uniweb foundations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"shiki": "^3.0.0",
|
|
44
44
|
"tailwind-merge": "^3.6.0",
|
|
45
45
|
"temml": "^0.13.2",
|
|
46
|
+
"@uniweb/schemas": "^0.10.0",
|
|
46
47
|
"@uniweb/semantic-parser": "^1.5.1",
|
|
48
|
+
"@uniweb/scene": "^0.1.3",
|
|
47
49
|
"@uniweb/core": "^0.35.0",
|
|
48
|
-
"@uniweb/projections": "^0.7.11"
|
|
49
|
-
"@uniweb/schemas": "^0.9.4",
|
|
50
|
-
"@uniweb/scene": "^0.1.3"
|
|
50
|
+
"@uniweb/projections": "^0.7.11"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": "^19.0.0",
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* - Internal navigation via React Router
|
|
6
6
|
* - External links with appropriate attributes
|
|
7
7
|
* - File downloads
|
|
8
|
-
* -
|
|
8
|
+
* - A generated tooltip where a link does something its text may not say:
|
|
9
|
+
* leaves the site, downloads a file, writes an email, places a call
|
|
9
10
|
*
|
|
10
11
|
* @module @uniweb/kit/Link
|
|
11
12
|
*/
|
|
@@ -52,10 +53,17 @@ function detectSocialPlatform(url) {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
|
-
*
|
|
56
|
+
* The tooltip a link gets when its caller gives none — only where the link does
|
|
57
|
+
* something its text may not say. An internal link gets none: its text names where
|
|
58
|
+
* it goes.
|
|
59
|
+
*
|
|
60
|
+
* ⛔ Until 2026-09-30 an internal link got `Go to <its path>`, dashes as spaces —
|
|
61
|
+
* `Go to blog/writing for the web` on every card of a blog [Diego: "stop adding it
|
|
62
|
+
* to internal links"].
|
|
63
|
+
*
|
|
56
64
|
* @param {string} href - The link URL
|
|
57
65
|
* @param {Function} localize - Localization function
|
|
58
|
-
* @returns {string}
|
|
66
|
+
* @returns {string} the tooltip, or '' for none
|
|
59
67
|
*/
|
|
60
68
|
function generateTitle(href, localize) {
|
|
61
69
|
if (!href) return ''
|
|
@@ -108,26 +116,6 @@ function generateTitle(href, localize) {
|
|
|
108
116
|
})
|
|
109
117
|
}
|
|
110
118
|
|
|
111
|
-
// Internal links - humanize the path
|
|
112
|
-
try {
|
|
113
|
-
const url = new URL(href, window.location.origin)
|
|
114
|
-
const path = decodeURIComponent(url.pathname)
|
|
115
|
-
.replace(/^\/+/, '')
|
|
116
|
-
.replace(/[-_]/g, ' ')
|
|
117
|
-
.replace(/\.\w+$/, '')
|
|
118
|
-
.trim()
|
|
119
|
-
|
|
120
|
-
if (path) {
|
|
121
|
-
return localize({
|
|
122
|
-
en: `Go to ${path}`,
|
|
123
|
-
fr: `Aller à ${path}`,
|
|
124
|
-
es: `Ir a ${path}`
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
} catch {
|
|
128
|
-
// Invalid URL
|
|
129
|
-
}
|
|
130
|
-
|
|
131
119
|
return ''
|
|
132
120
|
}
|
|
133
121
|
|
|
@@ -137,7 +125,9 @@ function generateTitle(href, localize) {
|
|
|
137
125
|
* @param {Object} props
|
|
138
126
|
* @param {string} [props.to] - Destination URL (alias for href)
|
|
139
127
|
* @param {string} [props.href] - Destination URL
|
|
140
|
-
* @param {string} [props.title] - Custom title/tooltip
|
|
128
|
+
* @param {string} [props.title] - Custom title/tooltip. Without one, a link that leaves the
|
|
129
|
+
* site, downloads, writes an email or places a call gets one saying so; an internal
|
|
130
|
+
* link gets none
|
|
141
131
|
* @param {string} [props.target] - Link target (_blank, _self, etc.)
|
|
142
132
|
* @param {string} [props.className] - CSS classes
|
|
143
133
|
* @param {boolean} [props.download] - Force download behavior
|
|
@@ -192,8 +182,8 @@ export function Link({
|
|
|
192
182
|
// Determine if external
|
|
193
183
|
const isExternal = isExternalUrl(linkHref)
|
|
194
184
|
|
|
195
|
-
//
|
|
196
|
-
const linkTitle = title || generateTitle(linkHref, localize)
|
|
185
|
+
// A generated tooltip when none is given — none at all rather than an empty one.
|
|
186
|
+
const linkTitle = title || generateTitle(linkHref, localize) || undefined
|
|
197
187
|
|
|
198
188
|
// Links with reload: render plain <a> for full page navigation
|
|
199
189
|
// Used for locale switches (same-domain or cross-domain)
|