mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Empty placeholder component. CSS fixes.
This commit is contained in:
parent
cd76cc895f
commit
e309376150
@ -9,6 +9,7 @@ import Button from './common/Button';
|
|||||||
import PageHeader from './layout/PageHeader';
|
import PageHeader from './layout/PageHeader';
|
||||||
import Arrow from 'assets/arrow-right.svg';
|
import Arrow from 'assets/arrow-right.svg';
|
||||||
import styles from './WebsiteList.module.css';
|
import styles from './WebsiteList.module.css';
|
||||||
|
import EmptyPlaceholder from './common/EmptyPlaceholder';
|
||||||
|
|
||||||
export default function WebsiteList() {
|
export default function WebsiteList() {
|
||||||
const [data, setData] = useState();
|
const [data, setData] = useState();
|
||||||
@ -22,6 +23,10 @@ export default function WebsiteList() {
|
|||||||
loadData();
|
loadData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
{data?.map(({ website_id, name }) => (
|
{data?.map(({ website_id, name }) => (
|
||||||
@ -51,6 +56,13 @@ export default function WebsiteList() {
|
|||||||
<WebsiteChart key={website_id} title={name} websiteId={website_id} />
|
<WebsiteChart key={website_id} title={name} websiteId={website_id} />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
{data.length === 0 && (
|
||||||
|
<EmptyPlaceholder msg={"You don't have any websites configured."}>
|
||||||
|
<Button icon={<Arrow />} size="medium" onClick={() => router.push('/settings')}>
|
||||||
|
<div>Go to settings</div>
|
||||||
|
</Button>
|
||||||
|
</EmptyPlaceholder>
|
||||||
|
)}
|
||||||
</Page>
|
</Page>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@ import WebsiteEditForm from './forms/WebsiteEditForm';
|
|||||||
import DeleteForm from './forms/DeleteForm';
|
import DeleteForm from './forms/DeleteForm';
|
||||||
import WebsiteCodeForm from './forms/WebsiteCodeForm';
|
import WebsiteCodeForm from './forms/WebsiteCodeForm';
|
||||||
import styles from './WebsiteSettings.module.css';
|
import styles from './WebsiteSettings.module.css';
|
||||||
|
import EmptyPlaceholder from './common/EmptyPlaceholder';
|
||||||
|
import Arrow from '../assets/arrow-right.svg';
|
||||||
|
|
||||||
export default function WebsiteSettings() {
|
export default function WebsiteSettings() {
|
||||||
const [data, setData] = useState();
|
const [data, setData] = useState();
|
||||||
@ -67,6 +69,14 @@ export default function WebsiteSettings() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const empty = (
|
||||||
|
<EmptyPlaceholder msg={"You don't have any websites configured."}>
|
||||||
|
<Button icon={<Plus />} size="medium" onClick={() => setAddWebsite(true)}>
|
||||||
|
<div>Add website</div>
|
||||||
|
</Button>
|
||||||
|
</EmptyPlaceholder>
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<PageHeader>
|
<PageHeader>
|
||||||
@ -75,7 +85,7 @@ export default function WebsiteSettings() {
|
|||||||
<div>Add website</div>
|
<div>Add website</div>
|
||||||
</Button>
|
</Button>
|
||||||
</PageHeader>
|
</PageHeader>
|
||||||
<Table columns={columns} rows={data} />
|
<Table columns={columns} rows={data} empty={empty} />
|
||||||
{editWebsite && (
|
{editWebsite && (
|
||||||
<Modal title="Edit website">
|
<Modal title="Edit website">
|
||||||
<WebsiteEditForm values={editWebsite} onSave={handleSave} onClose={handleClose} />
|
<WebsiteEditForm values={editWebsite} onSave={handleSave} onClose={handleClose} />
|
||||||
|
14
components/common/EmptyPlaceholder.js
Normal file
14
components/common/EmptyPlaceholder.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import Icon from 'components/common/Icon';
|
||||||
|
import Logo from 'assets/logo.svg';
|
||||||
|
import styles from './EmptyPlaceholder.module.css';
|
||||||
|
|
||||||
|
export default function EmptyPlaceholder({ msg, children }) {
|
||||||
|
return (
|
||||||
|
<div className={styles.placeholder}>
|
||||||
|
<Icon icon={<Logo />} size="xlarge" />
|
||||||
|
<h2>{msg}</h2>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
7
components/common/EmptyPlaceholder.module.css
Normal file
7
components/common/EmptyPlaceholder.module.css
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.placeholder {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
min-height: 600px;
|
||||||
|
}
|
@ -22,7 +22,9 @@ export default function Menu({
|
|||||||
[styles.right]: align === 'right',
|
[styles.right]: align === 'right',
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
{options.map(option => {
|
{options
|
||||||
|
.filter(({ hidden }) => !hidden)
|
||||||
|
.map(option => {
|
||||||
const { label, value, className: customClassName, render } = option;
|
const { label, value, className: customClassName, render } = option;
|
||||||
|
|
||||||
return render ? (
|
return render ? (
|
||||||
|
@ -2,7 +2,11 @@ import React from 'react';
|
|||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import styles from './Table.module.css';
|
import styles from './Table.module.css';
|
||||||
|
|
||||||
export default function Table({ columns, rows }) {
|
export default function Table({ columns, rows, empty }) {
|
||||||
|
if (empty && rows.length === 0) {
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.table}>
|
<div className={styles.table}>
|
||||||
<div className={styles.header}>
|
<div className={styles.header}>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
.table {
|
.table {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
@ -16,8 +17,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.body {
|
.body {
|
||||||
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.body:empty:before {
|
||||||
|
content: 'No data available';
|
||||||
|
color: var(--gray500);
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
|
@ -54,9 +54,14 @@ textarea {
|
|||||||
line-height: 1.8;
|
line-height: 1.8;
|
||||||
border: 1px solid var(--gray500);
|
border: 1px solid var(--gray500);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
width: 100%;
|
|
||||||
outline: none;
|
outline: none;
|
||||||
resize: none;
|
resize: none;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
flex: 1;
|
||||||
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
dt {
|
dt {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user