Skip to content

Commit c2956d6

Browse files
committed
WIP: PR comments
1 parent 0f36a38 commit c2956d6

File tree

8 files changed

+20
-27
lines changed

8 files changed

+20
-27
lines changed

packages/main/src/components/ObjectPage/CollapsedAvatar.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { ReactNode, useLayoutEffect, useMemo, useRef, useState } from 'react';
22
import { createUseStyles } from 'react-jss';
3-
import { Avatar } from '../Avatar';
4-
import { AvatarShape, AvatarSize } from '../..';
3+
import { Avatar } from '../../lib/Avatar';
4+
import { AvatarSize } from '../../lib/AvatarSize';
5+
import { AvatarShape } from '../../lib/AvatarShape';
56
import { StyleClassHelper } from '@ui5/webcomponents-react-base';
67

78
const styles = {
@@ -18,14 +19,16 @@ const styles = {
1819
}
1920
};
2021

21-
const useStyles = createUseStyles(styles);
22+
const useStyles = createUseStyles(styles, {
23+
name: 'CollapsedAvatar'
24+
});
2225

2326
export interface CollapsedAvatarPropTypes {
2427
image?: string | ReactNode;
2528
imageShapeCircle?: boolean;
2629
}
2730

28-
export function CollapsedAvatar(props: CollapsedAvatarPropTypes) {
31+
export const CollapsedAvatar = (props: CollapsedAvatarPropTypes) => {
2932
const { image, imageShapeCircle } = props;
3033
const classes = useStyles();
3134
const [isMounted, setIsMounted] = useState(false);
@@ -53,21 +56,13 @@ export function CollapsedAvatar(props: CollapsedAvatarPropTypes) {
5356
useLayoutEffect(() => {
5457
requestAnimationFrame(() => {
5558
setIsMounted(true);
56-
// @ts-ignore
57-
// setTimeout(() => {
58-
// // @ts-ignore
59-
// domRef.current.style.opacity = 1;
60-
// domRef.current.style.transition = 'opacity 3s';
61-
// }, 1000);
6259
});
6360
}, []);
6461

6562
const containerClasses = StyleClassHelper.of(classes.base);
6663
if (isMounted) {
67-
// debugger;
6864
containerClasses.put(classes.visible);
6965
} else {
70-
// debugger;
7166
containerClasses.put(classes.hidden);
7267
}
7368

@@ -76,4 +71,4 @@ export function CollapsedAvatar(props: CollapsedAvatarPropTypes) {
7671
{avatarContent}
7772
</div>
7873
);
79-
}
74+
};

packages/main/src/components/ObjectPage/ObjectPageAnchorButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export const ObjectPageAnchorButton: FC<ObjectPageAnchorPropTypes> = (props) =>
122122
<ObjectPageLink
123123
key={item.props.id}
124124
id={`ObjectPageSubSection-${item.props.id}`}
125-
scrollOffset={collapsedHeader ? 0 : -45}
125+
scrollOffset={collapsedHeader ? 45 : 0}
126126
>
127127
<StandardListItem data-key={item.props.id}>{item.props.title}</StandardListItem>
128128
</ObjectPageLink>
@@ -137,7 +137,7 @@ export const ObjectPageAnchorButton: FC<ObjectPageAnchorPropTypes> = (props) =>
137137
onSetActive={onScrollActive}
138138
activeClass={classes.selected}
139139
alwaysToTop={index === 0}
140-
scrollOffset={collapsedHeader ? 0 : -45}
140+
scrollOffset={collapsedHeader ? 45 : 0}
141141
>
142142
<span className={classes.button}>{section.props.title}</span>
143143
</ObjectPageLink>

packages/main/src/components/ObjectPage/demo.stories.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import { ObjectPageSubSection } from '../../lib/ObjectPageSubSection';
1414
import { Text } from '../../lib/Text';
1515
// @ts-ignore
1616
import SampleImage from './DemoImage.png';
17-
import { ScrollDemo } from './ScrollDemo';
18-
import { ScrollSyncExample } from './scrollSync/ScrollSyncExample';
1917

2018
const renderHeaderContent = () => (
2119
<div style={{ display: 'flex', flexDirection: 'column' }}>

packages/main/src/components/ObjectPage/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { ObjectPageScroller } from './scroll/ObjectPageScroller';
2626
import { Avatar } from '@ui5/webcomponents-react/lib/Avatar';
2727
import { AvatarSize } from '@ui5/webcomponents-react/lib/AvatarSize';
2828
import { AvatarShape } from '@ui5/webcomponents-react/lib/AvatarShape';
29-
import { ContentDensity } from '../..';
29+
import { ContentDensity } from '../../lib/ContentDensity';
3030

3131
export interface ObjectPagePropTypes extends CommonProps {
3232
title?: string;
@@ -299,7 +299,7 @@ const ObjectPage: FC<ObjectPagePropTypes> = forwardRef((props: ObjectPagePropTyp
299299

300300
useEffect(() => {
301301
if (selectedSubSectionId && mode === ObjectPageMode.IconTabBar && scroller.current) {
302-
scroller.current.scrollToElementById(`ObjectPageSubSection-${selectedSubSectionId}`, collapsedHeader ? 0 : -45);
302+
scroller.current.scrollToElementById(`ObjectPageSubSection-${selectedSubSectionId}`, collapsedHeader ? 45 : 0);
303303
}
304304
}, [selectedSubSectionId]);
305305

@@ -311,7 +311,7 @@ const ObjectPage: FC<ObjectPagePropTypes> = forwardRef((props: ObjectPagePropTyp
311311
// @ts-ignore
312312
const id = Children.toArray(children)[selectedSectionIndex].props.id;
313313
if (id) {
314-
scroller.current.scrollToElementById(`ObjectPageSection-${id}`, collapsedHeader ? 0 : -45);
314+
scroller.current.scrollToElementById(`ObjectPageSection-${id}`, collapsedHeader ? 45 : 0);
315315
}
316316
} else {
317317
scroller.current.scrollToTop();

packages/main/src/components/ObjectPage/scroll/ObjectPageLink.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useCallback, useContext, useEffect } from 'react';
22
import { ScrollContext } from './ScrollContext';
33

4-
export function ObjectPageLink(props) {
4+
export const ObjectPageLink = (props) => {
55
const {
66
children,
77
inactiveClass = '',
@@ -41,4 +41,4 @@ export function ObjectPageLink(props) {
4141
{children}
4242
</div>
4343
);
44-
}
44+
};

packages/main/src/components/ObjectPage/scroll/ObjectPageScroller.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export const ObjectPageScroller = forwardRef((props: Props, ref) => {
5353
if (element) {
5454
const { htmlRef } = element;
5555
scrollTo(
56-
element.offsetTop + 1 + scrollOffset,
56+
element.offsetTop + scrollOffset,
5757
{
5858
scrollContainer,
5959
absolute: true

packages/main/src/components/ObjectPage/scroll/ScrollContextProvider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useMemo } from 'react';
22
import { ScrollContext } from './ScrollContext';
33

4-
export function ScrollContentProvider(props) {
4+
export const ScrollContentProvider = (props) => {
55
const {
66
children,
77
scrollContainer,
@@ -23,4 +23,4 @@ export function ScrollContentProvider(props) {
2323
}, [scrollContainer, registerElement, unregisterElement, scrollToElementById, selectedElementId, scrollToTop]);
2424

2525
return <ScrollContext.Provider value={context}>{children}</ScrollContext.Provider>;
26-
}
26+
};

packages/main/src/components/ObjectPage/scroll/useScrollElement.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useContext, useEffect } from 'react';
22
import { ScrollContext } from './ScrollContext';
33

4-
export function useScrollElement(id, htmlRef, options = {}) {
4+
export const useScrollElement = (id, htmlRef, options = {}) => {
55
const { registerElement, unregisterElement } = useContext(ScrollContext);
66

77
useEffect(() => {
@@ -16,4 +16,4 @@ export function useScrollElement(id, htmlRef, options = {}) {
1616
unregisterElement(id);
1717
};
1818
}, [htmlRef.current]);
19-
}
19+
};

0 commit comments

Comments
 (0)