File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
routes/editor/LayersPanel/BrandTab/ColorPanel Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { makeAutoObservable } from 'mobx';
9
9
import colors from 'tailwindcss/colors' ;
10
10
import type { EditorEngine } from '..' ;
11
11
import { camelCase } from 'lodash' ;
12
+ import { customAlphabet } from 'nanoid/non-secure' ;
12
13
13
14
interface ColorValue {
14
15
value : string ;
@@ -451,9 +452,10 @@ export class ThemeManager {
451
452
throw new Error ( 'Color not found' ) ;
452
453
}
453
454
// If the color name is a number, we need to add a suffix to the new color name
455
+ const randomId = customAlphabet ( '0123456789' , 5 ) ( ) ;
454
456
const newName = isNaN ( Number ( colorName ) )
455
457
? `${ colorName } Copy`
456
- : `${ colorName } ${ group . length + 1 } ` ;
458
+ : `${ colorName } ${ randomId } ` ;
457
459
458
460
const color = Color . from (
459
461
theme === Theme . DARK
Original file line number Diff line number Diff line change @@ -125,7 +125,9 @@ export const BrandPalletGroup = ({
125
125
} ;
126
126
127
127
const generateUniqueColorName = ( ) => {
128
- const randomId = customAlphabet ( 'abcdefghijklmnopqrstuvwxyz0123456789' , 5 ) ( ) ;
128
+ const randomIdText = customAlphabet ( 'abcdefghijklmnopqrstuvwxyz0123456789' , 5 ) ( ) ;
129
+ const randomIdNumber = customAlphabet ( '0123456789' , 5 ) ( ) ;
130
+ const randomId = isNaN ( Number ( title ) ) ? randomIdText : randomIdNumber ;
129
131
return `${ title } ${ randomId } ` ;
130
132
} ;
131
133
You can’t perform that action at this time.
0 commit comments