@@ -12,6 +12,7 @@ type ImageGeneratorForm = {
1212 textColor : Color | undefined ;
1313 tab : 'unsplash' | 'placehold' ;
1414 text : string ;
15+ textSize : number | undefined ;
1516} ;
1617
1718export const DEFAULT_VALUES : ImageGeneratorForm = {
@@ -22,13 +23,19 @@ export const DEFAULT_VALUES: ImageGeneratorForm = {
2223 textColor : new ColorFactory ( '1668dc00' ) ,
2324 tab : 'unsplash' ,
2425 text : '' ,
26+ textSize : undefined ,
2527} ;
2628
27- export const SIZE_LIMIT = {
29+ export const IMG_SIZE_LIMIT = {
2830 min : 1 ,
2931 max : 5000 ,
3032} ;
3133
34+ export const TEXT_SIZE_LIMIT = {
35+ min : 1 ,
36+ max : 999 ,
37+ } ;
38+
3239export const UNSPLASH_FILE_TYPES = [
3340 {
3441 label : 'JPG' ,
@@ -114,13 +121,14 @@ const createUnsplashURL = (values: ImageGeneratorForm) => {
114121
115122// https://placehold.jp/
116123const createPlaceholdURL = ( values : ImageGeneratorForm ) => {
117- const { wight, height, type, textColor, bgColor, text } = values ;
124+ const { wight, height, type, textColor, bgColor, text, textSize } = values ;
125+ const textSizePath = textSize ? '' : `/${ textSize } ` ;
118126 const bgColorPath = bgColor ? `/${ bgColor . toHex ( ) } ` : '' ;
119127 const textColorPath = textColor ? `/${ textColor . toHex ( ) } ` : '' ;
120128
121129 const params = new URLSearchParams ( {
122130 text,
123131 } ) ;
124132
125- return `https://placehold.jp${ bgColorPath } ${ textColorPath } /${ wight } x${ height } .${ type } ?${ params } ` ;
133+ return `https://placehold.jp${ textSizePath } ${ bgColorPath } ${ textColorPath } /${ wight } x${ height } .${ type } ?${ params } ` ;
126134} ;
0 commit comments