bhd-components 0.2.7 → 0.2.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.
@@ -3,7 +3,7 @@ interface TitleBarProps {
3
3
  title?: React.ReactElement;
4
4
  leftIcon?: React.ReactElement;
5
5
  subTitle?: React.ReactElement;
6
- rightContent: (kind?: string) => React.ReactElement;
6
+ rightContent?: (kind?: string) => React.ReactElement;
7
7
  rightMaxWidth?: number;
8
8
  wrapClassName?: string;
9
9
  leftIconClassName?: string;
@@ -14,27 +14,31 @@ const TitleBar = (props)=>{
14
14
  };
15
15
  // const onResize = useCallback(, [screenWidth]);
16
16
  const onResize = ()=>{
17
- const { width } = titleBarRef.current.getBoundingClientRect();
18
- const maxWidth = width * rightMaxWidth / 100;
19
- console.log("resize", maxWidth, screenWidth);
20
- if (screenWidth > maxWidth) {
21
- // kind minScreen
22
- setKind("minScreen");
23
- } else {
24
- setKind("screen");
17
+ if (rightContent) {
18
+ const { width } = titleBarRef.current.getBoundingClientRect();
19
+ const maxWidth = width * rightMaxWidth / 100;
20
+ console.log("resize", maxWidth, screenWidth);
21
+ if (screenWidth > maxWidth) {
22
+ // kind minScreen
23
+ setKind("minScreen");
24
+ } else {
25
+ setKind("screen");
26
+ }
25
27
  }
26
28
  };
27
29
  useLayoutEffect(()=>{
28
- const { width } = titleBarRef.current.getBoundingClientRect();
29
- const maxWidth = width * rightMaxWidth / 100;
30
- const rightWidth = rightContentRef.current.getBoundingClientRect().width;
31
- setScreenWidth(rightWidth);
32
- console.log("rightWidthrightWidth", rightWidth, maxWidth);
33
- if (rightWidth > maxWidth) {
34
- // kind minScreen
35
- setKind("minScreen");
36
- } else {
37
- setKind("screen");
30
+ if (rightContent) {
31
+ const { width } = titleBarRef.current.getBoundingClientRect();
32
+ const maxWidth = width * rightMaxWidth / 100;
33
+ const rightWidth = rightContentRef.current.getBoundingClientRect().width;
34
+ setScreenWidth(rightWidth);
35
+ console.log("rightWidthrightWidth", rightWidth, maxWidth);
36
+ if (rightWidth > maxWidth) {
37
+ // kind minScreen
38
+ setKind("minScreen");
39
+ } else {
40
+ setKind("screen");
41
+ }
38
42
  }
39
43
  }, []);
40
44
  useEffect(()=>{
@@ -3,7 +3,7 @@ interface TitleBarProps {
3
3
  title?: React.ReactElement;
4
4
  leftIcon?: React.ReactElement;
5
5
  subTitle?: React.ReactElement;
6
- rightContent: (kind?: string) => React.ReactElement;
6
+ rightContent?: (kind?: string) => React.ReactElement;
7
7
  rightMaxWidth?: number;
8
8
  wrapClassName?: string;
9
9
  leftIconClassName?: string;
@@ -15,27 +15,31 @@ var TitleBar = function(props) {
15
15
  };
16
16
  // const onResize = useCallback(, [screenWidth]);
17
17
  var onResize = function() {
18
- var width = titleBarRef.current.getBoundingClientRect().width;
19
- var maxWidth = width * rightMaxWidth / 100;
20
- console.log("resize", maxWidth, screenWidth);
21
- if (screenWidth > maxWidth) {
22
- // kind minScreen
23
- setKind("minScreen");
24
- } else {
25
- setKind("screen");
18
+ if (rightContent) {
19
+ var width = titleBarRef.current.getBoundingClientRect().width;
20
+ var maxWidth = width * rightMaxWidth / 100;
21
+ console.log("resize", maxWidth, screenWidth);
22
+ if (screenWidth > maxWidth) {
23
+ // kind minScreen
24
+ setKind("minScreen");
25
+ } else {
26
+ setKind("screen");
27
+ }
26
28
  }
27
29
  };
28
30
  useLayoutEffect(function() {
29
- var width = titleBarRef.current.getBoundingClientRect().width;
30
- var maxWidth = width * rightMaxWidth / 100;
31
- var rightWidth = rightContentRef.current.getBoundingClientRect().width;
32
- setScreenWidth(rightWidth);
33
- console.log("rightWidthrightWidth", rightWidth, maxWidth);
34
- if (rightWidth > maxWidth) {
35
- // kind minScreen
36
- setKind("minScreen");
37
- } else {
38
- setKind("screen");
31
+ if (rightContent) {
32
+ var width = titleBarRef.current.getBoundingClientRect().width;
33
+ var maxWidth = width * rightMaxWidth / 100;
34
+ var rightWidth = rightContentRef.current.getBoundingClientRect().width;
35
+ setScreenWidth(rightWidth);
36
+ console.log("rightWidthrightWidth", rightWidth, maxWidth);
37
+ if (rightWidth > maxWidth) {
38
+ // kind minScreen
39
+ setKind("minScreen");
40
+ } else {
41
+ setKind("screen");
42
+ }
39
43
  }
40
44
  }, []);
41
45
  useEffect(function() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bhd-components",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "组件功能描述",
5
5
  "files": [
6
6
  "esm",