File tree Expand file tree Collapse file tree
packages/imagekit-editor-dev/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ import { useTemplateStorage } from "../../context/TemplateStorageContext"
3636import type { TemplateRecord } from "../../storage"
3737import { applyTemplateStorageAccessFailure } from "../../storage/templateAccessError"
3838import { useEditorStore } from "../../store"
39+ import { truncateTemplateName } from "../../utils"
3940
4041const MAX_VISIBLE = 5
4142
@@ -351,8 +352,9 @@ export function TemplatesDropdown({
351352 fontWeight = "medium"
352353 isTruncated
353354 color = "blue.800"
355+ title = { templateName }
354356 >
355- { templateName }
357+ { truncateTemplateName ( templateName ) }
356358 </ Text >
357359 < Badge colorScheme = "blue" fontSize = "xs" flexShrink = { 0 } >
358360 Current
@@ -413,8 +415,9 @@ export function TemplatesDropdown({
413415 fontWeight = "medium"
414416 isTruncated
415417 color = "editorBattleshipGrey.800"
418+ title = { record . name }
416419 >
417- { record . name }
420+ { truncateTemplateName ( record . name ) }
418421 </ Text >
419422
420423 { /* Creator on hover + pin (always visible for pinned, hover for others) */ }
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ import { useTemplateStorage } from "../../context/TemplateStorageContext"
3737import { useDebounce } from "../../hooks/useDebounce"
3838import type { TemplateRecord } from "../../storage"
3939import { useEditorStore } from "../../store"
40+ import { truncateTemplateName } from "../../utils"
4041import FilterChipsField from "../common/FilterChipsField"
4142import MultiSelectListField from "../common/MultiSelectListField"
4243import { SettingsModal } from "../header/SettingsModal"
@@ -605,8 +606,9 @@ function TemplateRow({
605606 fontWeight = "medium"
606607 color = { isCurrent ? "blue.800" : "editorBattleshipGrey.700" }
607608 isTruncated
609+ title = { record . name }
608610 >
609- { record . name }
611+ { truncateTemplateName ( record . name ) }
610612 </ Text >
611613 { isCurrent && (
612614 < Badge colorScheme = "blue" fontSize = "xs" flexShrink = { 0 } >
Original file line number Diff line number Diff line change 11export const __DEV__ = process . env . NODE_ENV !== "production"
22
33export const SIMPLE_OVERLAY_TEXT_REGEX = / ^ [ a - z A - Z 0 - 9 - ._ ] * $ /
4+ export const TEMPLATE_NAME_UI_MAX_LENGTH = 30
45
56export const safeBtoa = ( str : string ) : string => {
67 if ( typeof window !== "undefined" ) {
@@ -93,3 +94,10 @@ export const extractImagePath = (imageUrl: string): string => {
9394 return segments [ 0 ] || ""
9495 }
9596}
97+
98+ export const truncateTemplateName = ( name : string ) => {
99+ if ( name . length <= TEMPLATE_NAME_UI_MAX_LENGTH ) {
100+ return name
101+ }
102+ return `${ name . slice ( 0 , TEMPLATE_NAME_UI_MAX_LENGTH ) } ...`
103+ }
You can’t perform that action at this time.
0 commit comments