mirror of
https://github.com/owncast/owncast.git
synced 2024-11-29 11:39:08 +03:00
Fixes : Admin: Custom emoji page layout (#2993)
* Update emojis.tsx * Prettified Code! * Second Iteration * Update emojis.tsx * Putting Delete Button at top-right Will this work ? * Prettified Code! * Update emojis.tsx Changing Icon of Delete Button Decreasing Delete-Button Size * Prettified Code! * Tweak style of delete emoji button --------- Co-authored-by: dev265545 <dev265545@users.noreply.github.com> Co-authored-by: Gabe Kangas <gabek@real-ity.com>
This commit is contained in:
parent
0803184c47
commit
fb36d32fa0
1 changed files with 47 additions and 38 deletions
|
@ -1,11 +1,9 @@
|
||||||
import { Button, Space, Table, Typography, Upload } from 'antd';
|
import { Avatar, Button, Card, Col, Row, Tooltip, Typography } from 'antd';
|
||||||
import { RcFile } from 'antd/lib/upload';
|
import Upload, { RcFile } from 'antd/lib/upload';
|
||||||
import React, { ReactElement, useEffect, useState } from 'react';
|
import React, { ReactElement, useEffect, useState } from 'react';
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import FormStatusIndicator from '../../../components/admin/FormStatusIndicator';
|
import FormStatusIndicator from '../../../components/admin/FormStatusIndicator';
|
||||||
|
|
||||||
import { DELETE_EMOJI, fetchData, UPLOAD_EMOJI } from '../../../utils/apis';
|
import { DELETE_EMOJI, fetchData, UPLOAD_EMOJI } from '../../../utils/apis';
|
||||||
|
|
||||||
import { ACCEPTED_IMAGE_TYPES, getBase64 } from '../../../utils/images';
|
import { ACCEPTED_IMAGE_TYPES, getBase64 } from '../../../utils/images';
|
||||||
import {
|
import {
|
||||||
createInputStatus,
|
createInputStatus,
|
||||||
|
@ -15,12 +13,12 @@ import {
|
||||||
} from '../../../utils/input-statuses';
|
} from '../../../utils/input-statuses';
|
||||||
import { RESET_TIMEOUT } from '../../../utils/config-constants';
|
import { RESET_TIMEOUT } from '../../../utils/config-constants';
|
||||||
import { URL_CUSTOM_EMOJIS } from '../../../utils/constants';
|
import { URL_CUSTOM_EMOJIS } from '../../../utils/constants';
|
||||||
|
|
||||||
import { AdminLayout } from '../../../components/layouts/AdminLayout';
|
import { AdminLayout } from '../../../components/layouts/AdminLayout';
|
||||||
|
|
||||||
|
const { Meta } = Card;
|
||||||
// Lazy loaded components
|
// Lazy loaded components
|
||||||
|
|
||||||
const DeleteOutlined = dynamic(() => import('@ant-design/icons/DeleteOutlined'), {
|
const CloseOutlined = dynamic(() => import('@ant-design/icons/CloseOutlined'), {
|
||||||
ssr: false,
|
ssr: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -33,7 +31,6 @@ const { Title, Paragraph } = Typography;
|
||||||
|
|
||||||
const Emoji = () => {
|
const Emoji = () => {
|
||||||
const [emojis, setEmojis] = useState<CustomEmoji[]>([]);
|
const [emojis, setEmojis] = useState<CustomEmoji[]>([]);
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [submitStatus, setSubmitStatus] = useState(null);
|
const [submitStatus, setSubmitStatus] = useState(null);
|
||||||
const [uploadFile, setUploadFile] = useState<RcFile>(null);
|
const [uploadFile, setUploadFile] = useState<RcFile>(null);
|
||||||
|
@ -133,30 +130,6 @@ const Emoji = () => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns = [
|
|
||||||
{
|
|
||||||
title: '',
|
|
||||||
key: 'delete',
|
|
||||||
render: (text, record) => (
|
|
||||||
<Space size="middle">
|
|
||||||
<Button onClick={() => handleDelete(record.url)} icon={<DeleteOutlined />} />
|
|
||||||
</Space>
|
|
||||||
),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Name',
|
|
||||||
key: 'name',
|
|
||||||
dataIndex: 'name',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: 'Emoji',
|
|
||||||
key: 'url',
|
|
||||||
render: (text, record) => (
|
|
||||||
<img src={record.url} alt={record.name} style={{ maxWidth: '2vw' }} />
|
|
||||||
),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Title>Emojis</Title>
|
<Title>Emojis</Title>
|
||||||
|
@ -164,13 +137,6 @@ const Emoji = () => {
|
||||||
Here you can upload new custom emojis for usage in the chat. When uploading a new emoji, the
|
Here you can upload new custom emojis for usage in the chat. When uploading a new emoji, the
|
||||||
filename will be used as emoji name.
|
filename will be used as emoji name.
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
|
|
||||||
<Table
|
|
||||||
rowKey={record => record.url}
|
|
||||||
dataSource={emojis}
|
|
||||||
columns={columns}
|
|
||||||
pagination={false}
|
|
||||||
/>
|
|
||||||
<br />
|
<br />
|
||||||
<Upload
|
<Upload
|
||||||
name="emoji"
|
name="emoji"
|
||||||
|
@ -187,6 +153,49 @@ const Emoji = () => {
|
||||||
</Button>
|
</Button>
|
||||||
</Upload>
|
</Upload>
|
||||||
<FormStatusIndicator status={submitStatus} />
|
<FormStatusIndicator status={submitStatus} />
|
||||||
|
<br />
|
||||||
|
<Row>
|
||||||
|
{emojis.map(record => (
|
||||||
|
<Col style={{ padding: '10px' }} key={record.name}>
|
||||||
|
<Card style={{ width: 120, marginTop: 16 }} actions={[]}>
|
||||||
|
<Meta
|
||||||
|
description={[
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
justifyItems: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: '20px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tooltip title={record.name}>
|
||||||
|
<Avatar style={{ height: 50, width: 50 }} src={record.url} />
|
||||||
|
</Tooltip>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
type="ghost"
|
||||||
|
title="Delete emoji"
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
right: 0,
|
||||||
|
top: 0,
|
||||||
|
height: 24,
|
||||||
|
width: 24,
|
||||||
|
border: 'none',
|
||||||
|
color: 'gray',
|
||||||
|
}}
|
||||||
|
onClick={() => handleDelete(record.url)}
|
||||||
|
icon={<CloseOutlined />}
|
||||||
|
/>
|
||||||
|
</div>,
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
))}
|
||||||
|
</Row>
|
||||||
|
<br />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue