Skip to content

Commit f238a92

Browse files
committed
refactor: cleanup sidebar actions
1 parent 42d44f1 commit f238a92

File tree

30 files changed

+274
-127
lines changed

30 files changed

+274
-127
lines changed

packages/metastream-app/src/assets/homescreen.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
<div class="column input-container">
146146
<input
147147
id="urlinput"
148-
placeholder="Or paste any URL (e.g. https://cool.website/video/123)"
148+
placeholder="Or paste any link (e.g. https://cool.website/video/123)"
149149
autocomplete="url"
150150
spellcheck="false"
151151
/>
Lines changed: 4 additions & 4 deletions
Loading
Lines changed: 5 additions & 0 deletions
Loading
Lines changed: 4 additions & 4 deletions
Loading

packages/metastream-app/src/components/GameLobby.tsx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { IReactReduxProps } from 'types/redux-thunk'
2525
import { ChatLocation } from './chat/Location'
2626
import { setPendingMedia } from 'lobby/actions/mediaPlayer'
2727
import { sendMediaRequest, ClientMediaRequestOptions } from 'lobby/actions/media-request'
28+
import { Sidebar } from './sidebar'
2829

2930
interface IProps {
3031
host: boolean
@@ -122,13 +123,7 @@ class _GameLobby extends React.Component<PrivateProps, IState> {
122123

123124
{this.renderControls()}
124125

125-
{this.props.isChatDocked && (
126-
<Chat
127-
theRef={el => (this.chat = el)}
128-
className={styles.chatDocked}
129-
disabled={!!this.state.modal}
130-
/>
131-
)}
126+
{this.props.isChatDocked && <Sidebar className={styles.chatDocked} />}
132127

133128
{this.isInactive && <div className={styles.inactiveOverlay} />}
134129
</div>
@@ -142,20 +137,25 @@ class _GameLobby extends React.Component<PrivateProps, IState> {
142137
<>
143138
{this.renderPlaybackControls()}
144139

145-
<UserList
146-
className={styles.users}
147-
onInvite={() => this.openModal(LobbyModal.SessionSettings)}
148-
/>
149-
<MediaList className={styles.queue} onShowInfo={this.showInfo} />
150-
151140
{!this.props.isChatDocked && (
152-
<Chat
153-
theRef={el => (this.chat = el)}
154-
className={styles.chatFloat}
155-
disabled={!!this.state.modal}
156-
showHint
157-
fade
158-
/>
141+
<>
142+
<UserList
143+
className={styles.users}
144+
onInvite={() => this.openModal(LobbyModal.SessionSettings)}
145+
/>
146+
<MediaList
147+
className={styles.queue}
148+
onOpenMediaBrowser={this.showBrowser}
149+
onShowInfo={this.showInfo}
150+
/>
151+
<Chat
152+
theRef={el => (this.chat = el)}
153+
className={styles.chatFloat}
154+
disabled={!!this.state.modal}
155+
showHint
156+
fade
157+
/>
158+
</>
159159
)}
160160

161161
{this.state.modal && this.renderModal()}
@@ -272,6 +272,10 @@ class _GameLobby extends React.Component<PrivateProps, IState> {
272272
)
273273
}
274274

275+
private showBrowser = () => {
276+
this.openModal(LobbyModal.Browser)
277+
}
278+
275279
private showInfo = (media?: IMediaItem) => {
276280
this.openModal(LobbyModal.MediaInfo, { media })
277281
}

packages/metastream-app/src/components/chat/Chat.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747

4848
.staticBackground {
4949
composes: absolute-full from '~styles/layout.css';
50-
background: var(--color-transparent-dark-66);
5150
}
5251

5352
.foreground {
@@ -68,6 +67,7 @@
6867
composes: scroller from '~styles/layout.css';
6968
max-height: 100%;
7069
flex-grow: 1;
70+
/* align-self: flex-end; */
7171
overflow-y: auto;
7272
position: relative;
7373
cursor: auto;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import * as React from 'react'
2+
import styles from './PanelHeader.css'
3+
import { useDispatch, useSelector } from 'react-redux'
4+
import { setSetting } from 'actions/settings'
5+
import { ChatLocation } from './Location'
6+
import { IAppState } from 'reducers'
7+
import { t } from 'locale'
8+
import { IconButton } from 'components/common/button'
9+
10+
interface Props {
11+
className?: string
12+
}
13+
14+
export const ChatLayoutButton: React.SFC<Props> = ({ className }) => {
15+
const dispatch = useDispatch()
16+
17+
const chatLocation = useSelector<IAppState>(state => state.settings.chatLocation)
18+
const isFloating = chatLocation === ChatLocation.FloatLeft
19+
20+
function toggleChatLayout() {
21+
dispatch(
22+
setSetting('chatLocation', location =>
23+
location === ChatLocation.DockRight ? ChatLocation.FloatLeft : ChatLocation.DockRight
24+
)
25+
)
26+
}
27+
28+
return (
29+
<IconButton
30+
icon={isFloating ? 'dock-right' : 'undock-float'}
31+
iconSize="small"
32+
className={className}
33+
onClick={toggleChatLayout}
34+
title={t(isFloating ? 'uiDockToRight' : 'uiUndock')}
35+
/>
36+
)
37+
}

packages/metastream-app/src/components/chat/index.tsx

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@ import { Messages } from './Messages'
77
import { ChatForm } from './ChatForm'
88

99
import styles from './Chat.css'
10-
import { IconButton } from '../common/button'
11-
import { t } from 'locale'
1210
import { connect } from 'react-redux'
1311
import { IAppState } from 'reducers/index'
1412
import { sendChat, notifyTyping } from 'lobby/actions/chat'
15-
import { setSetting } from 'actions/settings'
16-
import { ChatLocation } from './Location'
1713
import { UserTyping } from './UserTyping'
1814
import { throttle } from 'lodash-es'
1915
import { TYPING_DURATION } from '../../lobby/reducers/chat.helpers'
2016
import { Cancelable } from 'lodash'
17+
import { ChatLayoutButton } from './ChatLayoutButton'
2118

2219
const CSS_PROP_CHAT_FADE_DELAY = '--chat-fade-delay'
2320

@@ -41,7 +38,6 @@ interface ConnectedProps {
4138

4239
interface DispatchProps {
4340
sendMessage(text: string): void
44-
toggleChatLayout(): void
4541
notifyTyping: () => void & Cancelable
4642
}
4743

@@ -170,14 +166,7 @@ export class ChatComponent extends PureComponent<PrivateProps, State> {
170166
>
171167
<UserTyping />
172168
</ChatForm>
173-
{this.props.showDockOption && (
174-
<IconButton
175-
icon={this.props.fade ? 'dock-right' : 'undock-float'}
176-
className={styles.btnLayout}
177-
onClick={this.props.toggleChatLayout}
178-
title={t(this.props.fade ? 'chatDockToRight' : 'chatUndock')}
179-
/>
180-
)}
169+
{this.props.showDockOption && <ChatLayoutButton className={styles.btnLayout} />}
181170
</div>
182171
</div>
183172
</div>
@@ -261,13 +250,6 @@ export const Chat = connect(
261250
},
262251
(dispatch: Function): DispatchProps => ({
263252
sendMessage: (text: string) => dispatch(sendChat(text)),
264-
toggleChatLayout() {
265-
dispatch(
266-
setSetting('chatLocation', location =>
267-
location === ChatLocation.DockRight ? ChatLocation.FloatLeft : ChatLocation.DockRight
268-
)
269-
)
270-
},
271253
notifyTyping: throttle(() => dispatch(notifyTyping()), TYPING_DURATION - 500, {
272254
trailing: false
273255
})

packages/metastream-app/src/components/common/button.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,18 @@
8080
.tooltip {
8181
composes: absolute-full from '~styles/layout.css';
8282
}
83+
84+
.iconButton {
85+
display: flex;
86+
}
87+
88+
.iconChildren {
89+
align-self: center;
90+
text-transform: uppercase;
91+
letter-spacing: 1px;
92+
}
93+
94+
.iconHighlight {
95+
color: var(--color-highlight);
96+
font-weight: bolder;
97+
}

packages/metastream-app/src/components/common/button.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface IIconButtonProps {
88
id?: string
99
icon: string
1010
iconSize?: 'small'
11+
highlight?: boolean
1112

1213
title?: React.ReactNode
1314
tooltipProps?: TooltipProps
@@ -29,11 +30,15 @@ export const IconButton: React.SFC<IIconButtonProps> = ({
2930
title,
3031
tooltipProps,
3132
children,
33+
highlight,
3234
...props
3335
}) => {
3436
return (
3537
<button
3638
type="button"
39+
className={cx(styles.iconButton, props.className, {
40+
[styles.iconHighlight]: highlight
41+
})}
3742
style={
3843
title
3944
? {
@@ -50,7 +55,7 @@ export const IconButton: React.SFC<IIconButtonProps> = ({
5055
) : null}
5156
<Icon name={icon} size={iconSize} pointerEvents="none" />
5257
{!!children && nbsp}
53-
{children ? <span>{children}</span> : undefined}
58+
{children ? <span className={styles.iconChildren}>{children}</span> : undefined}
5459
</button>
5560
)
5661
}

0 commit comments

Comments
 (0)