ng-hub-ui-utils 22.14.0 → 22.15.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 +23 -0
- package/fesm2022/ng-hub-ui-utils.mjs +363 -41
- package/fesm2022/ng-hub-ui-utils.mjs.map +1 -1
- package/package.json +8 -2
- package/types/ng-hub-ui-utils.d.ts +194 -12
package/README.md
CHANGED
|
@@ -704,6 +704,29 @@ These functions back the i18n system and are exported for direct use:
|
|
|
704
704
|
- `isInSrgbGamut(color): boolean` - Whether the colour survives the trip to sRGB
|
|
705
705
|
- `clampToSrgbGamut(color): HubOklch` - Reduces chroma until it fits, preserving lightness and hue
|
|
706
706
|
|
|
707
|
+
### Palette Derivation
|
|
708
|
+
|
|
709
|
+
One brand colour, the whole palette — and the two numbers that keep it honest.
|
|
710
|
+
|
|
711
|
+
- `harmoniseSemantics(primary, options?): HubSemanticPalette | null` - Rotates `success`, `warning`, `danger` and `info` towards the brand's hue and returns them as hex. Lightness is left exactly where the anchor had it, because it is what carries the contrast each role was chosen for; chroma is reduced only when the new hue cannot hold it inside sRGB
|
|
712
|
+
- `tintNeutrals(primary, options?): HubNeutralRamp | null` - Leans the grey ramp (`100` … `900`) the same way, keeping each step's lightness
|
|
713
|
+
- `HUB_MAX_HUE_SHIFT: number` (15) - How far a role may rotate, in degrees. Not taste: success and danger sit 135.8° apart in OKLCh, and a viewer with deuteranopia separates them by hue alone. A brand hue between the two pulls both inwards, so the gap closes by up to twice the cap; at 22.9° it would reach the 90° floor. 15° leaves the worst case at 105.8°
|
|
714
|
+
- `HUB_MAX_NEUTRAL_CHROMA: number` (0.015) - The most chroma a tinted neutral may carry. Anchored on the ramp the design system already ships — `gray-600` measures 0.0165 and `gray-500` 0.0145 — so a tinted ramp is never more colourful than the grey people already accept as grey
|
|
715
|
+
- `HUB_SEMANTIC_ANCHORS` / `HUB_NEUTRAL_ANCHORS` - The untinted starting points, so a product that harmonises nothing still gets the palette the stylesheet ships
|
|
716
|
+
- Types: `HubSemanticRole`, `HubSemanticPalette`, `HubNeutralStep`, `HubNeutralRamp`, `HubHarmoniseOptions`, `HubTintNeutralsOptions`
|
|
717
|
+
|
|
718
|
+
```typescript
|
|
719
|
+
import { harmoniseSemantics, tintNeutrals } from 'ng-hub-ui-utils';
|
|
720
|
+
|
|
721
|
+
harmoniseSemantics('#6f42c1');
|
|
722
|
+
// { success: '#00866b', warning: '#ffbd6e', danger: '#d8336b', info: '#44c4ff' }
|
|
723
|
+
|
|
724
|
+
tintNeutrals('#6f42c1'); // greys leaning violet, chroma never above 0.015
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
A brand with no hue of its own — a pure grey — leaves both sets untouched: OKLCh's hue on a grey
|
|
728
|
+
is rounding noise, and harmonising towards it would rotate every role in a direction nobody chose.
|
|
729
|
+
|
|
707
730
|
### Focus Functions
|
|
708
731
|
|
|
709
732
|
- `getFocusableBoundaryElements(element: HTMLElement): HTMLElement[]` - Gets first and last focusable elements
|