Skip to content

Commit

Permalink
Merge pull request #203 from l3vels/feat/focus-mode
Browse files Browse the repository at this point in the history
Feat: Focus mode
  • Loading branch information
Chkhikvadze authored Oct 4, 2023
2 parents 53dd6e8 + a03643a commit 0d868e4
Show file tree
Hide file tree
Showing 12 changed files with 250 additions and 113 deletions.
2 changes: 2 additions & 0 deletions apps/ui/src/@types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ declare module '@l3-lib/ui-core/dist/icons/Web'
declare module '@l3-lib/ui-core/dist/icons/StarOutline'
declare module '@l3-lib/ui-core/dist/icons/ShareOutline'
declare module '@l3-lib/ui-core/dist/icons/Share'
declare module '@l3-lib/ui-core/dist/icons/Show'
declare module '@l3-lib/ui-core/dist/icons/Hide'
declare module '@l3-lib/ui-core/dist/icons/Link'
declare module '@l3-lib/ui-core/dist/icons/Download'
declare module '@l3-lib/ui-core/dist/icons/Team'
Expand Down
3 changes: 2 additions & 1 deletion apps/ui/src/components/ChatCards/TeamChatCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export const StyledAgentWrapper = styled.div<{ picked: boolean }>`
gap: 5px;
padding: 10px;
width: 350px;
width: 100%;
max-width: 350px;
/* background: rgba(255, 255, 255, 0.1); */
Expand Down
9 changes: 5 additions & 4 deletions apps/ui/src/components/ChatSwitcher/ChatSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,17 @@ const StyledRoot = styled.div<{ collapsed: boolean; theme: DefaultTheme }>`
position: absolute;
top: 50%;
left: 0;
z-index: 2147483647;
z-index: 2000000;
transform: translateY(-50%);
/* background: red; */
display: flex;
flex-direction: column;
justify-content: center;
height: 80%;
/* height: 80%; */
/* width: 110px; */
padding-right: 10px;
/* margin-left: 20px; */
@keyframes slideAnimation {
from {
left: 0; /* Element slides to the right and is fully visible */
Expand All @@ -226,7 +227,7 @@ const StyledRoot = styled.div<{ collapsed: boolean; theme: DefaultTheme }>`
p.collapsed &&
css`
/* width: 10px; */
left: -100px;
left: -80px;
overflow: hidden;
/* animation: slideAnimation 0.2s ease-in-out; */
Expand Down
16 changes: 8 additions & 8 deletions apps/ui/src/components/ChatSwitcher/useChatSwitcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ export const useChatSwitcher = () => {
}
}, [])

useEffect(() => {
if (expand) {
setShowSwitcher(false)
} else {
setShowSwitcher(true)
}
}, [expand])
// useEffect(() => {
// if (expand) {
// setShowSwitcher(false)
// } else {
// setShowSwitcher(true)
// }
// }, [expand])

