-
Notifications
You must be signed in to change notification settings - Fork 57
[Prototype] Fix sprite item title width #3203
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
base: ui
Are you sure you want to change the base?
Changes from 11 commits
a332165
693c5f5
9d6eaff
9db41ce
611752c
d9b6ea7
d7a0c66
10405d1
da623ca
1f505db
6c31688
ecf6541
96c5443
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,31 @@ | ||
| <template> | ||
| <div :class="rootClass"> | ||
| <span class="min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap" :title="title"> | ||
| <slot></slot> | ||
| </span> | ||
| <slot v-if="slots.suffix != null" name="suffix"></slot> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed, useSlots } from 'vue' | ||
|
|
||
| import { cn, type ClassValue } from '../utils' | ||
|
|
||
| const props = defineProps<{ | ||
| size: 'medium' | 'large' | ||
| title: string | ||
| class?: string | ||
| class?: ClassValue | ||
| }>() | ||
|
|
||
| const slots = useSlots() | ||
| const rootClass = computed(() => [ | ||
| 'flex w-full items-center gap-2 px-1.5 text-center text-title', | ||
| props.size === 'large' ? 'h-5 text-sm' : 'h-5.5 text-2xs', | ||
| props.class | ||
| ]) | ||
| const rootClass = computed(() => | ||
| cn( | ||
| 'flex items-center text-title', | ||
| props.size === 'large' | ||
| ? 'h-5 w-full gap-2 px-1.5 text-center text-sm' | ||
| : ['h-5.5 w-[76px] gap-0.5 px-0 text-2xs', slots.suffix != null ? 'text-left' : 'text-center'], | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
另外在有 suffix(右侧图标)的时候就把文本改成左对齐,这个是预期的改动吗?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已改回用容器宽度和内边距表达,并撤掉按 suffix 改变文本对齐的逻辑。 |
||
| props.class | ||
| ) | ||
| ) | ||
| </script> | ||
|
|
||
| <template> | ||
| <div :class="rootClass"> | ||
| <span class="min-w-0 flex-1 overflow-hidden text-ellipsis whitespace-nowrap" :title="title"> | ||
| <slot></slot> | ||
| </span> | ||
| <slot v-if="slots.suffix != null" name="suffix"></slot> | ||
| </div> | ||
| </template> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| <template> | ||
| <UIBlockItem :active="selected"> | ||
| <div class="mt-0.5 flex min-h-0 w-full flex-col items-center"> | ||
| <img class="h-15 w-20 rounded-[4px] object-cover" :src="imgSrc" :alt="name" /> | ||
| </div> | ||
| <UIBlockItemTitle size="medium" :title="name"> | ||
| {{ name }} | ||
| </UIBlockItemTitle> | ||
| <slot></slot> | ||
| </UIBlockItem> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import UIBlockItem from '@/components/ui/block-items/UIBlockItem.vue' | ||
| import UIBlockItemTitle from '@/components/ui/block-items/UIBlockItemTitle.vue' | ||
|
|
||
| defineProps<{ | ||
| imgSrc: string | ||
| name: string | ||
| selected?: boolean | ||
| }>() | ||
| </script> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <template> | ||
| <!-- eslint-disable-next-line vue/no-v-html --> | ||
| <div :class="rootClass" :data-icon-type="type" v-html="typeIconMap[type]"></div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed } from 'vue' | ||
|
|
||
| import { cn, type ClassValue } from '../utils' | ||
| import eyeOff from './eye-off.svg?raw' | ||
|
|
||
| const typeIconMap = { | ||
| eyeOff | ||
| } | ||
|
|
||
| export type Type = keyof typeof typeIconMap | ||
|
|
||
| const props = defineProps<{ | ||
| type: Type | ||
| class?: ClassValue | ||
| }>() | ||
|
|
||
| const rootClass = computed(() => cn('ui-icon flex h-4 w-4', props.class)) | ||
| </script> | ||
|
|
||
| <style scoped> | ||
| .ui-icon :deep(svg) { | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { twMerge } from 'tailwind-merge' | ||
|
|
||
| export type ClassDictionary = Record<string, boolean | null> | ||
| export type ClassValue = string | ClassDictionary | null | undefined | false | ClassValue[] | ||
|
|
||
| function flattenClassValue(value: ClassValue, tokens: string[]) { | ||
| if (value == null || value === false) return | ||
|
|
||
| if (typeof value === 'string') { | ||
| tokens.push(value) | ||
| return | ||
| } | ||
|
|
||
| if (Array.isArray(value)) { | ||
| for (const item of value) flattenClassValue(item, tokens) | ||
| return | ||
| } | ||
|
|
||
| for (const [className, enabled] of Object.entries(value)) { | ||
| if (enabled === true) tokens.push(className) | ||
| } | ||
| } | ||
|
|
||
| export function cn(...values: ClassValue[]) { | ||
| const tokens: string[] = [] | ||
| for (const value of values) flattenClassValue(value, tokens) | ||
| return twMerge(tokens.join(' ')) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from './cn' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The structural check that
SpriteItem.vueimports and usesUIEditorSpriteItem(rather than duplicating its own hidden-icon layout) was a valid regression guard — the regression it prevented was precisely the one that necessitated PR #3198. It was removed alongside the bad CSS checks, but the two concerns are independent. Worth restoring just the structural checks here: