Skip to content

Commit 54c38de

Browse files
committed
style: improve code formatting and structure in ChannelsTable and render helpers
1 parent d6284bf commit 54c38de

File tree

2 files changed

+41
-15
lines changed

2 files changed

+41
-15
lines changed

web/default/src/components/ChannelsTable.js

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
import React, {useEffect, useState} from 'react';
2-
import {useTranslation} from 'react-i18next';
3-
import {Button, Dropdown, Form, Input, Label, Message, Pagination, Popup, Table,} from 'semantic-ui-react';
4-
import {Link} from 'react-router-dom';
1+
import React, { useEffect, useState } from 'react';
2+
import { useTranslation } from 'react-i18next';
3+
import {
4+
Button,
5+
Dropdown,
6+
Form,
7+
Input,
8+
Label,
9+
Message,
10+
Pagination,
11+
Popup,
12+
Table,
13+
} from 'semantic-ui-react';
14+
import { Link } from 'react-router-dom';
515
import {
616
API,
717
loadChannelModels,
@@ -13,8 +23,8 @@ import {
1323
timestamp2string,
1424
} from '../helpers';
1525

16-
import {CHANNEL_OPTIONS, ITEMS_PER_PAGE} from '../constants';
17-
import {renderGroup, renderNumber} from '../helpers/render';
26+
import { CHANNEL_OPTIONS, ITEMS_PER_PAGE } from '../constants';
27+
import { renderGroup, renderNumber } from '../helpers/render';
1828

1929
function renderTimestamp(timestamp) {
2030
return <>{timestamp2string(timestamp)}</>;
@@ -108,7 +118,7 @@ const ChannelsTable = () => {
108118

109119
const loadChannels = async (startIdx) => {
110120
const res = await API.get(`/api/channel/?p=${startIdx}`);
111-
const {success, message, data} = res.data;
121+
const { success, message, data } = res.data;
112122
if (success) {
113123
let localChannels = data.map(processChannelData);
114124
if (startIdx === 0) {
@@ -588,7 +598,15 @@ const ChannelsTable = () => {
588598
/>
589599
</Table.Cell>
590600
<Table.Cell>
591-
<div>
601+
<div
602+
style={{
603+
display: 'flex',
604+
alignItems: 'center',
605+
flexWrap: 'wrap',
606+
gap: '2px',
607+
rowGap: '6px',
608+
}}
609+
>
592610
<Button
593611
size={'tiny'}
594612
positive

web/default/src/helpers/render.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Label, Message} from 'semantic-ui-react';
2-
import {getChannelOption} from './helper';
1+
import { Label, Message } from 'semantic-ui-react';
2+
import { getChannelOption } from './helper';
33
import React from 'react';
44

55
export function renderText(text, limit) {
@@ -16,7 +16,15 @@ export function renderGroup(group) {
1616
let groups = group.split(',');
1717
groups.sort();
1818
return (
19-
<>
19+
<div
20+
style={{
21+
display: 'flex',
22+
alignItems: 'center',
23+
flexWrap: 'wrap',
24+
gap: '2px',
25+
rowGap: '6px',
26+
}}
27+
>
2028
{groups.map((group) => {
2129
if (group === 'vip' || group === 'pro') {
2230
return <Label color='yellow'>{group}</Label>;
@@ -25,7 +33,7 @@ export function renderGroup(group) {
2533
}
2634
return <Label>{group}</Label>;
2735
})}
28-
</>
36+
</div>
2937
);
3038
}
3139

@@ -106,8 +114,8 @@ export function renderChannelTip(channelId) {
106114
return <></>;
107115
}
108116
return (
109-
<Message>
110-
<div dangerouslySetInnerHTML={{__html: channel.tip}}></div>
111-
</Message>
117+
<Message>
118+
<div dangerouslySetInnerHTML={{ __html: channel.tip }}></div>
119+
</Message>
112120
);
113121
}

0 commit comments

Comments
 (0)