@ibragim-dev-org/ui-forge-library 1.3.6 → 1.3.8

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.
@@ -786,78 +786,74 @@ function getAspectRatioFit(maxWidth, maxHeight, srcWidth, srcHeight) {
786
786
  return { width: maxWidth, height: maxHeight };
787
787
  }
788
788
 
789
- const stringToHslColor = (value) => {
790
- const MIN_CONTRAST_WITH_WHITE_TEXT = 3;
791
- const hslToRgb = (h, s, l) => {
792
- const sn = s / 100;
793
- const ln = l / 100;
794
- const c = (1 - Math.abs(2 * ln - 1)) * sn;
795
- const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
796
- const m = ln - c / 2;
797
- let r1 = 0, g1 = 0, b1 = 0;
798
- if (h < 60) {
799
- r1 = c;
800
- g1 = x;
801
- }
802
- else if (h < 120) {
803
- r1 = x;
804
- g1 = c;
805
- }
806
- else if (h < 180) {
807
- g1 = c;
808
- b1 = x;
809
- }
810
- else if (h < 240) {
811
- g1 = x;
812
- b1 = c;
813
- }
814
- else if (h < 300) {
815
- r1 = x;
816
- b1 = c;
817
- }
818
- else {
819
- r1 = c;
820
- b1 = x;
821
- }
822
- return [Math.round((r1 + m) * 255), Math.round((g1 + m) * 255), Math.round((b1 + m) * 255)];
823
- };
824
- const linearize = (channel) => {
825
- const normalized = channel / 255;
826
- return normalized <= 0.03928 ? normalized / 12.92 : ((normalized + 0.055) / 1.055) ** 2.4;
827
- };
828
- const contrastWithWhiteText = (h, s, l) => {
829
- const [r, g, b] = hslToRgb(h, s, l);
830
- const luminance = 0.2126 * linearize(r) + 0.7152 * linearize(g) + 0.0722 * linearize(b);
831
- return (1.05 + 0.05) / (luminance + 0.05);
832
- };
833
- // Hash the text → deterministic number
789
+ const COLOR_FAMILIES = [
790
+ // Same style as requested references: vivid top color + deeper companion.
791
+ { solid: '#FF7A7A', gradientStart: '#FF7A7A', gradientEnd: '#D74A59' }, // Red
792
+ { solid: '#FFB357', gradientStart: '#FFB357', gradientEnd: '#F47D3D' }, // Orange
793
+ { solid: '#E6D24A', gradientStart: '#D4C32A', gradientEnd: '#FFAA55' }, // Yellow (exact)
794
+ { solid: '#A8DF4A', gradientStart: '#A8DF4A', gradientEnd: '#72BD45' }, // Lime
795
+ { solid: '#57D88B', gradientStart: '#57D88B', gradientEnd: '#1FA96E' }, // Green
796
+ { solid: '#55DAF5', gradientStart: '#55DAF5', gradientEnd: '#1EA9C8' }, // Light Blue (exact)
797
+ { solid: '#4F9BFF', gradientStart: '#4F9BFF', gradientEnd: '#1D6DD6' }, // Blue (exact)
798
+ { solid: '#7D84FF', gradientStart: '#7D84FF', gradientEnd: '#5A60D9' }, // Indigo
799
+ { solid: '#B979FF', gradientStart: '#B979FF', gradientEnd: '#8D57D6' }, // Violet
800
+ { solid: '#FF86E4', gradientStart: '#FF64DD', gradientEnd: '#F599C4' }, // Pink (exact)
801
+ ];
802
+ const hashValue = (value) => {
834
803
  let hash = 0;
835
804
  for (let i = 0; i < value.length; i++) {
836
805
  hash = value.charCodeAt(i) + ((hash << 5) - hash);
837
- hash &= hash;
838
- }
839
- const absHash = Math.abs(hash);
840
- // Rainbow hue families: Red, Orange, Yellow, Green, Blue, Indigo, Violet
841
- const HUE_RANGES = [
842
- [0, 20], // Red
843
- [25, 40], // Orange
844
- [50, 65], // Yellow
845
- [110, 140], // Green
846
- [200, 230], // Blue
847
- [240, 260], // Indigo
848
- [270, 300], // Violet
806
+ hash |= 0;
807
+ }
808
+ return Math.abs(hash);
809
+ };
810
+ const pickColorFamily = (value) => {
811
+ const absHash = hashValue(value);
812
+ return COLOR_FAMILIES[absHash % COLOR_FAMILIES.length];
813
+ };
814
+ const hexToRgb = (hex) => {
815
+ const value = hex.replace('#', '');
816
+ const normalized = value.length === 3
817
+ ? value
818
+ .split('')
819
+ .map((c) => c + c)
820
+ .join('')
821
+ : value;
822
+ return [
823
+ Number.parseInt(normalized.slice(0, 2), 16),
824
+ Number.parseInt(normalized.slice(2, 4), 16),
825
+ Number.parseInt(normalized.slice(4, 6), 16),
849
826
  ];
850
- const [minHue, maxHue] = HUE_RANGES[absHash % HUE_RANGES.length];
851
- const hueSpan = maxHue - minHue;
852
- const hue = minHue + ((absHash >> 3) % (hueSpan + 1));
853
- // Vivid saturation/lightness
854
- const saturation = 80; // fixed vivid
855
- let lightness = 50; // balanced
856
- // Adjust lightness until white text is readable
857
- while (lightness > 30 && contrastWithWhiteText(hue, saturation, lightness) < MIN_CONTRAST_WITH_WHITE_TEXT) {
858
- lightness -= 2;
859
- }
860
- return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
827
+ };
828
+ const rgbToHex = (r, g, b) => {
829
+ const channelToHex = (channel) => Math.max(0, Math.min(255, Math.round(channel)))
830
+ .toString(16)
831
+ .padStart(2, '0');
832
+ return `#${channelToHex(r)}${channelToHex(g)}${channelToHex(b)}`;
833
+ };
834
+ const mixHex = (first, second, amount) => {
835
+ const ratio = Math.max(0, Math.min(1, amount));
836
+ const [r1, g1, b1] = hexToRgb(first);
837
+ const [r2, g2, b2] = hexToRgb(second);
838
+ return rgbToHex(r1 + (r2 - r1) * ratio, g1 + (g2 - g1) * ratio, b1 + (b2 - b1) * ratio);
839
+ };
840
+ const hexToRgba = (hex, alpha) => {
841
+ const [r, g, b] = hexToRgb(hex);
842
+ const opacity = Math.max(0, Math.min(1, alpha));
843
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`;
844
+ };
845
+ const stringToHslColor = (value) => {
846
+ const family = pickColorFamily(value);
847
+ return family.solid;
848
+ };
849
+ const stringToColorGradient = (value) => {
850
+ const family = pickColorFamily(value);
851
+ const start = family.gradientStart;
852
+ const end = family.gradientEnd;
853
+ const mid = mixHex(start, end, 0.45);
854
+ const glow = mixHex(start, '#FFFFFF', 0.18);
855
+ const shadow = mixHex(end, '#000000', 0.12);
856
+ return `linear-gradient(135deg, ${start} 0%, ${mid} 54%, ${end} 100%), radial-gradient(circle at 78% 82%, ${hexToRgba(shadow, 0.4)} 0%, transparent 58%), radial-gradient(circle at 26% 8%, ${hexToRgba(glow, 0.35)} 0%, transparent 52%)`;
861
857
  };
862
858
 
863
859
  class AppIconsLibrary {
@@ -1338,13 +1334,13 @@ class UiAvatarDirective {
1338
1334
  this.elementRef = elementRef;
1339
1335
  this.renderer = renderer;
1340
1336
  effect(() => {
1341
- let acronym = '';
1342
- this.$acronym()
1343
- .split(' ')
1344
- .forEach((v) => {
1345
- acronym = acronym + v[0];
1346
- });
1347
- this.renderer.setStyle(this.elementRef.nativeElement, 'background-color', stringToHslColor(acronym[0]));
1337
+ const acronym = this.$acronym()
1338
+ .trim()
1339
+ .split(/\s+/)
1340
+ .slice(0, 2)
1341
+ .map((word) => word[0])
1342
+ .join('');
1343
+ this.renderer.setStyle(this.elementRef.nativeElement, 'background', stringToColorGradient(acronym[0]));
1348
1344
  this.$text.set(acronym);
1349
1345
  });
1350
1346
  effect(() => {
@@ -4223,5 +4219,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.1", ngImpor
4223
4219
  * Generated bundle index. Do not edit.
4224
4220
  */
4225
4221
 
4226
- export { Alert, AlertType, AppIconsLibrary, AutoFocusDirective, CalendarUtils, CenterEllipsisPipe, ContainerSizeDirective, CountryService, DateUtils, EMAIL, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, RouterBehavior, SkeletonDirective, StickyObserverDirective, ThemeService, TrackLifecycleDirective, UIInputDateDirective, UIPhoneNumberDirective, UiAccordionComponent, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCalendarDropdownDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiTimeDropdownDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, createNavigation, createUrl, createUrlTree, emptyCountry, extractParam, getAspectRatioFit, navigateByUrl, stringToHslColor };
4222
+ export { Alert, AlertType, AppIconsLibrary, AutoFocusDirective, CalendarUtils, CenterEllipsisPipe, ContainerSizeDirective, CountryService, DateUtils, EMAIL, HAS_CAPITAL_CASE, HAS_NUMBER, HAS_SMALL_CASE, HAS_SPECIAL_CHARTERS, HoverTipDirective, IconComponent, LazyImgDirective, MIN_LENGTH, MaskGradientDirective, RouterBehavior, SkeletonDirective, StickyObserverDirective, ThemeService, TrackLifecycleDirective, UIInputDateDirective, UIPhoneNumberDirective, UiAccordionComponent, UiAlertMessagesService, UiAvatarDirective, UiButtonDirective, UiCalendarDropdownDirective, UiCodeDirective, UiCopyButtonDirective, UiDailyCalendarDirective, UiDropdownContainerDirective, UiDropdownService, UiFieldBaseDirective, UiImageDirective, UiInputCheckboxDirective, UiInputCountryDirective, UiInputDirective, UiInputSelectDirective, UiInputSequenceDirective, UiInputTimeDirective, UiMonthlyCalendarDirective, UiPaginationDirective, UiPopupBackdropDirective, UiPopupContainerDirective, UiPopupImageDirective, UiPopupInstance, UiPopupService, UiSelectButtonsDirective, UiTabsDirective, UiTimeDropdownDirective, UiValidationErrorsDirective, UiYearlyCalendarDirective, createNavigation, createUrl, createUrlTree, emptyCountry, extractParam, getAspectRatioFit, navigateByUrl, stringToColorGradient, stringToHslColor };
4227
4223
  //# sourceMappingURL=ibragim-dev-org-ui-forge-library.mjs.map