Skip to content

Commit 7943200

Browse files
authored
feat(spx-gui): uITag adapted for the new UI specification (#2585)
* feat(spx-giu): ui-tag adapted for the new UI specification * refactor(spx-gui): enhance UITag with checkable functionality * refactor(spx-gui): beta tag to UITag * refactor(spx-gui): merge checkable and checked into a single object prop * docs(spx-gui): added comments to the UIChip and UITag components
1 parent aa76141 commit 7943200

File tree

13 files changed

+513
-128
lines changed

13 files changed

+513
-128
lines changed

spx-gui/src/components/asset/library/AssetLibraryModal.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
</template>
2121
<section class="body">
2222
<div class="sider">
23-
<UITag
23+
<UIChip
2424
:type="category.value === categoryPersonal.value ? 'primary' : 'boring'"
2525
@click="handleSelectCategory(categoryPersonal)"
2626
>
2727
{{ $t(categoryPersonal.message) }}
28-
</UITag>
28+
</UIChip>
2929
<UIDivider />
30-
<UITag
30+
<UIChip
3131
v-for="c in categories"
3232
:key="c.value"
3333
:type="c.value === category.value ? 'primary' : 'boring'"
3434
@click="handleSelectCategory(c)"
3535
>
3636
{{ $t(c.message) }}
37-
</UITag>
37+
</UIChip>
3838
</div>
3939
<main class="main">
4040
<h3 class="title">{{ $t(category.message) }}</h3>
@@ -85,7 +85,7 @@
8585

8686
<script lang="ts" setup>
8787
import { computed, ref, shallowReactive, shallowRef, watch } from 'vue'
88-
import { UITextInput, UIIcon, UITag, UIPagination, UIButton, UISearchableModal, UIDivider } from '@/components/ui'
88+
import { UITextInput, UIIcon, UIChip, UIPagination, UIButton, UISearchableModal, UIDivider } from '@/components/ui'
8989
import { listAsset, AssetType, type AssetData, Visibility } from '@/apis/asset'
9090
import { debounce } from 'lodash'
9191
import { useMessageHandle } from '@/utils/exception'

spx-gui/src/components/asset/library/management/AssetLibraryManagementModal.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { listAsset, AssetType, type AssetData, Visibility, updateAsset, deleteAs
88
import {
99
UITextInput,
1010
UIIcon,
11-
UITag,
11+
UIChip,
1212
UIPagination,
1313
UISearchableModal,
1414
useModal,
@@ -196,14 +196,14 @@ const handleRemove = useMessageHandle(
196196
</template>
197197
<section class="body">
198198
<div class="sider">
199-
<UITag
199+
<UIChip
200200
v-for="c in categories"
201201
:key="c.value"
202202
:type="c.value === category.value ? 'primary' : 'boring'"
203203
@click="handleSelectCategory(c)"
204204
>
205205
{{ $t(c.message) }}
206-
</UITag>
206+
</UIChip>
207207
</div>
208208
<main class="main">
209209
<h3 class="title">{{ $t(category.message) }}</h3>

spx-gui/src/components/editor/common/AnglePicker.vue

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useDraggableAngleForElement } from '@/utils/dom'
44
import { makeArcPathString } from '@/utils/svg'
55
import { nomalizeDegree, useDebouncedModel } from '@/utils/utils'
66
import { specialDirections } from '@/utils/spx'
7+
import { UITag } from '@/components/ui'
78
89
const props = defineProps<{
910
modelValue: number
@@ -30,14 +31,14 @@ watch(angle, (v) => (modelValue.value = nomalizeDegree(v)))
3031

3132
<template>
3233
<div class="angle-picker">
33-
<!-- TODO: temporary, will be handled uniformly after the tag design specification is complete -->
34-
<span
34+
<UITag
3535
v-for="direction in specialDirections"
3636
:key="direction.name"
37-
class="text"
38-
:class="[direction.name.toLowerCase(), { active: modelValue === direction.value }]"
37+
:class="[direction.name.toLowerCase()]"
38+
:checkable="{ checked: modelValue === direction.value }"
39+
variant="none"
3940
@click="modelValue = direction.value"
40-
>{{ direction.name }}</span
41+
>{{ direction.name }}</UITag
4142
>
4243
<svg
4344
ref="svgEl"
@@ -131,18 +132,6 @@ watch(angle, (v) => (modelValue.value = nomalizeDegree(v)))
131132
text-align: center;
132133
}
133134
134-
.text {
135-
font-size: 12px;
136-
color: var(--ui-color-grey-900);
137-
width: fit-content;
138-
cursor: pointer;
139-
140-
&.active,
141-
&:hover {
142-
color: var(--ui-color-turquoise-500);
143-
}
144-
}
145-
146135
.picker {
147136
grid-column: 2;
148137
grid-row: 2;
366 Bytes
Loading

spx-gui/src/components/editor/navbar/EditorNavbar.vue

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@
2626
<span class="item-text">
2727
{{ $t({ en: 'Import Scratch project file...', zh: '导入 Scratch 项目文件...' }) }}
2828
</span>
29-
<!-- TODO: temporary, will be handled uniformly after the tag design specification is complete -->
30-
<div class="beta">Beta</div>
29+
<UITag>Beta</UITag>
3130
</UIMenuItem>
3231
<UIMenuItem @click="handleImportAssetsFromScratch">
3332
<template #icon><img :src="importAssetsScratchSvg" /></template>
@@ -144,7 +143,8 @@ import {
144143
useConfirmDialog,
145144
useMessage,
146145
UIButtonGroup,
147-
UIButtonGroupItem
146+
UIButtonGroupItem,
147+
UITag
148148
} from '@/components/ui'
149149
import { useMessageHandle } from '@/utils/exception'
150150
import { useI18n, type LocaleMessage } from '@/utils/i18n'
@@ -397,18 +397,6 @@ const autoSaveStateIcon = computed<AutoSaveStateIcon | null>(() => {
397397
flex: 1;
398398
margin-right: 8px;
399399
}
400-
401-
.beta {
402-
margin-left: 24px;
403-
height: 20px;
404-
border-radius: 4px;
405-
border: 1px solid var(--ui-color-grey-400);
406-
background: var(--ui-color-grey-300);
407-
padding: 0 8px;
408-
font-size: 12px;
409-
line-height: 20px;
410-
color: var(--ui-color-grey-900);
411-
}
412400
}
413401
414402
.owner-info,
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<template>
2+
<button class="ui-chip" :class="`type-${type}`">
3+
<slot></slot>
4+
</button>
5+
</template>
6+
7+
<script setup lang="ts">
8+
export type ChipType = 'primary' | 'boring'
9+
10+
defineProps<{
11+
type: ChipType
12+
}>()
13+
</script>
14+
15+
<style lang="scss" scoped>
16+
.ui-chip {
17+
display: flex;
18+
width: fit-content;
19+
align-items: center;
20+
height: 32px; // TODO: support different sizes
21+
padding: 0 16px;
22+
color: var(--ui-color-grey-100);
23+
background: var(--ui-color-grey-600);
24+
border: 1px solid var(--ui-color-grey-600);
25+
border-radius: var(--ui-border-radius-2);
26+
cursor: pointer;
27+
white-space: nowrap;
28+
transition: 0.3s;
29+
30+
&.type-primary {
31+
color: var(--ui-color-grey-100);
32+
background: var(--ui-color-primary-main);
33+
border-color: var(--ui-color-primary-main);
34+
}
35+
36+
&.type-boring {
37+
color: var(--ui-color-grey-900);
38+
background: var(--ui-color-grey-300);
39+
border-color: var(--ui-color-grey-300);
40+
}
41+
}
42+
</style>

0 commit comments

Comments
 (0)