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

Update table component's skeleton look #4450

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 22 additions & 4 deletions app/components/Table/Table.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,30 @@
cursor: pointer;
}

.loader {
height: 40.797px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rocket science happening right here

}

.wrapper tr:nth-child(even) {
background-color: rgba(var(--rgb-min), var(--rgb-min), var(--rgb-min), 3%);

& .loader {
animation: skeleton-loading 1s linear infinite alternate;
}
}

@keyframes skeleton-loading {
0% {
background-color: var(--color-gray-1);
}

50% {
background-color: var(--color-gray-2);
}

100% {
background-color: var(--color-gray-3);
}
}

.checkbox {
Expand All @@ -34,10 +56,6 @@
font-size: var(--font-size-md);
}

.loader {
border-bottom: none;
}

.overlay {
min-width: 200px;
padding: 8px;
Expand Down
22 changes: 13 additions & 9 deletions app/components/Table/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LoadingIndicator } from '@webkom/lego-bricks';
import cx from 'classnames';
import { debounce, isEmpty, get } from 'lodash';
import { useEffect, useMemo, useState } from 'react';
Expand Down Expand Up @@ -176,12 +175,14 @@ const Table: React.FC<TableProps> = ({
}
};

const visibleColumns = columns.filter(isVisible);

return (
<div className={cx(styles.wrapper, className)}>
<table>
<thead>
<tr>
{columns.filter(isVisible).map((column, index) => (
{visibleColumns.map((column, index) => (
<HeadCell
key={column.dataIndex + column.title}
column={column}
Expand Down Expand Up @@ -217,13 +218,16 @@ const Table: React.FC<TableProps> = ({
))}
</tr>
))}
{loading && (
<tr>
<td className={styles.loader} colSpan={columns.length}>
<LoadingIndicator loading={loading} />
</td>
</tr>
)}
{loading &&
Array.from({ length: 10 }).map((_, index) => (
<tr key={index}>
{Array.from({ length: visibleColumns.length }).map(
(_, index) => (
<td key={index} className={styles.loader} />
)
)}
</tr>
))}
</InfiniteScroll>
</table>
</div>
Expand Down
20 changes: 9 additions & 11 deletions app/routes/admin/groups/components/GroupMembersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,15 @@ const GroupMembersList = ({
].filter(Boolean);

return (
<>
<Table
onChange={setQuery}
columns={columns}
hasMore={hasMore}
loading={fetching}
data={memberships}
filters={query}
className={styles.list}
/>
</>
<Table
onChange={setQuery}
columns={columns}
hasMore={hasMore}
loading={fetching}
data={memberships}
filters={query}
className={styles.list}
/>
);
};

Expand Down
2 changes: 1 addition & 1 deletion app/routes/events/components/EventAdministrate/Abacard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const Abacard = () => {
<div>
<Validator handleSelect={handleSelect} validateAbakusGroup={false} />
<div className={styles.counter}>
{registerCount}/{event.registrationCount} har møtt opp
{registerCount}/{event.registrationCount || '?'} har møtt opp
</div>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion app/routes/events/components/EventAdministrate/Allergies.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Button, Flex, Icon, LoadingIndicator } from '@webkom/lego-bricks';
import { usePreparedEffect } from '@webkom/react-prepare';
import { isEmpty } from 'lodash';
import { Link, useParams } from 'react-router-dom';
import { fetchAllergies } from 'app/actions/EventActions';
import Table from 'app/components/Table';
Expand All @@ -16,7 +17,7 @@ export const canSeeAllergies = (
currentUser?: CurrentUser,
event?: AdministrateEvent
) => {
if (!currentUser || !event) {
if (!currentUser || !event || isEmpty(event)) {
return false;
}
return (
Expand Down
23 changes: 7 additions & 16 deletions app/routes/events/components/EventAdministrate/Attendees.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
Button,
ConfirmModal,
Flex,
LoadingIndicator,
} from '@webkom/lego-bricks';
import { Button, ConfirmModal, Flex } from '@webkom/lego-bricks';
import moment from 'moment-timezone';
import { useState } from 'react';
import { formatPhoneNumber, parsePhoneNumber } from 'react-phone-number-input';
Expand Down Expand Up @@ -57,10 +52,6 @@ const Attendees = () => {
unreg.paymentStatus === 'succeeded' || unreg.paymentStatus === 'manual'
).length;

if (loading || !event) {
return <LoadingIndicator loading={loading} />;
}

// Not showing the presence column until 1 day before start or if someone has been given set to presence
const showPresence =
moment().isAfter(moment(event.startTime).subtract(1, 'day')) ||
Expand Down Expand Up @@ -129,14 +120,14 @@ const Attendees = () => {
</Flex>
<Flex column>
<div>
<strong>Påmeldte:</strong>
<strong>Påmeldte</strong>
<div className={styles.attendeeStatistics}>
{`${registerCount}/${event.registrationCount} ${
{`${registerCount}/${event.registrationCount || '?'} ${
eventHasEnded ? 'møtte opp' : 'har møtt opp'
}`}
</div>
<div className={styles.attendeeStatistics}>
{`${adminRegisterCount}/${event.registrationCount} ${
{`${adminRegisterCount}/${event.registrationCount || '?'} ${
eventHasEnded ? 'ble' : 'er'
} adminpåmeldt`}
</div>
Expand All @@ -155,7 +146,7 @@ const Attendees = () => {
: ''}
</div>
</div>
{registered.length === 0 ? (
{registered.length === 0 && !loading ? (
<span className="secondaryFontColor">Ingen påmeldte</span>
) : (
<RegisteredTable
Expand All @@ -172,9 +163,9 @@ const Attendees = () => {
marginTop: '10px',
}}
>
Avmeldte:
Avmeldte
</strong>
{unregistered.length === 0 ? (
{unregistered.length === 0 && !loading ? (
<span className="secondaryFontColor">Ingen avmeldte</span>
) : (
<UnregisteredTable
Expand Down
10 changes: 1 addition & 9 deletions app/routes/events/components/EventAdministrate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import loadable from '@loadable/component';
import { LoadingIndicator } from '@webkom/lego-bricks';
import { usePreparedEffect } from '@webkom/react-prepare';
import { Route, Routes, useParams } from 'react-router-dom';
import { fetchAdministrate } from 'app/actions/EventActions';
Expand Down Expand Up @@ -33,14 +32,6 @@ const EventAdministrateIndex = () => {

const base = `/events/${eventId}/administrate`;

if (!event) {
return (
<Content>
<LoadingIndicator loading={fetching} />
</Content>
);
}

return (
<Content>
<NavigationTab
Expand All @@ -49,6 +40,7 @@ const EventAdministrateIndex = () => {
label: 'Tilbake',
path: '/events/' + event.slug,
}}
skeleton={fetching}
>
<NavigationLink to={`${base}/attendees`}>Påmeldinger</NavigationLink>
{event && canSeeAllergies(currentUser, event) && (
Expand Down
10 changes: 6 additions & 4 deletions app/routes/users/components/UserSettingsOAuth2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ const UserSettingsOAuth2 = () => {
<Link to="/users/me/settings/oauth2/new">Ny applikasjon</Link>
</Button>
)}
{applications.length === 0 ? (
<span>Du har ingen applikasjoner</span>
{applications.length === 0 && !fetchingApplications ? (
<span className="secondaryFontColor">Du har ingen applikasjoner</span>
) : (
<Table
columns={applicationColumns}
Expand All @@ -209,8 +209,10 @@ const UserSettingsOAuth2 = () => {
</Flex>

<h3>Aksepterte applikasjoner</h3>
{grants.length === 0 ? (
<span>Du har ikke logget på en app enda.</span>
{grants.length === 0 && !fetchingGrants ? (
<span className="secondaryFontColor">
Du har ikke logget på en app enda
</span>
) : (
<Table
columns={acceptedApplicationcolumns}
Expand Down