@@ -21,6 +21,30 @@ const attribute = 'grid-generators';
2121const getCssOrTailwindDropdownElement = getCssOrTailwindDropdown ( attribute ) ;
2222const showCopyClass = 'show-css-tailwind' ;
2323
24+ function areInputsValid ( ) {
25+ const noOfColumns = getNumberOfColumns ( attribute ) ;
26+ const noOfRows = getNumberOfRows ( attribute ) ;
27+
28+ const isColumnInputValid =
29+ noOfColumns . value . length > 0
30+ ? parseInt ( noOfColumns . value ) >= 1 && parseInt ( noOfColumns . value ) <= 100
31+ : true ;
32+ const isRowInputValid =
33+ noOfRows . value . length > 0
34+ ? parseInt ( noOfRows . value ) >= 1 && parseInt ( noOfRows . value ) <= 100
35+ : true ;
36+
37+ if ( isColumnInputValid && isRowInputValid ) return true ;
38+
39+ showPopup (
40+ 'Limit Exceeded' ,
41+ 'The input value should be within 1 and 100.' ,
42+ 'error'
43+ ) ;
44+
45+ return false ;
46+ }
47+
2448export function gridGenerator ( ) : void {
2549 const noOfColumns = getNumberOfColumns ( attribute ) ;
2650 const noOfRows = getNumberOfRows ( attribute ) ;
@@ -44,6 +68,7 @@ export function gridGenerator(): void {
4468 allGridInputFields [ index ] . textContent = `${ input . value } px` ;
4569 }
4670 input . addEventListener ( 'input' , ( ) => {
71+ if ( areInputsValid ( ) === false ) return ;
4772 preview . style . display = 'grid' ;
4873 preview . style . gridTemplateColumns = getGridColValue ( ) ;
4974 preview . style . gridTemplateRows = getGridRowValue ( ) ;
0 commit comments