const handleMouseLeave = () => {
const clearHoverTimer = () => {
clearTimeout(hoverTimeout)
}
clearHoverTimer()

if (window.innerWidth <= 1000 || expand) {
if (window.innerWidth <= 1000) {
setTimeout(() => {
setShowSwitcher(false)
}, 1000)
Expand Down
97 changes: 66 additions & 31 deletions apps/ui/src/components/HeaderButtons/HeaderButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,58 +10,93 @@ import TwitterLogo from 'assets/tools/twitter.png'
import TypographyPrimary from 'components/Typography/Primary'
import { ButtonTertiary } from 'components/Button/Button'

import Hide from '@l3-lib/ui-core/dist/icons/Hide'
import Show from '@l3-lib/ui-core/dist/icons/Show'
import { useContext } from 'react'
import { LayoutContext } from 'contexts'

export const openLinkTab = (url: string) => {
window.open(url, '_blank')
}

const HeaderButtons = () => {
const { expand, onChangeLayout } = useContext(LayoutContext)

return (
<StyledButtonsWrapper>
<ButtonTertiary
size={Button.sizes.SMALL}
onClick={() => openLinkTab(import.meta.env.REACT_APP_TWITTER_LINK)}
<Tooltip
content={() => <span>Focus Mode</span>}
position={Tooltip.positions.BOTTOM}
tooltipSize='small'
>
<ButtonTertiary size={'small'} onClick={() => onChangeLayout(!expand)}>
{expand ? <Hide size={26} /> : <Show size={26} />}
</ButtonTertiary>
</Tooltip>

<Tooltip
content={() => <span>Twitter</span>}
position={Tooltip.positions.BOTTOM}
tooltipSize='small'
>
<StyledInnerButtonWrapper>
<StyledImageWrapper>
<StyledImg src={TwitterLogo} customScale={1} />
</StyledImageWrapper>
<TypographyPrimary
<ButtonTertiary
size={Button.sizes.SMALL}
onClick={() => openLinkTab(import.meta.env.REACT_APP_TWITTER_LINK)}
>
<StyledInnerButtonWrapper>
<StyledImageWrapper>
<StyledImg src={TwitterLogo} customScale={1} />
</StyledImageWrapper>
{/* <TypographyPrimary
value='Twitter'
type={Typography.types.LABEL}
size={Typography.sizes.sm}
/>
</StyledInnerButtonWrapper>
</ButtonTertiary>
/> */}
</StyledInnerButtonWrapper>
</ButtonTertiary>
</Tooltip>

<ButtonTertiary
size={Button.sizes.SMALL}
onClick={() => openLinkTab(import.meta.env.REACT_APP_DISCORD_LINK)}
<Tooltip
content={() => <span>Discord</span>}
position={Tooltip.positions.BOTTOM}
tooltipSize='small'
>
<StyledInnerButtonWrapper>
<StyledDiscordIcon size='20' />
<TypographyPrimary
<ButtonTertiary
size={Button.sizes.SMALL}
onClick={() => openLinkTab(import.meta.env.REACT_APP_DISCORD_LINK)}
>
<StyledInnerButtonWrapper>
<StyledDiscordIcon size='20' />
{/* <TypographyPrimary
value='Discord'
type={Typography.types.LABEL}
size={Typography.sizes.sm}
/>
</StyledInnerButtonWrapper>
</ButtonTertiary>
/> */}
</StyledInnerButtonWrapper>
</ButtonTertiary>
</Tooltip>

<ButtonTertiary
size={Button.sizes.SMALL}
onClick={() => openLinkTab(import.meta.env.REACT_APP_GITHUB_LINK)}
<Tooltip
content={() => <span>Github</span>}
position={Tooltip.positions.BOTTOM}
tooltipSize='small'
>
<StyledInnerButtonWrapper>
<StyledImageWrapper>
<StyledImg src={githubIcon} />
</StyledImageWrapper>
<TypographyPrimary
<ButtonTertiary
size={Button.sizes.SMALL}
onClick={() => openLinkTab(import.meta.env.REACT_APP_GITHUB_LINK)}
>
<StyledInnerButtonWrapper>
<StyledImageWrapper>
<StyledImg src={githubIcon} />
</StyledImageWrapper>
{/* <TypographyPrimary
value='Github'
type={Typography.types.LABEL}
size={Typography.sizes.sm}
/>
</StyledInnerButtonWrapper>
</ButtonTertiary>
/> */}
</StyledInnerButtonWrapper>
</ButtonTertiary>
</Tooltip>
</StyledButtonsWrapper>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type MemberTextProps = {
}

const MemberText = ({ name, role }: MemberTextProps) => {
const { shortText: shortName } = textSlicer(name, 20)
const { shortText: shortName } = textSlicer(name, 14)

let shortRole
if (role) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,11 @@ const StyledWrapper = styled.div<{ isHidden?: boolean; isReplying?: boolean }>`
display: flex;
flex-direction: column;
justify-content: center;
/* align-items: center; */
align-items: center;
gap: 5px;
padding-top: 10px;
/* margin-right: 50px; */
.visible-reply {
opacity: 1;
}
Expand Down Expand Up @@ -288,10 +288,11 @@ const StyledLoaderWrapper = styled.div`
margin-top: 30px;
width: calc(100% - 50px);
max-width: 850px;
max-width: 800px;
`
const StyledReplyMessageContainer = styled.div`
transition: opacity 1000ms;
/* width: 100%; */
opacity: 0;
height: 30px;
max-height: 30px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export const StyledMessageWrapper = styled.div<{ secondary?: boolean }>`
padding-right: 10px;
min-width: 400px;
width: calc(100% - 100px);
max-width: 850px;
max-width: 800px;
:hover {
.actions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export const StyledReplyWrapper = styled.div`
width: calc(100vw - 100px);
max-width: 850px;
max-width: 800px;
height: 20px;
/* background: red; */
gap: 10px;
Expand Down
47 changes: 13 additions & 34 deletions apps/ui/src/modals/AIChatModal/components/ChatV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { useAgentByIdService } from 'services/agent/useAgentByIdService'

import { useTeamOfAgentsByIdService } from 'services/team/useTeamOfAgentsByIdService'

import ChatMembers from './ChatMembers'
import { ChatStatus, TeamOfAgentsType } from 'types'
import useStopChatService from 'services/chat/useStopChatService'
import { useConfigsService } from 'services/config/useConfigsService'
Expand Down Expand Up @@ -286,10 +285,6 @@ const ChatV2 = () => {

return (
<StyledWrapper>
<StyledMembersWrapper>
<ChatMembers agentById={agentById || chatById?.agent} teamOfAgents={teamOfAgents} />
</StyledMembersWrapper>

<StyledMessages>
<StyledChatWrapper>
<ChatMessageListV2
Expand Down Expand Up @@ -461,7 +456,8 @@ const StyledForm = styled.form`
border-radius: 100px;
/* cursor: pointer; */
width: fit-content;
width: 100%;
max-width: 800px;
min-height: 48px;
height: fit-content;
max-height: 250px;
Expand Down Expand Up @@ -503,14 +499,15 @@ const StyledChatFooter = styled.div`
display: flex;
/* flex-direction: column; */
/* justify-content: center; */
justify-content: center;
width: 100%;
padding: 0 20px;
`

const StyledButtonGroup = styled.div`
display: flex;
/* justify-content: center; */
justify-content: center;
padding: 16px 0;
width: 100%;
Expand All @@ -528,14 +525,14 @@ const StyledChatWrapper = styled.div`
`

const StyledSuggestionsContainer = styled.div`
position: absolute;
display: flex;
width: calc(100vw - 100px);
width: 100%;
max-width: 800px;
align-items: center;
gap: 12px;
overflow-y: scroll;
overflow-x: auto;
::-webkit-scrollbar {
display: none;
Expand All @@ -556,10 +553,11 @@ const StyledFileWrapper = styled.div`
`

const StyledInputWrapper = styled.div<{ secondary?: boolean }>`
width: calc(100vw - 700px);
max-width: 600px;
padding-bottom: 2px;
/* width: calc(100vw - 600px);
max-width: 600px; */
padding-bottom: 2px;
width: 100%;
${p =>
p.secondary &&
css`
Expand All @@ -575,6 +573,7 @@ const StyledChatInputWrapper = styled.div`
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
`
const StyledChatBottom = styled.div`
display: flex;
Expand All @@ -583,23 +582,3 @@ const StyledChatBottom = styled.div`
padding: 0 50px;
width: 100%;
`
const StyledMembersWrapper = styled.div`
position: absolute;
top: 20px;
right: 5px;
border-radius: 23px;
z-index: 12000000;
padding: 10px;
display: flex;
flex-direction: column;
gap: 5px;
/* background: rgba(0, 0, 0, 0.3); */
height: calc(100vh - 240px);
@media only screen and (max-width: 1400px) {
display: none;
}
`
18 changes: 13 additions & 5 deletions apps/ui/src/providers/LayoutProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import React, { useEffect, useState } from 'react'

import { LayoutContext } from 'contexts'
import { useLocation } from 'react-router-dom'
// import { useLocation } from 'react-router-dom'

export const LayoutProvider = ({ children }: any) => {
const [expand, setExpand] = useState(false)
const location = useLocation()
const [expand, setExpand] = useState(localStorage.getItem('expand') === 'true' ? true : false)
// const location = useLocation()

// useEffect(() => {
// setExpand(false)
// }, [location.pathname])

useEffect(() => {
setExpand(false)
}, [location.pathname])
if (expand) {
localStorage.setItem('expand', 'true')
} else {
localStorage.setItem('expand', 'false')
}
}, [expand])

const onChangeLayout = () => setExpand(prevValue => !prevValue)

Expand Down
Loading

0 comments on commit 0d868e4

Please sign in to comment.