updating channel component

This commit is contained in:
Roland Osborne 2024-02-15 23:40:23 -08:00
parent a6970986d1
commit 19f01c57c5
8 changed files with 89 additions and 40 deletions

View File

@ -41,7 +41,9 @@ export const LightTheme = {
headerArea: '#f2f2f2', headerArea: '#f2f2f2',
footerArea: '#f2f2f2', footerArea: '#f2f2f2',
itemArea: '#f8f8f8', itemArea: '#f8f8f8',
inputArea: '#ffffff',
hoverArea: '#efefef', hoverArea: '#efefef',
noticeArea: '#8fbea7',
selectedArea: '#e8e8e8', selectedArea: '#e8e8e8',
enabledArea: '#448866', enabledArea: '#448866',
disabledArea: '#cccccc', disabledArea: '#cccccc',
@ -53,16 +55,19 @@ export const LightTheme = {
linkText: '#448866', linkText: '#448866',
labelText: '#888888', labelText: '#888888',
alertText: '#ff8888', alertText: '#ff8888',
itemLine: '#eeeeee', itemBorder: '#eeeeee',
sectionLine: '#dddddd', inputBorder: '#888888',
headerLine: '#aaaaaa', sectionBorder: '#dddddd',
headerBorder: '#aaaaaa',
}; };
export const DarkTheme = { export const DarkTheme = {
headerArea: '#111111', headerArea: '#111111',
footerArea: '#111111', footerArea: '#111111',
itemArea: '#222222', itemArea: '#222222',
inputArea: '#000000',
hoverArea: '#2f2f2f', hoverArea: '#2f2f2f',
noticeArea: '#8fbea7',
selectedArea: '#333333', selectedArea: '#333333',
enabledArea: '#448866', enabledArea: '#448866',
disabledArea: '#888888', disabledArea: '#888888',
@ -74,8 +79,9 @@ export const DarkTheme = {
linkText: '#448866', linkText: '#448866',
labelText: '#dddddd', labelText: '#dddddd',
alertText: '#ff8888', alertText: '#ff8888',
itemLine: '#555555', itemBorder: '#555555',
sectionLine: '#777777', inputBorder: '#aaaaaa',
headerLine: '#aaaaaa', sectionBorder: '#777777',
headerBorder: '#aaaaaa',
}; };

View File

@ -9,6 +9,11 @@ export const en = {
allDevices: 'Logout of all devices', allDevices: 'Logout of all devices',
ok: 'OK', ok: 'OK',
cancel: 'Cancel', cancel: 'Cancel',
newMessage: 'New Message',
topics: 'Topics',
unsetSealing: 'Unset Sealing Key',
newTopic: 'New Topic',
}; };
export const fr = { export const fr = {
@ -22,5 +27,10 @@ export const fr = {
allDevices: 'Déconnexion de tous les appareils', allDevices: 'Déconnexion de tous les appareils',
ok: 'OK', ok: 'OK',
cancel: 'Annuler', cancel: 'Annuler',
newMessage: 'Nouveau Message',
topics: 'Sujets',
unsetSealing: 'Clé de sécurité non définie',
newTopic: 'Nouveau Sujet',
}; };

View File

@ -16,38 +16,38 @@ export function Channels({ open, active }) {
return ( return (
<ChannelsWrapper> <ChannelsWrapper>
<div class="search"> <div className="search">
<div class="filter"> <div className="filter">
<Input bordered={false} allowClear={true} placeholder="Topics" prefix={<SearchOutlined />} <Input className="filterControl" bordered={false} allowClear={true} placeholder={state.strings.topics} prefix={<SearchOutlined />}
spellCheck="false" onChange={(e) => actions.onFilter(e.target.value)} /> spellCheck="false" onChange={(e) => actions.onFilter(e.target.value)} />
</div> </div>
{ state.display === 'small' && ( { state.display === 'small' && (
<div class="inline"> <div className="inline">
<Button type="primary" disabled={!state.allowAdd} icon={<CommentOutlined />} onClick={actions.setShowAdd}>New</Button> <Button type="primary" disabled={!state.allowAdd} icon={<CommentOutlined />} onClick={actions.setShowAdd}>New</Button>
</div> </div>
)} )}
</div> </div>
<div class="view"> <div className="view">
{ state.channels.length > 0 && ( { state.channels.length > 0 && (
<List local={{ emptyText: '' }} itemLayout="horizontal" dataSource={state.channels} gutter="0" <List local={{ emptyText: '' }} itemLayout="horizontal" dataSource={state.channels} gutter="0"
renderItem={item => ( renderItem={item => (
<ChannelItem item={item} openChannel={open} <ChannelItem item={item} openChannel={open} tip={state.strings.newMessage}
active={active.card === item.cardId && active.channel === item.channelId} /> active={active.card === item.cardId && active.channel === item.channelId} />
)} )}
/> />
)} )}
{ state.channels.length === 0 && ( { state.channels.length === 0 && (
<div class="empty">No Topics</div> <div className="empty">No Topics</div>
)} )}
</div> </div>
{ state.display !== 'small' && ( { state.display !== 'small' && (
<div class="bar"> <div className="bar">
<Tooltip placement="right" title={ state.allowAdd ? '' : 'Account Sealing Key Required' }> <Tooltip placement="right" title={ state.allowAdd ? '' : state.strings.unsetSealing }>
<Button type="primary" disabled={!state.allowAdd} icon={<CommentOutlined />} onClick={actions.setShowAdd}>New Topic</Button> <Button className={state.allowAdd ? 'addEnabled' : 'addDisabled'} type="primary" disabled={!state.allowAdd} icon={<CommentOutlined />} onClick={actions.setShowAdd}>{state.strings.newTopic}</Button>
</Tooltip> </Tooltip>
</div> </div>
)} )}
<Modal bodyStyle={{ padding: 16 }} title="New Topic" centered visible={state.showAdd && state.allowAdd} footer={null} destroyOnClose={true} <Modal bodyStyle={{ padding: 16 }} title={state.strings.newTopic} centered visible={state.showAdd && state.allowAdd} footer={null} destroyOnClose={true}
onCancel={actions.clearShowAdd}> onCancel={actions.clearShowAdd}>
<AddChannel added={added} cancelled={actions.clearShowAdd} /> <AddChannel added={added} cancelled={actions.clearShowAdd} />
</Modal> </Modal>

View File

@ -6,7 +6,7 @@ export const ChannelsWrapper = styled.div`
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
background-color: ${Colors.formFocus}; background-color: ${props => props.theme.itemArea};
.view { .view {
min-height: 0; min-height: 0;
@ -18,7 +18,7 @@ export const ChannelsWrapper = styled.div`
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-style: italic; font-style: italic;
color: ${Colors.grey}; color: ${props => props.theme.hintText};
height: 100%; height: 100%;
} }
} }
@ -28,16 +28,30 @@ export const ChannelsWrapper = styled.div`
padding-bottom: 8px; padding-bottom: 8px;
padding-left: 16px; padding-left: 16px;
padding-right: 16px; padding-right: 16px;
border-bottom: 1px solid ${Colors.divider}; border-bottom: 1px solid ${props => props.theme.sectionBorder};
display: flex; display: flex;
flex-direction: row; flex-direction: row;
height: 48px; height: 48px;
.filter { .filter {
border: 1px solid ${Colors.divider}; border: 1px solid ${props => props.theme.sectionBorder};
background-color: ${Colors.white}; background-color: ${props => props.theme.inputArea};
border-radius: 8px; border-radius: 8px;
flex-grow: 1; flex-grow: 1;
.filterControl {
color: ${props => props.theme.mainText};
input {
padding-left: 4px;
color: ${props => props.theme.mainText};
}
input::placeholder {
color: ${props => props.theme.placeholderText};
}
}
} }
.inline { .inline {
@ -60,18 +74,34 @@ export const ChannelsWrapper = styled.div`
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
background-color: ${Colors.formBackground}; background-color: ${props => props.theme.headerArea};
border-top: 1px solid ${Colors.divider}; border-top: 1px solid ${props => props.theme.sectionBorder};
padding-bottom: 10px; padding-bottom: 10px;
padding-top: 10px; padding-top: 10px;
position: relative; position: relative;
} }
.add { .addDisabled {
background-color: ${props => props.theme.disabledArea};
button {
color: ${props => props.theme.idleText};
}
}
.addEnabled {
background-color: ${props => props.theme.enabledArea};
button {
color: ${props => props.theme.activeText};
}
}
.adding {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
background-color: ${Colors.primary}; background-color: ${props => props.theme.enabledArea};
color: ${Colors.white}; color: ${props => props.theme.activeText};
align-items: center; align-items: center;
justify-content: center; justify-content: center;
padding-left: 16px; padding-left: 16px;

View File

@ -3,7 +3,7 @@ import { ChannelItemWrapper, Markup } from './ChannelItem.styled';
import { Logo } from 'logo/Logo'; import { Logo } from 'logo/Logo';
import { UnlockOutlined, LockFilled } from '@ant-design/icons'; import { UnlockOutlined, LockFilled } from '@ant-design/icons';
export function ChannelItem({ item, openChannel, active }) { export function ChannelItem({ item, openChannel, active, tip }) {
return ( return (
<ChannelItemWrapper onClick={() => openChannel(item.channelId, item.cardId)}> <ChannelItemWrapper onClick={() => openChannel(item.channelId, item.cardId)}>
@ -25,7 +25,7 @@ export function ChannelItem({ item, openChannel, active }) {
<div class="message">{ item.message }</div> <div class="message">{ item.message }</div>
</div> </div>
{ item.updatedFlag && ( { item.updatedFlag && (
<Tooltip placement="topRight" title="New Message"> <Tooltip placement="topRight" title={tip}>
<Markup /> <Markup />
</Tooltip> </Tooltip>
)} )}

View File

@ -6,17 +6,18 @@ export const ChannelItemWrapper = styled.div`
width: 100%; width: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
border-bottom: 1px solid ${Colors.itemDivider}; border-bottom: 1px solid ${props => props.theme.itemBorder};
color: ${props => props.theme.mainText};
line-height: 16px; line-height: 16px;
cursor: pointer; cursor: pointer;
overflow: hidden; overflow: hidden;
&:hover { &:hover {
background-color: ${Colors.formHover}; background-color: ${props => props.theme.hoverArea};
} }
.active { .active {
background-color: ${Colors.profileForm}; background-color: ${props => props.theme.selectedArea};
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
@ -48,7 +49,7 @@ export const ChannelItemWrapper = styled.div`
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
border: 1px solid ${Colors.grey}; border: 1px solid ${props => props.theme.itemBorder};
width: 32px; width: 32px;
height: 32px; height: 32px;
border-radius: 4px; border-radius: 4px;
@ -74,7 +75,7 @@ export const ChannelItemWrapper = styled.div`
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
color: ${Colors.disabled}; color: ${props => props.theme.hintText};
} }
} }
} }
@ -84,7 +85,7 @@ export const Markup = styled.div`
position: absolute; position: absolute;
right: 0; right: 0;
border-radius: 8px; border-radius: 8px;
background-color: ${Colors.background}; background-color: ${props => props.theme.noticeArea};
width: 8px; width: 8px;
height: 8px; height: 8px;
margin-right: 8px; margin-right: 8px;

View File

@ -17,6 +17,7 @@ export function useChannels() {
channels: [], channels: [],
showAdd: false, showAdd: false,
allowAdd: false, allowAdd: false,
strings: {},
}); });
const profile = useContext(ProfileContext); const profile = useContext(ProfileContext);
@ -264,8 +265,9 @@ export function useChannels() {
}, [account.state, store.state, card.state, channel.state, filter]); }, [account.state, store.state, card.state, channel.state, filter]);
useEffect(() => { useEffect(() => {
updateState({ display: settings.state.display }); const { display, strings } = settings.state;
}, [settings]); updateState({ display, strings });
}, [settings.state]);
const actions = { const actions = {
onFilter: (value) => { onFilter: (value) => {

View File

@ -9,7 +9,7 @@ export const IdentityWrapper = styled.div`
padding-left: 16px; padding-left: 16px;
padding-right: 16px; padding-right: 16px;
background-color: ${props => props.theme.headerArea}; background-color: ${props => props.theme.headerArea};
border-bottom: 1px solid ${props => props.theme.sectionLine}; border-bottom: 1px solid ${props => props.theme.sectionBorder};
color: ${props => props.theme.mainText}; color: ${props => props.theme.mainText};
flex-shrink: 0; flex-shrink: 0;
@ -26,7 +26,7 @@ export const IdentityWrapper = styled.div`
padding-left: 4px; padding-left: 4px;
padding-right: 4px; padding-right: 4px;
border-radius: 8px; border-radius: 8px;
border: 1px solid ${props => props.theme.sectionLine}; border: 2px solid ${props => props.theme.sectionBorder};
color: ${props => props.theme.mainText}; color: ${props => props.theme.mainText};
} }