Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project titles, repo listing, and branch name #4367

Merged
merged 6 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 6 additions & 10 deletions editor/src/components/titlebar/buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,23 @@ export const SquareButton: React.FC<React.PropsWithChildren<TitleButtonProps>> =
export const RoundButton: React.FC<React.PropsWithChildren<TitleButtonProps>> = ({
onMouseDown,
onClick,
color,
children,
}) => {
const bgColor = color == null ? {} : { backgroundColor: color }
const ButtonEl = styled(TitleButton)((props) => ({
padding: '3px 12px',
const ButtonEl = styled(TitleButton)(() => ({
padding: '3px',
gap: 5,
height: 24,
borderRadius: 18,
color: colorTheme.bg0.value,
...bgColor,
borderRadius: 20,
}))

return (
<ButtonEl
onClick={onClick}
onMouseDown={onMouseDown}
css={{
height: 20,
width: 20,
'&:hover': {
background: color,
opacity: 0.7,
background: colorTheme.bg3.value,
},
}}
>
Expand Down
178 changes: 82 additions & 96 deletions editor/src/components/titlebar/title-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,14 @@ export const TitleBarProjectTitle = React.memo((props: { panelData: StoredPanel

const dispatch = useDispatch()
const theme = useColorTheme()
const projectName = useEditorState(
Substores.restOfEditor,
(store) => {
return store.editor.projectName
},
'TitleBar projectName',
)
const { upstreamChanges, currentBranch, treeConflicts, repoName } = useEditorState(

const { upstreamChanges, currentBranch, treeConflicts } = useEditorState(
Substores.github,
(store) => {
return {
upstreamChanges: store.editor.githubData.upstreamChanges,
currentBranch: store.editor.githubSettings.branchName,
treeConflicts: store.editor.githubData.treeConflicts,
repoName: githubRepoFullName(store.editor.githubSettings.targetRepository),
}
},
'TitleBar github',
Expand Down Expand Up @@ -172,6 +165,14 @@ export const TitleBarProjectTitle = React.memo((props: { panelData: StoredPanel
setIsHovered(false)
}, [])

const projectName = useEditorState(
Substores.restOfEditor,
(store) => {
return store.editor.projectName
},
'TitleBar projectName',
)

return (
<div
ref={drag}
Expand All @@ -180,88 +181,70 @@ export const TitleBarProjectTitle = React.memo((props: { panelData: StoredPanel
height: TitleHeight,
width: '100%',
backgroundColor: theme.inspectorBackground.value,
paddingLeft: 10,
padding: '0 10px',
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
gap: 10,
flexShrink: 0,
}}
onMouseEnter={setIsHoveredTrue}
onMouseLeave={setIsHoveredFalse}
>
<FlexRow css={{ gap: 6 }}>
<PanelButton onClick={toggleNavigatorVisible} color='#FF5F57' isHovered={isHovered} />
<PanelButton isHovered={isHovered} color={colorTheme.unavailableGrey.value} />
</FlexRow>
<div style={{ display: 'flex', flexDirection: 'column' }}>
<FlexRow css={{ gap: 10, alignItems: 'center' }}>
<FlexRow css={{ gap: 6 }}>
<PanelButton onClick={toggleNavigatorVisible} color='#FF5F57' isHovered={isHovered} />
<PanelButton isHovered={isHovered} color={colorTheme.unavailableGrey.value} />
</FlexRow>
{currentBranch != null ? (
<SimpleFlexRow
onClick={showMergeConflict}
style={{
gap: 5,
scale: hasUpstreamChanges || hasMergeConflicts || hasDownstreamChanges ? '75%' : 1,
transformOrigin: 'left',
gap: 4,
color: hasMergeConflicts ? colorTheme.error.value : colorTheme.fg1.value,
}}
>
{repoName}
{<Icons.Branch style={{ width: 19, height: 19 }} />}
{hasMergeConflicts ? (
<Icons.WarningTriangle style={{ width: 18, height: 18 }} color={'error'} />
) : (
<Icons.Branch style={{ width: 18, height: 18 }} />
)}
{currentBranch}
</SimpleFlexRow>
) : (
<ProjectTitle>{projectName}</ProjectTitle>
)}
{when(
loggedIn,
<div
style={{
display: 'flex',
flexDirection: 'row',
gap: 6,
scale: '75%',
transformOrigin: 'left',
}}
>
{when(
hasUpstreamChanges,
<RoundButton
color={colorTheme.secondaryOrange.value}
onClick={openLeftPaneltoGithubTab}
onMouseDown={onMouseDown}
>
{<Icons.Download style={{ width: 19, height: 19 }} color={'on-light-main'} />}
<>Remote</>
</RoundButton>,
)}
{when(
hasMergeConflicts,
<RoundButton
color={colorTheme.error.value}
onClick={showMergeConflict}
onMouseDown={onMouseDown}
>
{
<Icons.WarningTriangle
style={{ width: 19, height: 19 }}
color={'on-light-main'}
/>
}
<>Merge Conflicts</>
</RoundButton>,
)}
{when(
hasDownstreamChanges,
<RoundButton
color={colorTheme.secondaryBlue.value}
onClick={openLeftPaneltoGithubTab}
onMouseDown={onMouseDown}
>
{<Icons.Upload style={{ width: 19, height: 19 }} color={'on-light-main'} />}
<>Local</>
</RoundButton>,
)}
</div>,
)}
</div>
</FlexRow>
{when(
loggedIn && currentBranch != null,
<FlexRow
css={{
gap: 2,
}}
>
{when(
hasUpstreamChanges,
<RoundButton
color={colorTheme.secondaryOrange.value}
onClick={openLeftPaneltoGithubTab}
onMouseDown={onMouseDown}
>
{<Icons.Download style={{ width: 18, height: 18 }} color={'component-orange'} />}
</RoundButton>,
)}
{when(
hasDownstreamChanges,
<RoundButton
color={colorTheme.secondaryBlue.value}
onClick={openLeftPaneltoGithubTab}
onMouseDown={onMouseDown}
>
{<Icons.Upload style={{ width: 18, height: 18 }} color={'dynamic'} />}
</RoundButton>,
)}
</FlexRow>,
)}
</div>
)
})
Expand Down Expand Up @@ -403,6 +386,17 @@ export const TitleBarCode = React.memo((props: { panelData: StoredPanel }) => {
setIsHovered(false)
}, [])

const { currentBranch, repoName } = useEditorState(
Substores.github,
(store) => {
return {
currentBranch: store.editor.githubSettings.branchName,
repoName: githubRepoFullName(store.editor.githubSettings.targetRepository),
}
},
'TitleBar github',
)

return (
<div
ref={drag}
Expand All @@ -411,20 +405,26 @@ export const TitleBarCode = React.memo((props: { panelData: StoredPanel }) => {
height: 40,
width: '100%',
backgroundColor: theme.inspectorBackground.value,
paddingLeft: 10,
padding: '0 10px',
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
gap: 6,
fontWeight: 600,
gap: 10,
}}
onMouseEnter={setIsHoveredTrue}
onMouseLeave={setIsHoveredFalse}
>
<PanelButton onClick={toggleCodeEditorVisible} color='#FF5F57' isHovered={isHovered} />
<PanelButton onClick={onMinimize} color='#FDBC40' isHovered={isHovered} />
<PanelButton onClick={onMaximize} color='#33C748' isHovered={isHovered} />
<span style={{ marginLeft: 8 }}>Code </span>
<FlexRow css={{ gap: 6 }}>
<PanelButton onClick={toggleCodeEditorVisible} color='#FF5F57' isHovered={isHovered} />
<PanelButton onClick={onMinimize} color='#FDBC40' isHovered={isHovered} />
<PanelButton onClick={onMaximize} color='#33C748' isHovered={isHovered} />
</FlexRow>

{currentBranch != null ? (
<SimpleFlexRow>{repoName}</SimpleFlexRow>
) : (
<span style={{ fontWeight: 600 }}>Code</span>
)}
</div>
)
})
Expand All @@ -438,22 +438,14 @@ const TitleBar = React.memo(() => {
}),
'TitleBar loginState',
)
const projectName = useEditorState(
Substores.restOfEditor,
(store) => {
return store.editor.projectName
},
'TitleBar projectName',
)

const { upstreamChanges, currentBranch, treeConflicts, repoName } = useEditorState(
const { upstreamChanges, currentBranch, treeConflicts } = useEditorState(
Substores.github,
(store) => {
return {
upstreamChanges: store.editor.githubData.upstreamChanges,
currentBranch: store.editor.githubSettings.branchName,
treeConflicts: store.editor.githubData.treeConflicts,
repoName: githubRepoFullName(store.editor.githubSettings.targetRepository),
}
},
'TitleBar github',
Expand Down Expand Up @@ -553,7 +545,6 @@ const TitleBar = React.memo(() => {
onClick={openLeftPaneltoGithubTab}
>
{<Icons.Download style={{ width: 19, height: 19 }} color={'on-light-main'} />}
<>Pull Remote</>
</RoundButton>,
)}
{when(
Expand All @@ -565,7 +556,6 @@ const TitleBar = React.memo(() => {
color={'on-light-main'}
/>
}
<>Merge Conflicts</>
</RoundButton>,
)}
{when(
Expand All @@ -575,7 +565,6 @@ const TitleBar = React.memo(() => {
onClick={openLeftPaneltoGithubTab}
>
{<Icons.Upload style={{ width: 19, height: 19 }} color={'on-light-main'} />}
<>Push Local</>
</RoundButton>,
)}
</>,
Expand All @@ -590,14 +579,11 @@ const TitleBar = React.memo(() => {
}}
>
{currentBranch != null ? (
<SimpleFlexRow style={{ gap: 5, flexShrink: 0 }}>
{repoName}
<SimpleFlexRow style={{ gap: 5 }}>
{<Icons.Branch style={{ width: 19, height: 19 }} />}
{currentBranch}
</SimpleFlexRow>
) : (
<ProjectTitle>{projectName}</ProjectTitle>
)}
) : null}
</SimpleFlexRow>
<div style={{ flexGrow: 1 }} />
<div style={{ flex: '0 0 0px', paddingRight: 8 }}>
Expand Down
Loading