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

redesign: runner header #435

Merged
merged 3 commits into from
Apr 30, 2024
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
93 changes: 56 additions & 37 deletions spx-gui/src/components/project/runner/RunnerContainer.vue
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
<template>
<div class="container">
<div class="header">
<div>
<div class="header-left"></div>
<div class="project-name">
{{ project?.name }}
</div>
<UITooltip placement="bottom">
<template #trigger>
<button>
<UIIcon type="rotate" @click="handleRerun" />
</button>
</template>
{{ $t({ en: 'Rerun', zh: '重新运行' }) }}
</UITooltip>
<UITooltip placement="bottom">
<template #trigger>
<button>
<UIIcon type="share" @click="handleShare" />
</button>
</template>
{{ $t({ en: 'Share', zh: '分享' }) }}
</UITooltip>
<UIModalClose v-if="mode === 'debug'" class="close" @click="emit('close')" />
<div class="header-right">
<UIButton class="button" icon="rotate" @click="handleRerun">
{{ $t({ en: 'Rerun', zh: '重新运行' }) }}
</UIButton>
<UIButton
class="button"
type="boring"
icon="share"
:loading="handleShare.isLoading.value"
@click="handleShare.fn"
>
{{ $t({ en: 'Share', zh: '分享' }) }}
</UIButton>
<UIModalClose v-if="mode === 'debug'" class="close" @click="emit('close')" />
</div>
</div>
<div :class="['main', displayMode, { expanded }]">
<div class="runner-container">
Expand Down Expand Up @@ -63,7 +62,8 @@ import dayjs from 'dayjs'
import type { Project } from '@/models/project'
import ProjectRunner from './ProjectRunner.vue'
import { useSaveAndShareProject, useShareProject } from '@/components/project'
import { UIIcon, UIModalClose, UITooltip } from '@/components/ui'
import { UIButton, UIIcon, UIModalClose } from '@/components/ui'
import { useMessageHandle } from '@/utils/exception'

const props = defineProps<{ project: Project; mode: 'debug' | 'share' }>()
const emit = defineEmits<{
Expand Down Expand Up @@ -124,13 +124,16 @@ const handleRerun = () => {

const saveAndShareProject = useSaveAndShareProject()
const shareProject = useShareProject()
const handleShare = () => {
if (props.mode === 'debug') {
saveAndShareProject(props.project)
} else {
shareProject(props.project)
}
}
const handleShare = useMessageHandle(
() => {
if (props.mode === 'debug') {
return saveAndShareProject(props.project)
} else {
return shareProject(props.project)
}
},
{ en: 'Failed to share project', zh: '分享项目失败' }
)
</script>
<style lang="scss" scoped>
button {
Expand All @@ -140,15 +143,8 @@ button {
padding: 0;
}

.header button > .ui-icon {
width: 24px;
height: 24px;
color: var(--ui-color-primary-500);
}

.close {
position: absolute;
right: 20px;
transform: scale(1.2);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这么实现的话这个 close 跟两侧的距离都会不准确吧

另外我感觉这个 close btn 的特殊大小应该不是只针对 RunnerContainner 的,而可能是针对 FullScreenModal 的,是的话可以考虑做到 @/components/ui/modal 里;虽然按你现在的抽象方式,不好直接做到 FullScreenModal 里,不过可以把对这个特定 size 的支持先做到 UIModalClose

}

.container {
Expand All @@ -157,19 +153,42 @@ button {
height: 100vh;
overflow: hidden;
}

.header {
display: flex;
justify-content: center;
align-items: center;
gap: 40px;
gap: 32px;
font-size: 16px;
font-weight: 500;
border-bottom: 1px solid var(--ui-color-grey-400);
height: 56px;
position: relative;
color: var(--ui-color-title);
}

.header-left {
flex: 1;
flex-basis: 30%;
}

.project-name {
flex: 1;
flex-basis: 40%;
text-align: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.header-right {
flex: 1;
flex-basis: 30%;
display: flex;
gap: 20px;
justify-content: flex-end;
align-items: center;
padding-right: 20px;
}

.runner-container {
overflow: hidden;
flex: 1;
Expand Down
36 changes: 29 additions & 7 deletions spx-gui/src/components/ui/modal/UIModalClose.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
<template>
<div class="ui-modal-close">
<div :class="['ui-modal-close', `size-${size}`]">
<UIIcon type="close" class="icon" />
</div>
</template>

<script setup lang="ts">
import UIIcon from '../icons/UIIcon.vue'

withDefaults(
defineProps<{
size?: 'medium' | 'large'
}>(),
{
size: 'medium'
}
)
</script>

<style scoped lang="scss">
.ui-modal-close {
width: 28px;
height: 28px;
display: flex;
align-items: center;
justify-content: center;
Expand All @@ -26,10 +33,25 @@ import UIIcon from '../icons/UIIcon.vue'
&:active {
background-color: var(--ui-color-grey-500);
}
}

.icon {
width: 20px;
height: 20px;
&.size-medium {
width: 28px;
height: 28px;

.icon {
width: 20px;
height: 20px;
}
}

&.size-large {
width: 32px;
height: 32px;

.icon {
width: 24px;
height: 24px;
}
}
}
</style>
Loading