@design-system-rte/core 0.2.0-rc3 → 0.2.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.
@@ -0,0 +1,9 @@
1
+ export type Position = 'auto' | 'top' | 'bottom' | 'left' | 'right';
2
+ export type Alignment = 'start' | 'center' | 'end';
3
+
4
+ export interface TooltipProps {
5
+ position?: Position;
6
+ alignment?: Alignment;
7
+ label?: string;
8
+ arrow?: boolean;
9
+ }
@@ -0,0 +1,19 @@
1
+ export const getAutoPlacement = (element: HTMLElement, defaultPosition: string) => {
2
+ const parent = element.parentElement;
3
+ if (!parent) return defaultPosition;
4
+
5
+ const parentRect = parent.getBoundingClientRect();
6
+ const tooltipRect = element.getBoundingClientRect();
7
+
8
+ const hasSpaceTop = tooltipRect.top-40 >= parentRect.top;
9
+ const hasSpaceBottom = tooltipRect.bottom+40 <= parentRect.bottom;
10
+ const hasSpaceLeft = tooltipRect.left-160 >= parentRect.left;
11
+ const hasSpaceRight = tooltipRect.right+160 <= parentRect.right;
12
+
13
+ if (hasSpaceTop) return "top";
14
+ if (hasSpaceBottom) return "bottom";
15
+ if (hasSpaceLeft) return "left";
16
+ if (hasSpaceRight) return "right";
17
+
18
+ return defaultPosition;
19
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design-system-rte/core",
3
- "version": "0.2.0-rc3",
3
+ "version": "0.2.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
@@ -234,4 +234,18 @@ $button-l-semibold-letter-spacing: $letter-spacing-s;
234
234
  @mixin typography-checkbox-error {
235
235
  @include typography-text-s;
236
236
  font-weight: $text-s-bold-font-weight;
237
+ }
238
+
239
+ @mixin typography-tooltip{
240
+ font-feature-settings: "liga" off, "clig" off;
241
+ font-style: normal;
242
+ }
243
+
244
+ @mixin typography-tooltip-label{
245
+ @include typography-tooltip;
246
+ font-family: $text-m-regular-font-family;
247
+ font-weight: $text-m-regular-font-weight;
248
+ font-size: $text-m-regular-font-size;
249
+ line-height: $text-m-regular-line-height;
250
+ letter-spacing: $text-m-regular-letter-spacing;
237
251
  }
package/tsconfig.json CHANGED
@@ -7,6 +7,5 @@
7
7
  "forceConsistentCasingInFileNames": true,
8
8
  "strict": true
9
9
  },
10
- "include": ["scripts/**/*"],
11
10
  "exclude": ["node_modules"]
12
- }
11
+ }