Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Implement skeleton view in workspace member page #43893

Merged
merged 13 commits into from
Jun 25, 2024
9 changes: 7 additions & 2 deletions src/components/OptionsListSkeletonView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import {Circle, Rect} from 'react-native-svg';
import useThemeStyles from '@hooks/useThemeStyles';
import ItemListSkeletonView from './Skeletons/ItemListSkeletonView';

function getLinedWidth(index: number): string {
Expand All @@ -17,12 +18,16 @@ function getLinedWidth(index: number): string {

type OptionsListSkeletonViewProps = {
shouldAnimate?: boolean;
shouldStyleAsTable?: boolean;
};

function OptionsListSkeletonView({shouldAnimate = true}: OptionsListSkeletonViewProps) {
function OptionsListSkeletonView({shouldAnimate = true, shouldStyleAsTable = false}: OptionsListSkeletonViewProps) {
const styles = useThemeStyles();

return (
<ItemListSkeletonView
shouldAnimate={shouldAnimate}
itemViewStyle={shouldStyleAsTable && [styles.highlightBG, styles.mb3, styles.mh5, styles.br2]}
renderSkeletonItem={({itemIndex}) => {
const lineWidth = getLinedWidth(itemIndex);

Expand All @@ -42,7 +47,7 @@ function OptionsListSkeletonView({shouldAnimate = true}: OptionsListSkeletonView
<Rect
x="72"
y="38"
width={lineWidth}
width={shouldStyleAsTable ? '10%' : lineWidth}
height="8"
/>
</>
Expand Down
3 changes: 2 additions & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function BaseSelectionList<TItem extends ListItem>(
{
sections,
ListItem,
shouldUseUserSkeletonView,
canSelectMultiple = false,
onSelectRow,
shouldDebounceRowSelect = false,
Expand Down Expand Up @@ -680,7 +681,7 @@ function BaseSelectionList<TItem extends ListItem>(
)}
{!!headerContent && headerContent}
{flattenedSections.allOptions.length === 0 && showLoadingPlaceholder ? (
<OptionsListSkeletonView shouldAnimate />
<OptionsListSkeletonView shouldStyleAsTable={shouldUseUserSkeletonView} />
) : (
<>
{!listHeaderContent && header()}
Expand Down
7 changes: 7 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,19 @@ type SectionWithIndexOffset<TItem extends ListItem> = Section<TItem> & {
indexOffset?: number;
};

type SkeletonViewProps = {
shouldAnimate: boolean;
};

type BaseSelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
/** Sections for the section list */
sections: Array<SectionListDataType<TItem>> | typeof CONST.EMPTY_ARRAY;

/** Default renderer for every item in the list */
ListItem: ValidListItem;

shouldUseUserSkeletonView?: boolean;

/** Whether this is a multi-select list */
canSelectMultiple?: boolean;

Expand Down Expand Up @@ -485,6 +491,7 @@ export type {
ReportListItemProps,
ReportListItemType,
Section,
SkeletonViewProps,
SectionListDataType,
SectionWithIndexOffset,
SelectionListHandle,
Expand Down
1 change: 1 addition & 0 deletions src/pages/workspace/WorkspaceMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ function WorkspaceMembersPage({personalDetails, invitedEmailsToAccountIDsDraft,
canSelectMultiple={isPolicyAdmin}
sections={[{data, isDisabled: false}]}
ListItem={TableListItem}
shouldUseUserSkeletonView
disableKeyboardShortcuts={removeMembersConfirmModalVisible}
headerMessage={getHeaderMessage()}
headerContent={!isSmallScreenWidth && getHeaderContent()}
Expand Down
Loading