@astratra/saas-kit-ui 1.2.0 → 1.3.0
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 +1 -1
- package/src/components/FeedbackBar.js +19 -2
- package/src/styles/global.css +9 -0
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ Utilisez ce paquet si `AstratraDashboardApp` vous convient tel quel ; utilisez `
|
|
|
68
68
|
|
|
69
69
|
MIT.
|
|
70
70
|
|
|
71
|
-
## FeedbackBar :
|
|
71
|
+
## FeedbackBar : pouces sous une réponse d’IA
|
|
72
72
|
|
|
73
73
|
Le même composant que dans `@astratra/native-ui`, pour le web. Contrôlé :
|
|
74
74
|
l'application garde `value` et parle à son serveur (par exemple
|
|
@@ -88,7 +88,7 @@ import { FeedbackBar } from '@astratra/saas-kit-ui';
|
|
|
88
88
|
Le pouce haut part aussitôt ; le pouce bas ouvre un panneau (raison,
|
|
89
89
|
commentaire facultatif) ; appuyer sur le pouce choisi le retire. Libellés par
|
|
90
90
|
défaut en anglais et en français (`locale`), remplaçables un par un (`labels`) ;
|
|
91
|
-
raisons ajoutables (`reasons`) ; `icons` remplace les émojis ; `haptics` est une
|
|
91
|
+
raisons ajoutables (`reasons`) ; `icons` remplace les pouces dessinés (contour SVG, plein une fois choisi, jamais d'émojis) ; `haptics` est une
|
|
92
92
|
fonction facultative (rien par défaut). Accessibilité : groupe nommé, boutons à
|
|
93
93
|
`aria-pressed`, puces `radio`, panneau `dialog`, Échap le ferme. Le style vient
|
|
94
94
|
des classes `.astratra-feedback*` de `styles.css` et des variables CSS du kit.
|
package/package.json
CHANGED
|
@@ -8,7 +8,24 @@ import {
|
|
|
8
8
|
resolveFeedbackLabels
|
|
9
9
|
} from '../lib/feedbackBar.js';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* The thumbs are drawn, never emoji (an emoji changes with the system and looks out of place in a
|
|
13
|
+
* product). One outline on a 24 grid; down is the same hand turned upside down. Filled once chosen.
|
|
14
|
+
*/
|
|
15
|
+
export const THUMB_PATH = 'M7 21H4.5A1.5 1.5 0 0 1 3 19.5v-8A1.5 1.5 0 0 1 4.5 10H7M7 21V10l4.2-6.3A1.6 1.6 0 0 1 14 4.6V9h5a2 2 0 0 1 2 2.4l-1.5 7.9A2 2 0 0 1 17.5 21H7';
|
|
16
|
+
|
|
17
|
+
function thumbIcon(rating, filled) {
|
|
18
|
+
return h('svg', {
|
|
19
|
+
'aria-hidden': 'true', focusable: 'false', viewBox: '0 0 24 24', width: 18, height: 18,
|
|
20
|
+
className: 'astratra-feedback__icon', fill: 'none', stroke: 'currentColor',
|
|
21
|
+
strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round'
|
|
22
|
+
}, h('path', {
|
|
23
|
+
d: THUMB_PATH,
|
|
24
|
+
fill: filled ? 'currentColor' : 'none',
|
|
25
|
+
fillOpacity: filled ? 0.9 : undefined,
|
|
26
|
+
transform: rating === 'down' ? 'matrix(1 0 0 -1 0 24)' : undefined
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
12
29
|
|
|
13
30
|
/**
|
|
14
31
|
* Thumbs up / thumbs down under an AI answer. Controlled: the app keeps
|
|
@@ -45,7 +62,7 @@ export default function FeedbackBar({
|
|
|
45
62
|
const thumb = (rating) => h('button', {
|
|
46
63
|
key: rating, type: 'button', disabled, 'aria-pressed': value === rating, 'aria-label': words[rating], title: words[rating],
|
|
47
64
|
className: 'astratra-feedback__thumb', 'data-rating': rating, onClick: () => press(rating)
|
|
48
|
-
}, icons?.[rating] ??
|
|
65
|
+
}, icons?.[rating] ?? thumbIcon(rating, value === rating));
|
|
49
66
|
|
|
50
67
|
const options = feedbackReasonOptions({ reasons, labels: words, selected: reason });
|
|
51
68
|
return h('div', { id, role: 'group', 'aria-label': words.group, className: ['astratra-feedback', className].filter(Boolean).join(' '), style },
|
package/src/styles/global.css
CHANGED
|
@@ -114,10 +114,19 @@ h3 {
|
|
|
114
114
|
border-radius: 999px;
|
|
115
115
|
background: transparent;
|
|
116
116
|
cursor: pointer;
|
|
117
|
+
color: var(--text, currentColor);
|
|
117
118
|
opacity: 0.7;
|
|
118
119
|
transition: opacity 120ms, background 120ms;
|
|
119
120
|
}
|
|
120
121
|
|
|
122
|
+
.astratra-feedback__icon {
|
|
123
|
+
display: block;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.astratra-feedback__thumb[aria-pressed="true"] .astratra-feedback__icon {
|
|
127
|
+
color: var(--lime, #d9ff66);
|
|
128
|
+
}
|
|
129
|
+
|
|
121
130
|
.astratra-feedback__thumb:hover:not(:disabled),
|
|
122
131
|
.astratra-feedback__thumb:focus-visible {
|
|
123
132
|
opacity: 1;
|