@helpwave/hightide 0.0.9 → 0.0.12
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 +1 -1
- package/dist/coloring/shading.d.ts +2 -0
- package/dist/coloring/shading.js +40 -0
- package/dist/coloring/types.d.ts +11 -0
- package/dist/coloring/types.js +1 -0
- package/dist/components/Avatar.d.ts +14 -0
- package/dist/components/Avatar.js +35 -0
- package/dist/components/AvatarGroup.d.ts +10 -0
- package/dist/components/AvatarGroup.js +13 -0
- package/dist/components/BreadCrumb.d.ts +16 -0
- package/dist/components/BreadCrumb.js +12 -0
- package/dist/components/Button.d.ts +41 -0
- package/dist/components/Button.js +84 -0
- package/dist/components/ChipList.d.ts +21 -0
- package/dist/components/ChipList.js +38 -0
- package/dist/components/Circle.d.ts +6 -0
- package/dist/components/Circle.js +10 -0
- package/dist/components/ErrorComponent.d.ts +13 -0
- package/dist/components/ErrorComponent.js +19 -0
- package/dist/components/Expandable.d.ts +30 -0
- package/dist/components/Expandable.js +16 -0
- package/dist/components/HelpwaveBadge.d.ts +11 -0
- package/dist/components/HelpwaveBadge.js +14 -0
- package/dist/components/HideableContentSection.d.ts +10 -0
- package/dist/components/HideableContentSection.js +15 -0
- package/dist/components/InputGroup.d.ts +13 -0
- package/dist/components/InputGroup.js +33 -0
- package/dist/components/LoadingAndErrorComponent.d.ts +17 -0
- package/dist/components/LoadingAndErrorComponent.js +25 -0
- package/dist/components/LoadingAnimation.d.ts +13 -0
- package/dist/components/LoadingAnimation.js +19 -0
- package/dist/components/LoadingButton.d.ts +6 -0
- package/dist/components/LoadingButton.js +10 -0
- package/dist/components/MarkdownInterpreter.d.ts +25 -0
- package/dist/components/MarkdownInterpreter.js +190 -0
- package/dist/components/Pagination.d.ts +14 -0
- package/dist/components/Pagination.js +25 -0
- package/dist/components/Profile.d.ts +28 -0
- package/dist/components/Profile.js +45 -0
- package/dist/components/ProgressIndicator.d.ts +21 -0
- package/dist/components/ProgressIndicator.js +24 -0
- package/dist/components/Ring.d.ts +31 -0
- package/dist/components/Ring.js +113 -0
- package/dist/components/SearchableList.d.ts +18 -0
- package/dist/components/SearchableList.js +27 -0
- package/dist/components/SortButton.d.ts +10 -0
- package/dist/components/SortButton.js +9 -0
- package/dist/components/Span.js +1 -0
- package/dist/components/StepperBar.d.ts +23 -0
- package/dist/components/StepperBar.js +47 -0
- package/dist/components/Table.d.ts +87 -0
- package/dist/components/Table.js +187 -0
- package/dist/components/TechRadar.d.ts +36 -0
- package/dist/components/TechRadar.js +191 -0
- package/dist/components/TextImage.d.ts +20 -0
- package/dist/components/TextImage.js +31 -0
- package/dist/components/TimeDisplay.d.ts +30 -0
- package/dist/components/TimeDisplay.js +83 -0
- package/dist/components/Tooltip.d.ts +34 -0
- package/dist/components/Tooltip.js +38 -0
- package/dist/components/VerticalDivider.d.ts +11 -0
- package/dist/components/VerticalDivider.js +7 -0
- package/dist/components/date/DatePicker.d.ts +26 -0
- package/dist/components/date/DatePicker.js +58 -0
- package/dist/components/date/DayPicker.d.ts +16 -0
- package/dist/components/date/DayPicker.js +37 -0
- package/dist/components/date/TimePicker.d.ts +12 -0
- package/dist/components/date/TimePicker.js +79 -0
- package/dist/components/date/YearMonthPicker.d.ts +11 -0
- package/dist/components/date/YearMonthPicker.js +59 -0
- package/dist/components/examples/InputGroupExample.d.ts +6 -0
- package/dist/components/examples/InputGroupExample.js +21 -0
- package/dist/components/examples/MultiSelectExample.d.ts +7 -0
- package/dist/components/examples/MultiSelectExample.js +27 -0
- package/dist/components/examples/SearchableSelectExample.d.ts +6 -0
- package/dist/components/examples/SearchableSelectExample.js +17 -0
- package/dist/components/examples/SelectExample.d.ts +4 -0
- package/dist/components/examples/SelectExample.js +15 -0
- package/dist/components/examples/StackingModals.d.ts +4 -0
- package/dist/components/examples/StackingModals.js +15 -0
- package/dist/components/examples/TableExample.d.ts +9 -0
- package/dist/components/examples/TableExample.js +92 -0
- package/dist/components/examples/TextareaExample.d.ts +6 -0
- package/dist/components/examples/TextareaExample.js +10 -0
- package/dist/components/examples/TileExample.d.ts +9 -0
- package/dist/components/examples/TileExample.js +9 -0
- package/dist/components/examples/Title.js +1 -0
- package/dist/components/examples/date/DateTimePickerExample.d.ts +10 -0
- package/dist/components/examples/date/DateTimePickerExample.js +21 -0
- package/dist/components/examples/properties/CheckboxPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/CheckboxPropertyExample.js +13 -0
- package/dist/components/examples/properties/DatePropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/DatePropertyExample.js +23 -0
- package/dist/components/examples/properties/MultiSelectPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/MultiSelectPropertyExample.js +16 -0
- package/dist/components/examples/properties/NumberPropertyExample.d.ts +6 -0
- package/dist/components/examples/properties/NumberPropertyExample.js +13 -0
- package/dist/components/examples/properties/SelectPropertyExample.d.ts +6 -0
- package/dist/components/examples/properties/SelectPropertyExample.js +18 -0
- package/dist/components/examples/properties/TextPropertyExample.d.ts +8 -0
- package/dist/components/examples/properties/TextPropertyExample.js +13 -0
- package/dist/components/icons/Helpwave.d.ts +10 -0
- package/dist/components/icons/Helpwave.js +20 -0
- package/dist/components/icons/Tag.d.ts +10 -0
- package/dist/components/icons/Tag.js +12 -0
- package/dist/components/layout/Carousel.d.ts +22 -0
- package/dist/components/layout/Carousel.js +233 -0
- package/dist/components/layout/DividerInserter.d.ts +11 -0
- package/dist/components/layout/DividerInserter.js +20 -0
- package/dist/components/layout/FAQSection.d.ts +23 -0
- package/dist/components/layout/FAQSection.js +14 -0
- package/dist/components/layout/Tile.d.ts +34 -0
- package/dist/components/layout/Tile.js +18 -0
- package/dist/components/modals/ConfirmDialog.d.ts +34 -0
- package/dist/components/modals/ConfirmDialog.js +31 -0
- package/dist/components/modals/DiscardChangesDialog.d.ts +19 -0
- package/dist/components/modals/DiscardChangesDialog.js +24 -0
- package/dist/components/modals/InputModal.d.ts +9 -0
- package/dist/components/modals/InputModal.js +9 -0
- package/dist/components/modals/LanguageModal.d.ts +17 -0
- package/dist/components/modals/LanguageModal.js +35 -0
- package/dist/components/modals/Modal.d.ts +38 -0
- package/dist/components/modals/Modal.js +57 -0
- package/dist/components/modals/ModalRegister.d.ts +11 -0
- package/dist/components/modals/ModalRegister.js +28 -0
- package/dist/components/properties/CheckboxProperty.d.ts +15 -0
- package/dist/components/properties/CheckboxProperty.js +27 -0
- package/dist/components/properties/DateProperty.d.ts +11 -0
- package/dist/components/properties/DateProperty.js +22 -0
- package/dist/components/properties/MultiSelectProperty.d.ts +12 -0
- package/dist/components/properties/MultiSelectProperty.js +33 -0
- package/dist/components/properties/NumberProperty.d.ts +16 -0
- package/dist/components/properties/NumberProperty.js +42 -0
- package/dist/components/properties/PropertyBase.d.ts +23 -0
- package/dist/components/properties/PropertyBase.js +27 -0
- package/dist/components/properties/SelectProperty.d.ts +12 -0
- package/dist/components/properties/SelectProperty.js +22 -0
- package/dist/components/properties/TextProperty.d.ts +15 -0
- package/dist/components/properties/TextProperty.js +37 -0
- package/dist/components/user-input/Checkbox.d.ts +37 -0
- package/dist/components/user-input/Checkbox.js +63 -0
- package/dist/components/user-input/DateAndTimePicker.d.ts +39 -0
- package/dist/components/user-input/DateAndTimePicker.js +65 -0
- package/dist/components/user-input/Input.d.ts +61 -0
- package/dist/components/user-input/Input.js +61 -0
- package/dist/components/user-input/Label.d.ts +12 -0
- package/dist/components/user-input/Label.js +12 -0
- package/dist/components/user-input/Menu.d.ts +21 -0
- package/dist/components/user-input/Menu.js +26 -0
- package/dist/components/user-input/MultiSelect.d.ts +39 -0
- package/dist/components/user-input/MultiSelect.js +57 -0
- package/dist/components/user-input/ScrollPicker.d.ts +11 -0
- package/dist/components/user-input/ScrollPicker.js +151 -0
- package/dist/components/user-input/SearchableSelect.d.ts +8 -0
- package/dist/components/user-input/SearchableSelect.js +14 -0
- package/dist/components/user-input/Select.d.ts +32 -0
- package/dist/components/user-input/Select.js +48 -0
- package/dist/components/user-input/Textarea.d.ts +20 -0
- package/dist/components/user-input/Textarea.js +33 -0
- package/dist/components/user-input/ToggleableInput.d.ts +32 -0
- package/dist/components/user-input/ToggleableInput.js +40 -0
- package/dist/css/globals.css +2450 -0
- package/dist/hooks/useHoverState.d.ts +40 -0
- package/dist/hooks/useHoverState.js +46 -0
- package/dist/hooks/useLanguage.d.ts +17 -0
- package/dist/hooks/useLanguage.js +51 -0
- package/dist/hooks/useLocalStorage.d.ts +4 -0
- package/dist/hooks/useLocalStorage.js +24 -0
- package/dist/hooks/useOutsideClick.d.ts +2 -0
- package/dist/hooks/useOutsideClick.js +22 -0
- package/dist/hooks/useSaveDelay.d.ts +5 -0
- package/dist/hooks/useSaveDelay.js +41 -0
- package/dist/hooks/useTheme.d.ts +16 -0
- package/dist/hooks/useTheme.js +32 -0
- package/dist/hooks/useTranslation.d.ts +24 -0
- package/dist/hooks/useTranslation.js +11 -0
- package/dist/util/array.d.ts +23 -0
- package/dist/util/array.js +103 -0
- package/{util/builder.ts → dist/util/builder.d.ts} +1 -4
- package/dist/util/builder.js +9 -0
- package/dist/util/date.d.ts +28 -0
- package/dist/util/date.js +133 -0
- package/dist/util/easeFunctions.d.ts +9 -0
- package/dist/util/easeFunctions.js +30 -0
- package/dist/util/emailValidation.d.ts +1 -0
- package/dist/util/emailValidation.js +3 -0
- package/dist/util/loopingArray.d.ts +23 -0
- package/dist/util/loopingArray.js +67 -0
- package/dist/util/math.d.ts +1 -0
- package/dist/util/math.js +3 -0
- package/dist/util/news.d.ts +98 -0
- package/dist/util/news.js +27 -0
- package/dist/util/noop.d.ts +1 -0
- package/dist/util/noop.js +1 -0
- package/{util/simpleSearch.ts → dist/util/simpleSearch.d.ts} +4 -21
- package/dist/util/simpleSearch.js +62 -0
- package/dist/util/storage.d.ts +15 -0
- package/dist/util/storage.js +32 -0
- package/dist/util/types.d.ts +1 -0
- package/dist/util/types.js +1 -0
- package/package.json +7 -8
- package/coloring/shading.ts +0 -46
- package/coloring/types.ts +0 -13
- package/components/Avatar.tsx +0 -58
- package/components/AvatarGroup.tsx +0 -48
- package/components/BreadCrumb.tsx +0 -35
- package/components/Button.tsx +0 -236
- package/components/ChipList.tsx +0 -89
- package/components/Circle.tsx +0 -27
- package/components/ErrorComponent.tsx +0 -40
- package/components/Expandable.tsx +0 -61
- package/components/HelpwaveBadge.tsx +0 -35
- package/components/HideableContentSection.tsx +0 -43
- package/components/InputGroup.tsx +0 -72
- package/components/LoadingAndErrorComponent.tsx +0 -47
- package/components/LoadingAnimation.tsx +0 -40
- package/components/LoadingButton.tsx +0 -27
- package/components/MarkdownInterpreter.tsx +0 -278
- package/components/Pagination.tsx +0 -65
- package/components/Profile.tsx +0 -124
- package/components/ProgressIndicator.tsx +0 -58
- package/components/Ring.tsx +0 -286
- package/components/SearchableList.tsx +0 -69
- package/components/SortButton.tsx +0 -33
- package/components/StepperBar.tsx +0 -124
- package/components/Table.tsx +0 -330
- package/components/TechRadar.tsx +0 -247
- package/components/TextImage.tsx +0 -86
- package/components/TimeDisplay.tsx +0 -121
- package/components/Tooltip.tsx +0 -92
- package/components/VerticalDivider.tsx +0 -51
- package/components/date/DatePicker.tsx +0 -164
- package/components/date/DayPicker.tsx +0 -95
- package/components/date/TimePicker.tsx +0 -167
- package/components/date/YearMonthPicker.tsx +0 -130
- package/components/examples/InputGroupExample.tsx +0 -58
- package/components/examples/MultiSelectExample.tsx +0 -57
- package/components/examples/SearchableSelectExample.tsx +0 -34
- package/components/examples/SelectExample.tsx +0 -28
- package/components/examples/StackingModals.tsx +0 -54
- package/components/examples/TableExample.tsx +0 -159
- package/components/examples/TextareaExample.tsx +0 -23
- package/components/examples/TileExample.tsx +0 -25
- package/components/examples/date/DateTimePickerExample.tsx +0 -53
- package/components/examples/properties/CheckboxPropertyExample.tsx +0 -29
- package/components/examples/properties/DatePropertyExample.tsx +0 -44
- package/components/examples/properties/MultiSelectPropertyExample.tsx +0 -39
- package/components/examples/properties/NumberPropertyExample.tsx +0 -28
- package/components/examples/properties/SelectPropertyExample.tsx +0 -39
- package/components/examples/properties/TextPropertyExample.tsx +0 -30
- package/components/icons/Helpwave.tsx +0 -51
- package/components/icons/Tag.tsx +0 -29
- package/components/layout/Carousel.tsx +0 -396
- package/components/layout/DividerInserter.tsx +0 -37
- package/components/layout/FAQSection.tsx +0 -57
- package/components/layout/Tile.tsx +0 -67
- package/components/modals/ConfirmDialog.tsx +0 -105
- package/components/modals/DiscardChangesDialog.tsx +0 -71
- package/components/modals/InputModal.tsx +0 -26
- package/components/modals/LanguageModal.tsx +0 -76
- package/components/modals/Modal.tsx +0 -149
- package/components/modals/ModalRegister.tsx +0 -45
- package/components/properties/CheckboxProperty.tsx +0 -62
- package/components/properties/DateProperty.tsx +0 -58
- package/components/properties/MultiSelectProperty.tsx +0 -82
- package/components/properties/NumberProperty.tsx +0 -86
- package/components/properties/PropertyBase.tsx +0 -84
- package/components/properties/SelectProperty.tsx +0 -67
- package/components/properties/TextProperty.tsx +0 -81
- package/components/user-input/Checkbox.tsx +0 -139
- package/components/user-input/DateAndTimePicker.tsx +0 -156
- package/components/user-input/Input.tsx +0 -192
- package/components/user-input/Label.tsx +0 -32
- package/components/user-input/Menu.tsx +0 -75
- package/components/user-input/MultiSelect.tsx +0 -158
- package/components/user-input/ScrollPicker.tsx +0 -240
- package/components/user-input/SearchableSelect.tsx +0 -36
- package/components/user-input/Select.tsx +0 -132
- package/components/user-input/Textarea.tsx +0 -86
- package/components/user-input/ToggleableInput.tsx +0 -115
- package/globals.css +0 -488
- package/hooks/useHoverState.ts +0 -88
- package/hooks/useLanguage.tsx +0 -78
- package/hooks/useLocalStorage.tsx +0 -33
- package/hooks/useOutsideClick.ts +0 -25
- package/hooks/useSaveDelay.ts +0 -46
- package/hooks/useTheme.tsx +0 -57
- package/hooks/useTranslation.ts +0 -43
- package/index.ts +0 -0
- package/util/array.ts +0 -115
- package/util/date.ts +0 -180
- package/util/easeFunctions.ts +0 -37
- package/util/emailValidation.ts +0 -3
- package/util/loopingArray.ts +0 -94
- package/util/math.ts +0 -3
- package/util/news.ts +0 -43
- package/util/noop.ts +0 -1
- package/util/storage.ts +0 -37
- package/util/types.ts +0 -4
- /package/{components/Span.tsx → dist/components/Span.d.ts} +0 -0
- /package/{components/examples/Title.tsx → dist/components/examples/Title.d.ts} +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type EaseFunction = (t: number) => number;
|
|
2
|
+
export declare class EaseFunctions {
|
|
3
|
+
static cubicBezierGeneric(x1: number, y1: number, x2: number, y2: number): {
|
|
4
|
+
x: EaseFunction;
|
|
5
|
+
y: EaseFunction;
|
|
6
|
+
};
|
|
7
|
+
static cubicBezier(x1: number, y1: number, x2: number, y2: number): EaseFunction;
|
|
8
|
+
static easeInEaseOut(t: number): number;
|
|
9
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { clamp } from './math';
|
|
2
|
+
export class EaseFunctions {
|
|
3
|
+
static cubicBezierGeneric(x1, y1, x2, y2) {
|
|
4
|
+
// Calculate the x and y coordinates using the cubic Bézier formula
|
|
5
|
+
const cx = 3 * x1;
|
|
6
|
+
const bx = 3 * (x2 - x1) - cx;
|
|
7
|
+
const ax = 1 - cx - bx;
|
|
8
|
+
const cy = 3 * y1;
|
|
9
|
+
const by = 3 * (y2 - y1) - cy;
|
|
10
|
+
const ay = 1 - cy - by;
|
|
11
|
+
// Compute x and y values at parameter t
|
|
12
|
+
const x = (t) => ((ax * t + bx) * t + cx) * t;
|
|
13
|
+
const y = (t) => ((ay * t + by) * t + cy) * t;
|
|
14
|
+
return {
|
|
15
|
+
x,
|
|
16
|
+
y
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
static cubicBezier(x1, y1, x2, y2) {
|
|
20
|
+
const { y } = EaseFunctions.cubicBezierGeneric(x1, y1, x2, y2);
|
|
21
|
+
return (t) => {
|
|
22
|
+
t = clamp(t);
|
|
23
|
+
return y(t); // <= equal to x(t) * 0 + y(t) * 1
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
static easeInEaseOut(t) {
|
|
27
|
+
return EaseFunctions.cubicBezier(0.65, 0, 0.35, 1)(t);
|
|
28
|
+
}
|
|
29
|
+
;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const validateEmail: (email: string) => boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 1 is forwards
|
|
3
|
+
*
|
|
4
|
+
* -1 is backwards
|
|
5
|
+
*/
|
|
6
|
+
export type Direction = 1 | -1;
|
|
7
|
+
export declare class LoopingArrayCalculator {
|
|
8
|
+
length: number;
|
|
9
|
+
isLooping: boolean;
|
|
10
|
+
allowedOverScroll: number;
|
|
11
|
+
constructor(length: number, isLooping?: boolean, allowedOverScroll?: number);
|
|
12
|
+
getCorrectedPosition(position: number): number;
|
|
13
|
+
static withoutOffset(position: number): number;
|
|
14
|
+
static getOffset(position: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* @return absolute distance forwards or Infinity when the target cannot be reached (only possible when not isLooping)
|
|
17
|
+
*/
|
|
18
|
+
getDistanceDirectional(position: number, target: number, direction: Direction): number;
|
|
19
|
+
getDistanceForward(position: number, target: number): number;
|
|
20
|
+
getDistanceBackward(position: number, target: number): number;
|
|
21
|
+
getDistance(position: number, target: number): number;
|
|
22
|
+
getBestDirection(position: number, target: number): Direction;
|
|
23
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export class LoopingArrayCalculator {
|
|
2
|
+
constructor(length, isLooping = true, allowedOverScroll = 0.1) {
|
|
3
|
+
if (allowedOverScroll < 0 || length < 1) {
|
|
4
|
+
throw new Error('Invalid parameters: allowedOverScroll >= 0 and length >= 1 must be true');
|
|
5
|
+
}
|
|
6
|
+
this.length = length;
|
|
7
|
+
this.isLooping = isLooping;
|
|
8
|
+
this.allowedOverScroll = allowedOverScroll;
|
|
9
|
+
}
|
|
10
|
+
getCorrectedPosition(position) {
|
|
11
|
+
if (!this.isLooping) {
|
|
12
|
+
return Math.max(-this.allowedOverScroll, Math.min(this.allowedOverScroll + this.length - 1, position));
|
|
13
|
+
}
|
|
14
|
+
if (position >= this.length) {
|
|
15
|
+
return position % this.length;
|
|
16
|
+
}
|
|
17
|
+
if (position < 0) {
|
|
18
|
+
return this.length - (Math.abs(position) % this.length);
|
|
19
|
+
}
|
|
20
|
+
return position;
|
|
21
|
+
}
|
|
22
|
+
static withoutOffset(position) {
|
|
23
|
+
return position + LoopingArrayCalculator.getOffset(position);
|
|
24
|
+
}
|
|
25
|
+
static getOffset(position) {
|
|
26
|
+
return Math.round(position) - position; // For example: 45.5 => 46 - 45.5 = 0.5
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* @return absolute distance forwards or Infinity when the target cannot be reached (only possible when not isLooping)
|
|
30
|
+
*/
|
|
31
|
+
getDistanceDirectional(position, target, direction) {
|
|
32
|
+
if (!this.isLooping && (position < -this.allowedOverScroll || position > this.allowedOverScroll + this.length - 1)) {
|
|
33
|
+
throw new Error('Invalid parameters: position is out of bounds.');
|
|
34
|
+
}
|
|
35
|
+
const isForwardInvalid = (direction === 1 && position > target);
|
|
36
|
+
const isBackwardInvalid = (direction === -1 && target < position);
|
|
37
|
+
if (!this.isLooping && (isForwardInvalid || isBackwardInvalid)) {
|
|
38
|
+
return Infinity;
|
|
39
|
+
}
|
|
40
|
+
if (direction === -1) {
|
|
41
|
+
return this.getDistanceDirectional(target, position, 1);
|
|
42
|
+
}
|
|
43
|
+
position = this.getCorrectedPosition(position);
|
|
44
|
+
target = this.getCorrectedPosition(target);
|
|
45
|
+
let distance = (target - position) * direction;
|
|
46
|
+
if (distance < 0) {
|
|
47
|
+
distance = this.length - (Math.abs(position) % this.length) + target;
|
|
48
|
+
}
|
|
49
|
+
return distance;
|
|
50
|
+
}
|
|
51
|
+
getDistanceForward(position, target) {
|
|
52
|
+
return this.getDistanceDirectional(position, target, 1);
|
|
53
|
+
}
|
|
54
|
+
getDistanceBackward(position, target) {
|
|
55
|
+
return this.getDistanceDirectional(position, target, -1);
|
|
56
|
+
}
|
|
57
|
+
getDistance(position, target) {
|
|
58
|
+
const forwardDistance = this.getDistanceForward(position, target);
|
|
59
|
+
const backwardDistance = this.getDistanceBackward(position, target);
|
|
60
|
+
return Math.min(forwardDistance, backwardDistance);
|
|
61
|
+
}
|
|
62
|
+
getBestDirection(position, target) {
|
|
63
|
+
const forwardDistance = this.getDistanceForward(position, target);
|
|
64
|
+
const backwardDistance = this.getDistanceBackward(position, target);
|
|
65
|
+
return forwardDistance < backwardDistance ? 1 : -1;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const clamp: (value: number, min?: number, max?: number) => number;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { Languages } from '../hooks/useLanguage';
|
|
3
|
+
export type News = {
|
|
4
|
+
title: string;
|
|
5
|
+
date: Date;
|
|
6
|
+
description: (string | URL)[];
|
|
7
|
+
externalResource?: URL;
|
|
8
|
+
keys: string[];
|
|
9
|
+
};
|
|
10
|
+
export type LocalizedNews = Record<Languages, News[]>;
|
|
11
|
+
export declare const newsSchema: z.ZodEffects<z.ZodObject<{
|
|
12
|
+
title: z.ZodString;
|
|
13
|
+
description: z.ZodString;
|
|
14
|
+
date: z.ZodString;
|
|
15
|
+
image: z.ZodOptional<z.ZodString>;
|
|
16
|
+
externalResource: z.ZodOptional<z.ZodString>;
|
|
17
|
+
keys: z.ZodArray<z.ZodString, "many">;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
title: string;
|
|
20
|
+
date: string;
|
|
21
|
+
description: string;
|
|
22
|
+
keys: string[];
|
|
23
|
+
image?: string | undefined;
|
|
24
|
+
externalResource?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
title: string;
|
|
27
|
+
date: string;
|
|
28
|
+
description: string;
|
|
29
|
+
keys: string[];
|
|
30
|
+
image?: string | undefined;
|
|
31
|
+
externalResource?: string | undefined;
|
|
32
|
+
}>, News, {
|
|
33
|
+
title: string;
|
|
34
|
+
date: string;
|
|
35
|
+
description: string;
|
|
36
|
+
keys: string[];
|
|
37
|
+
image?: string | undefined;
|
|
38
|
+
externalResource?: string | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
export declare const newsListSchema: z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
41
|
+
title: z.ZodString;
|
|
42
|
+
description: z.ZodString;
|
|
43
|
+
date: z.ZodString;
|
|
44
|
+
image: z.ZodOptional<z.ZodString>;
|
|
45
|
+
externalResource: z.ZodOptional<z.ZodString>;
|
|
46
|
+
keys: z.ZodArray<z.ZodString, "many">;
|
|
47
|
+
}, "strip", z.ZodTypeAny, {
|
|
48
|
+
title: string;
|
|
49
|
+
date: string;
|
|
50
|
+
description: string;
|
|
51
|
+
keys: string[];
|
|
52
|
+
image?: string | undefined;
|
|
53
|
+
externalResource?: string | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
title: string;
|
|
56
|
+
date: string;
|
|
57
|
+
description: string;
|
|
58
|
+
keys: string[];
|
|
59
|
+
image?: string | undefined;
|
|
60
|
+
externalResource?: string | undefined;
|
|
61
|
+
}>, News, {
|
|
62
|
+
title: string;
|
|
63
|
+
date: string;
|
|
64
|
+
description: string;
|
|
65
|
+
keys: string[];
|
|
66
|
+
image?: string | undefined;
|
|
67
|
+
externalResource?: string | undefined;
|
|
68
|
+
}>, "many">;
|
|
69
|
+
export declare const localizedNewsSchema: z.ZodRecord<z.ZodEnum<["en", "de"]>, z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
70
|
+
title: z.ZodString;
|
|
71
|
+
description: z.ZodString;
|
|
72
|
+
date: z.ZodString;
|
|
73
|
+
image: z.ZodOptional<z.ZodString>;
|
|
74
|
+
externalResource: z.ZodOptional<z.ZodString>;
|
|
75
|
+
keys: z.ZodArray<z.ZodString, "many">;
|
|
76
|
+
}, "strip", z.ZodTypeAny, {
|
|
77
|
+
title: string;
|
|
78
|
+
date: string;
|
|
79
|
+
description: string;
|
|
80
|
+
keys: string[];
|
|
81
|
+
image?: string | undefined;
|
|
82
|
+
externalResource?: string | undefined;
|
|
83
|
+
}, {
|
|
84
|
+
title: string;
|
|
85
|
+
date: string;
|
|
86
|
+
description: string;
|
|
87
|
+
keys: string[];
|
|
88
|
+
image?: string | undefined;
|
|
89
|
+
externalResource?: string | undefined;
|
|
90
|
+
}>, News, {
|
|
91
|
+
title: string;
|
|
92
|
+
date: string;
|
|
93
|
+
description: string;
|
|
94
|
+
keys: string[];
|
|
95
|
+
image?: string | undefined;
|
|
96
|
+
externalResource?: string | undefined;
|
|
97
|
+
}>, "many">>;
|
|
98
|
+
export declare const filterNews: (localizedNews: News[], requiredKeys: string[]) => News[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { languages } from '../hooks/useLanguage';
|
|
3
|
+
export const newsSchema = z.object({
|
|
4
|
+
title: z.string(),
|
|
5
|
+
description: z.string(),
|
|
6
|
+
date: z.string(),
|
|
7
|
+
image: z.string().url().optional(),
|
|
8
|
+
externalResource: z.string().url().optional(),
|
|
9
|
+
keys: z.array(z.string())
|
|
10
|
+
}).transform((obj) => {
|
|
11
|
+
let description = [obj.description];
|
|
12
|
+
if (obj.image) {
|
|
13
|
+
description = [new URL(obj.image), ...description];
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
title: obj.title,
|
|
17
|
+
date: new Date(obj.date),
|
|
18
|
+
description,
|
|
19
|
+
externalResource: obj.externalResource ? new URL(obj.externalResource) : undefined,
|
|
20
|
+
keys: obj.keys
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
export const newsListSchema = z.array(newsSchema);
|
|
24
|
+
export const localizedNewsSchema = z.record(z.enum(languages), newsListSchema);
|
|
25
|
+
export const filterNews = (localizedNews, requiredKeys) => {
|
|
26
|
+
return localizedNews.filter(news => requiredKeys.every(value => news.keys.includes(value)));
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const noop: () => undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const noop = () => undefined;
|
|
@@ -10,13 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @return The list of objects that match all search strings
|
|
12
12
|
*/
|
|
13
|
-
export const MultiSubjectSearchWithMapping
|
|
14
|
-
return objects.filter(object => {
|
|
15
|
-
const mappedSearchKeywords = mapping(object).map(value => value ? value.toLowerCase().trim() : undefined)
|
|
16
|
-
return search.every(searchValue => !!mappedSearchKeywords.find(value => !!value && value.includes(searchValue.toLowerCase().trim())))
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
|
|
13
|
+
export declare const MultiSubjectSearchWithMapping: <T>(search: string[], objects: T[], mapping: (value: T) => (string | undefined)[]) => T[];
|
|
20
14
|
/**
|
|
21
15
|
* Finds all values matching the search value by first mapping the values to a string array and then checking each entry for matches.
|
|
22
16
|
* Returns the list of all matches.
|
|
@@ -29,13 +23,7 @@ export const MultiSubjectSearchWithMapping = <T>(search: string[], objects: T[],
|
|
|
29
23
|
*
|
|
30
24
|
* @return The list of objects that match the search string
|
|
31
25
|
*/
|
|
32
|
-
export const MultiSearchWithMapping
|
|
33
|
-
return objects.filter(object => {
|
|
34
|
-
const mappedSearchKeywords = mapping(object).map(value => value.toLowerCase().trim())
|
|
35
|
-
return !!mappedSearchKeywords.find(value => value.includes(search.toLowerCase().trim()))
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
26
|
+
export declare const MultiSearchWithMapping: <T>(search: string, objects: T[], mapping: (value: T) => string[]) => T[];
|
|
39
27
|
/**
|
|
40
28
|
* Finds all values matching the search value by first mapping the values to a string and returns the list of all matches.
|
|
41
29
|
*
|
|
@@ -47,10 +35,7 @@ export const MultiSearchWithMapping = <T>(search: string, objects: T[], mapping:
|
|
|
47
35
|
*
|
|
48
36
|
* @return The list of objects that match the search string
|
|
49
37
|
*/
|
|
50
|
-
export const SimpleSearchWithMapping
|
|
51
|
-
return MultiSearchWithMapping(search, objects, value => [mapping(value)])
|
|
52
|
-
}
|
|
53
|
-
|
|
38
|
+
export declare const SimpleSearchWithMapping: <T>(search: string, objects: T[], mapping: (value: T) => string) => T[];
|
|
54
39
|
/**
|
|
55
40
|
* Finds all values matching the search value and returns the list of all matches.
|
|
56
41
|
*
|
|
@@ -60,6 +45,4 @@ export const SimpleSearchWithMapping = <T>(search: string, objects: T[], mapping
|
|
|
60
45
|
*
|
|
61
46
|
* @return The list of objects that match the search string
|
|
62
47
|
*/
|
|
63
|
-
export const SimpleSearch
|
|
64
|
-
return SimpleSearchWithMapping(search, objects, value => value)
|
|
65
|
-
}
|
|
48
|
+
export declare const SimpleSearch: (search: string, objects: string[]) => string[];
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds all values matching the search values by first mapping the values to a string array and then checking each entry for matches.
|
|
3
|
+
* Returns the list of all matches.
|
|
4
|
+
*
|
|
5
|
+
* @param search The list of search strings e.g. `[name, type]`
|
|
6
|
+
*
|
|
7
|
+
* @param objects The list of objects to be searched in
|
|
8
|
+
*
|
|
9
|
+
* @param mapping The mapping of objects to the string properties they fulfil
|
|
10
|
+
*
|
|
11
|
+
* @return The list of objects that match all search strings
|
|
12
|
+
*/
|
|
13
|
+
export const MultiSubjectSearchWithMapping = (search, objects, mapping) => {
|
|
14
|
+
return objects.filter(object => {
|
|
15
|
+
const mappedSearchKeywords = mapping(object).map(value => value ? value.toLowerCase().trim() : undefined);
|
|
16
|
+
return search.every(searchValue => !!mappedSearchKeywords.find(value => !!value && value.includes(searchValue.toLowerCase().trim())));
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Finds all values matching the search value by first mapping the values to a string array and then checking each entry for matches.
|
|
21
|
+
* Returns the list of all matches.
|
|
22
|
+
*
|
|
23
|
+
* @param search The search string e.g `name`
|
|
24
|
+
*
|
|
25
|
+
* @param objects The list of objects to be searched in
|
|
26
|
+
*
|
|
27
|
+
* @param mapping The mapping of objects to the string properties they fulfil
|
|
28
|
+
*
|
|
29
|
+
* @return The list of objects that match the search string
|
|
30
|
+
*/
|
|
31
|
+
export const MultiSearchWithMapping = (search, objects, mapping) => {
|
|
32
|
+
return objects.filter(object => {
|
|
33
|
+
const mappedSearchKeywords = mapping(object).map(value => value.toLowerCase().trim());
|
|
34
|
+
return !!mappedSearchKeywords.find(value => value.includes(search.toLowerCase().trim()));
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Finds all values matching the search value by first mapping the values to a string and returns the list of all matches.
|
|
39
|
+
*
|
|
40
|
+
* @param search The search string e.g `name`
|
|
41
|
+
*
|
|
42
|
+
* @param objects The list of objects to be searched in
|
|
43
|
+
*
|
|
44
|
+
* @param mapping The mapping of objects to a string that is compared to the search
|
|
45
|
+
*
|
|
46
|
+
* @return The list of objects that match the search string
|
|
47
|
+
*/
|
|
48
|
+
export const SimpleSearchWithMapping = (search, objects, mapping) => {
|
|
49
|
+
return MultiSearchWithMapping(search, objects, value => [mapping(value)]);
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Finds all values matching the search value and returns the list of all matches.
|
|
53
|
+
*
|
|
54
|
+
* @param search The search string e.g `name`
|
|
55
|
+
*
|
|
56
|
+
* @param objects The list of objects to be searched in
|
|
57
|
+
*
|
|
58
|
+
* @return The list of objects that match the search string
|
|
59
|
+
*/
|
|
60
|
+
export const SimpleSearch = (search, objects) => {
|
|
61
|
+
return SimpleSearchWithMapping(search, objects, value => value);
|
|
62
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare class StorageService {
|
|
2
|
+
private storage;
|
|
3
|
+
constructor(storage: Storage);
|
|
4
|
+
get<T>(key: string): T | null;
|
|
5
|
+
set<T>(key: string, value: T): void;
|
|
6
|
+
delete(key: string): void;
|
|
7
|
+
deleteAll(): void;
|
|
8
|
+
}
|
|
9
|
+
export declare class LocalStorageService extends StorageService {
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
12
|
+
export declare class SessionStorageService extends StorageService {
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
class StorageService {
|
|
2
|
+
// this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript
|
|
3
|
+
constructor(storage) {
|
|
4
|
+
this.storage = storage;
|
|
5
|
+
}
|
|
6
|
+
get(key) {
|
|
7
|
+
const value = this.storage.getItem(key);
|
|
8
|
+
if (value === null) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return JSON.parse(value);
|
|
12
|
+
}
|
|
13
|
+
set(key, value) {
|
|
14
|
+
this.storage.setItem(key, JSON.stringify(value));
|
|
15
|
+
}
|
|
16
|
+
delete(key) {
|
|
17
|
+
this.storage.removeItem(key);
|
|
18
|
+
}
|
|
19
|
+
deleteAll() {
|
|
20
|
+
this.storage.clear();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class LocalStorageService extends StorageService {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(window.localStorage);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export class SessionStorageService extends StorageService {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(window.sessionStorage);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type NativeProps<NativeElement extends keyof React.ReactHTML, OmittedKeys extends string | number | symbol | undefined = undefined> = Omit<React.JSX.IntrinsicElements[NativeElement], OmittedKeys extends undefined ? 'ref' : 'ref' | OmittedKeys>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -7,25 +7,24 @@
|
|
|
7
7
|
"url": "git+https://github.com/helpwave/hightide.git"
|
|
8
8
|
},
|
|
9
9
|
"license": "MPL-2.0",
|
|
10
|
-
"version": "0.0.
|
|
11
|
-
"main": "index.
|
|
10
|
+
"version": "0.0.12",
|
|
11
|
+
"main": "index.js",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"scripts": {
|
|
14
|
+
"clean": "rm -rf dist",
|
|
15
|
+
"build-css": "npx @tailwindcss/cli -i ./src/css/globals.css -o ./dist/css/globals.css",
|
|
16
|
+
"build": "npm run clean && tsc && npm run build-css",
|
|
14
17
|
"storybook": "storybook dev -p 6006",
|
|
15
18
|
"build-storybook": "storybook build",
|
|
16
19
|
"lint": "tsc --noEmit && eslint ."
|
|
17
20
|
},
|
|
18
21
|
"files": [
|
|
19
|
-
"
|
|
20
|
-
"globals.css",
|
|
21
|
-
"coloring/",
|
|
22
|
-
"components/",
|
|
23
|
-
"hooks/",
|
|
24
|
-
"util/"
|
|
22
|
+
"dist"
|
|
25
23
|
],
|
|
26
24
|
"dependencies": {
|
|
27
25
|
"@headlessui/react": "1.7.19",
|
|
28
26
|
"@radix-ui/react-checkbox": "1.1.3",
|
|
27
|
+
"@tailwindcss/cli": "^4.1.7",
|
|
29
28
|
"clsx": "^2.1.1",
|
|
30
29
|
"lucide-react": "0.468.0",
|
|
31
30
|
"prop-types": "15.8.1",
|
package/coloring/shading.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import tinycolor from 'tinycolor2'
|
|
2
|
-
import type { ShadedColors } from './types'
|
|
3
|
-
import { shadingColorValues } from './types'
|
|
4
|
-
|
|
5
|
-
// Function to generate a full shading of several colors
|
|
6
|
-
export const generateShadingColors = (partialShading: Omit<Partial<ShadedColors>, '0' | '1000'>): ShadedColors => {
|
|
7
|
-
const shading: ShadedColors = {
|
|
8
|
-
0: '#FFFFFF',
|
|
9
|
-
1000: '#000000'
|
|
10
|
-
} as ShadedColors
|
|
11
|
-
|
|
12
|
-
let index = 1
|
|
13
|
-
while (index < shadingColorValues.length - 1) {
|
|
14
|
-
const previous = shadingColorValues[index - 1]!
|
|
15
|
-
const current = shadingColorValues[index]!
|
|
16
|
-
|
|
17
|
-
if (partialShading[current] !== undefined) {
|
|
18
|
-
shading[current] = partialShading[current]
|
|
19
|
-
index++
|
|
20
|
-
continue
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let j: number = index + 1
|
|
24
|
-
while (j < shadingColorValues.length) {
|
|
25
|
-
if (partialShading[shadingColorValues[j]!] !== undefined) {
|
|
26
|
-
break
|
|
27
|
-
}
|
|
28
|
-
j++
|
|
29
|
-
}
|
|
30
|
-
if (j === shadingColorValues.length) {
|
|
31
|
-
j = shadingColorValues.length - 1
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const nextFound = shadingColorValues[j]!
|
|
35
|
-
const interval = nextFound - previous
|
|
36
|
-
for (let k = index; k < j; k++) {
|
|
37
|
-
const current = shadingColorValues[k]!
|
|
38
|
-
const previousValue = partialShading[previous] ?? shading[previous]
|
|
39
|
-
const nextValue = partialShading[nextFound] ?? shading[nextFound]
|
|
40
|
-
shading[current] = tinycolor.mix(tinycolor(previousValue), tinycolor(nextValue), (current - previous) / interval * 100).toHexString()
|
|
41
|
-
}
|
|
42
|
-
index = j
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return shading
|
|
46
|
-
}
|
package/coloring/types.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export const shadingColorValues = [0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000] as const
|
|
2
|
-
export type ColorShadingValue = typeof shadingColorValues[number]
|
|
3
|
-
export type ShadedColors = Record<ColorShadingValue, string>
|
|
4
|
-
|
|
5
|
-
export type ColoringStyle = 'background' | 'tonal' | 'tonal-opaque' | 'text' | 'text-border'
|
|
6
|
-
export type ColorMode = 'light' | 'dark'
|
|
7
|
-
|
|
8
|
-
export type Coloring = {
|
|
9
|
-
color: '',
|
|
10
|
-
style?: ColoringStyle,
|
|
11
|
-
mode?: ColorMode,
|
|
12
|
-
hover?: boolean,
|
|
13
|
-
}
|
package/components/Avatar.tsx
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import Image from 'next/image'
|
|
2
|
-
import clsx from 'clsx'
|
|
3
|
-
|
|
4
|
-
export const avtarSizeList = ['tiny', 'small', 'medium', 'large'] as const
|
|
5
|
-
export type AvatarSize = typeof avtarSizeList[number]
|
|
6
|
-
export const avatarSizeMapping: Record<AvatarSize, number> = {
|
|
7
|
-
tiny: 24,
|
|
8
|
-
small: 32,
|
|
9
|
-
medium: 48,
|
|
10
|
-
large: 64
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type AvatarProps = {
|
|
14
|
-
avatarUrl: string,
|
|
15
|
-
alt: string,
|
|
16
|
-
size?: AvatarSize,
|
|
17
|
-
className?: string,
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* A component for showing a profile picture
|
|
22
|
-
*/
|
|
23
|
-
const Avatar = ({ avatarUrl, alt, size = 'medium', className = '' }: AvatarProps) => {
|
|
24
|
-
// TODO remove later
|
|
25
|
-
avatarUrl = 'https://cdn.helpwave.de/boringavatar.svg'
|
|
26
|
-
|
|
27
|
-
const avtarSize = {
|
|
28
|
-
tiny: 24,
|
|
29
|
-
small: 32,
|
|
30
|
-
medium: 48,
|
|
31
|
-
large: 64,
|
|
32
|
-
}[size]
|
|
33
|
-
|
|
34
|
-
const style = {
|
|
35
|
-
width: avtarSize + 'px',
|
|
36
|
-
height: avtarSize + 'px',
|
|
37
|
-
maxWidth: avtarSize + 'px',
|
|
38
|
-
maxHeight: avtarSize + 'px',
|
|
39
|
-
minWidth: avtarSize + 'px',
|
|
40
|
-
minHeight: avtarSize + 'px',
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
// TODO transparent or white background later
|
|
45
|
-
<div className={clsx(`rounded-full bg-primary`, className)} style={style}>
|
|
46
|
-
<Image
|
|
47
|
-
className="rounded-full border border-gray-200"
|
|
48
|
-
style={style}
|
|
49
|
-
src={avatarUrl}
|
|
50
|
-
alt={alt}
|
|
51
|
-
width={avtarSize}
|
|
52
|
-
height={avtarSize}
|
|
53
|
-
/>
|
|
54
|
-
</div>
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export { Avatar }
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { AvatarProps, AvatarSize } from './Avatar'
|
|
2
|
-
import { Avatar, avatarSizeMapping } from './Avatar'
|
|
3
|
-
|
|
4
|
-
export type AvatarGroupProps = {
|
|
5
|
-
avatars: Omit<AvatarProps, 'size'>[],
|
|
6
|
-
maxShownProfiles?: number,
|
|
7
|
-
size?: AvatarSize,
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A component for showing a group of Avatar's
|
|
12
|
-
*/
|
|
13
|
-
export const AvatarGroup = ({
|
|
14
|
-
avatars,
|
|
15
|
-
maxShownProfiles = 5,
|
|
16
|
-
size = 'tiny'
|
|
17
|
-
}: AvatarGroupProps) => {
|
|
18
|
-
const displayedProfiles = avatars.length < maxShownProfiles ? avatars : avatars.slice(0, maxShownProfiles)
|
|
19
|
-
const diameter = avatarSizeMapping[size]
|
|
20
|
-
const stackingOverlap = 0.5 // given as a percentage
|
|
21
|
-
const notDisplayedProfiles = avatars.length - maxShownProfiles
|
|
22
|
-
const avatarGroupWidth = diameter * (stackingOverlap * (displayedProfiles.length - 1) + 1)
|
|
23
|
-
return (
|
|
24
|
-
<div className="row relative" style={{ height: diameter + 'px' }}>
|
|
25
|
-
<div style={{ width: avatarGroupWidth + 'px' }}>
|
|
26
|
-
{displayedProfiles.map((avatar, index) => (
|
|
27
|
-
<div
|
|
28
|
-
key={index}
|
|
29
|
-
className="absolute"
|
|
30
|
-
style={{ left: (index * diameter * stackingOverlap) + 'px', zIndex: maxShownProfiles - index }}
|
|
31
|
-
>
|
|
32
|
-
<Avatar avatarUrl={avatar.avatarUrl} alt={avatar.alt} size={size}/>
|
|
33
|
-
</div>
|
|
34
|
-
))}
|
|
35
|
-
</div>
|
|
36
|
-
{
|
|
37
|
-
notDisplayedProfiles > 0 && (
|
|
38
|
-
<div
|
|
39
|
-
className="truncate row items-center"
|
|
40
|
-
style={{ fontSize: (diameter / 2) + 'px', marginLeft: (1 + diameter / 16) + 'px' }}
|
|
41
|
-
>
|
|
42
|
-
<span>+ {notDisplayedProfiles}</span>
|
|
43
|
-
</div>
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
</div>
|
|
47
|
-
)
|
|
48
|
-
}
|