cognite-create 0.3.6 → 0.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.
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: Whenever you are
|
|
2
|
+
description: Whenever you are generating layouts or components with design instructions or reference images, consult these rules.
|
|
3
3
|
alwaysApply: false
|
|
4
4
|
---
|
|
5
5
|
|
|
@@ -13,4 +13,7 @@ Responsive design is a must.
|
|
|
13
13
|
|
|
14
14
|
Styling must be consistent with the Cognite design patterns.
|
|
15
15
|
|
|
16
|
-
Do not edit the Cognite components you add directly you can create wrappers around them.
|
|
16
|
+
Do not edit the Cognite components you add directly you can create wrappers around them.
|
|
17
|
+
|
|
18
|
+
Grids
|
|
19
|
+
Make sure to build up grids using either flex or grid classes from tailwind, consider the arrangement and use the best one for the job. Make sure to align components as neatly as possible.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
|
|
3
|
+
const MOBILE_BREAKPOINT = 768
|
|
4
|
+
|
|
5
|
+
export function useIsMobile() {
|
|
6
|
+
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)
|
|
7
|
+
|
|
8
|
+
React.useEffect(() => {
|
|
9
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)
|
|
10
|
+
const onChange = () => {
|
|
11
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
|
12
|
+
}
|
|
13
|
+
mql.addEventListener("change", onChange)
|
|
14
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)
|
|
15
|
+
return () => mql.removeEventListener("change", onChange)
|
|
16
|
+
}, [])
|
|
17
|
+
|
|
18
|
+
return !!isMobile
|
|
19
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEffect, RefObject } from "react";
|
|
2
|
+
|
|
3
|
+
export function useOutsideClick<T extends HTMLElement = HTMLElement>(
|
|
4
|
+
ref: RefObject<T>,
|
|
5
|
+
handler: (event: MouseEvent | TouchEvent) => void
|
|
6
|
+
) {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const listener = (event: MouseEvent | TouchEvent) => {
|
|
9
|
+
const el = ref?.current;
|
|
10
|
+
if (!el || el.contains((event?.target as Node) || null)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
handler(event);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
document.addEventListener("mousedown", listener);
|
|
18
|
+
document.addEventListener("touchstart", listener);
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
document.removeEventListener("mousedown", listener);
|
|
22
|
+
document.removeEventListener("touchstart", listener);
|
|
23
|
+
};
|
|
24
|
+
}, [ref, handler]);
|
|
25
|
+
}
|
|
File without changes
|