1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-07-24 13:39:35 +02:00

Display info message on homescreen if applications or categories arrays are empty

This commit is contained in:
unknown 2021-06-08 14:02:19 +02:00
parent 22920f2660
commit 35c589c94c
8 changed files with 58 additions and 42 deletions

View file

@ -28,4 +28,13 @@
.GridMessage a { .GridMessage a {
color: var(--color-accent); color: var(--color-accent);
font-weight: 600; font-weight: 600;
}
.AppsMessage {
color: var(--color-primary);
}
.AppsMessage a {
color: var(--color-accent);
font-weight: 600;
} }

View file

@ -1,4 +1,5 @@
import classes from './AppGrid.module.css'; import classes from './AppGrid.module.css';
import { Link } from 'react-router-dom';
import { App } from '../../../interfaces/App'; import { App } from '../../../interfaces/App';
import AppCard from '../AppCard/AppCard'; import AppCard from '../AppCard/AppCard';
@ -8,16 +9,24 @@ interface ComponentProps {
} }
const AppGrid = (props: ComponentProps): JSX.Element => { const AppGrid = (props: ComponentProps): JSX.Element => {
const apps = ( let apps: JSX.Element;
<div className={classes.AppGrid}>
{props.apps.map((app: App): JSX.Element => { if (props.apps.length > 0) {
return <AppCard apps = (
key={app.id} <div className={classes.AppGrid}>
app={app} {props.apps.map((app: App): JSX.Element => {
/> return <AppCard
})} key={app.id}
</div> app={app}
); />
})}
</div>
)
} else {
apps = (
<p className={classes.AppsMessage}>You don't have any applications. You can add a new one from <Link to='/applications'>/application</Link> menu</p>
);
}
return apps; return apps;
} }

View file

@ -1,13 +1,4 @@
.ActionsContainer { .ActionsContainer {
display: flex; display: flex;
align-items: center; align-items: center;
}
.AppsMessage {
color: var(--color-primary);
}
.AppsMessage a {
color: var(--color-accent);
font-weight: 600;
} }

View file

@ -96,9 +96,7 @@ const Apps = (props: ComponentProps): JSX.Element => {
{props.loading {props.loading
? <Spinner /> ? <Spinner />
: (!isInEdit : (!isInEdit
? props.apps.length > 0 ? <AppGrid apps={props.apps} />
? <AppGrid apps={props.apps} />
: <p className={classes.AppsMessage}>You don't have any applications. You can add a new one from <Link to='/applications'>/application</Link> menu</p>
: <AppTable updateAppHandler={toggleUpdate} />) : <AppTable updateAppHandler={toggleUpdate} />)
} }
</div> </div>

View file

@ -19,4 +19,13 @@
.BookmarkGrid { .BookmarkGrid {
grid-template-columns: repeat(4, 1fr); grid-template-columns: repeat(4, 1fr);
} }
}
.BookmarksMessage {
color: var(--color-primary);
}
.BookmarksMessage a {
color: var(--color-accent);
font-weight: 600;
} }

View file

@ -1,3 +1,5 @@
import { Link } from 'react-router-dom';
import classes from './BookmarkGrid.module.css'; import classes from './BookmarkGrid.module.css';
import { Bookmark, Category } from '../../../interfaces'; import { Bookmark, Category } from '../../../interfaces';
@ -9,12 +11,21 @@ interface ComponentProps {
} }
const BookmarkGrid = (props: ComponentProps): JSX.Element => { const BookmarkGrid = (props: ComponentProps): JSX.Element => {
return ( let bookmarks: JSX.Element;
<div className={classes.BookmarkGrid}>
{props.categories.map((category: Category): JSX.Element => <BookmarkCard category={category} key={category.id} />)} if (props.categories.length > 0) {
</div> bookmarks = (
) <div className={classes.BookmarkGrid}>
{props.categories.map((category: Category): JSX.Element => <BookmarkCard category={category} key={category.id} />)}
</div>
);
} else {
bookmarks = (
<p className={classes.BookmarksMessage}>You don't have any bookmarks. You can add a new one from <Link to='/bookmarks'>/bookmarks</Link> menu</p>
);
}
return bookmarks;
} }
export default BookmarkGrid; export default BookmarkGrid;

View file

@ -1,13 +1,4 @@
.ActionsContainer { .ActionsContainer {
display: flex; display: flex;
align-items: center; align-items: center;
}
.BookmarksMessage {
color: var(--color-primary);
}
.BookmarksMessage a {
color: var(--color-accent);
font-weight: 600;
} }

View file

@ -134,14 +134,12 @@ const Bookmarks = (props: ComponentProps): JSX.Element => {
{props.loading {props.loading
? <Spinner /> ? <Spinner />
: (!isInEdit : (!isInEdit
? props.categories.length > 0 ? <BookmarkGrid categories={props.categories} />
? <BookmarkGrid categories={props.categories} /> : <BookmarkTable
: <p className={classes.BookmarksMessage}>You don't have any bookmarks. You can add a new one from <Link to='/bookmarks'>/bookmarks</Link> menu</p>
: (<BookmarkTable
contentType={tableContentType} contentType={tableContentType}
categories={props.categories} categories={props.categories}
updateHandler={goToUpdateMode} updateHandler={goToUpdateMode}
/>) />
) )
} }
</Container> </Container>