mirror of
				https://gitlab.nic.cz/turris/reforis/foris-js.git
				synced 2025-11-03 23:00:31 +01:00 
			
		
		
		
	Button: Fix loading state & button's layout
This commit is contained in:
		@@ -1,5 +1,5 @@
 | 
				
			|||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (C) 2019 CZ.NIC z.s.p.o. (http://www.nic.cz/)
 | 
					 * Copyright (C) 2019-2023 CZ.NIC z.s.p.o. (https://www.nic.cz/)
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * This is free software, licensed under the GNU General Public License v3.
 | 
					 * This is free software, licensed under the GNU General Public License v3.
 | 
				
			||||||
 * See /LICENSE for more information.
 | 
					 * See /LICENSE for more information.
 | 
				
			||||||
@@ -31,24 +31,25 @@ export function Button({
 | 
				
			|||||||
    children,
 | 
					    children,
 | 
				
			||||||
    ...props
 | 
					    ...props
 | 
				
			||||||
}) {
 | 
					}) {
 | 
				
			||||||
    let buttonClass = className ? `btn ${className}` : "btn btn-primary ";
 | 
					    let buttonClass = className ? `btn ${className}` : "btn btn-primary";
 | 
				
			||||||
    if (forisFormSize) {
 | 
					    if (forisFormSize) {
 | 
				
			||||||
        buttonClass = `${buttonClass} col-sm-12 col-md-3 col-lg-2`;
 | 
					        buttonClass = `${buttonClass} col-sm-12 col-md-3 col-lg-2`;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const span = loading ? (
 | 
					 | 
				
			||||||
        <span
 | 
					 | 
				
			||||||
            className="spinner-border spinner-border-sm"
 | 
					 | 
				
			||||||
            role="status"
 | 
					 | 
				
			||||||
            aria-hidden="true"
 | 
					 | 
				
			||||||
        />
 | 
					 | 
				
			||||||
    ) : null;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return (
 | 
					    return (
 | 
				
			||||||
        <button type="button" className={buttonClass} {...props}>
 | 
					        <button
 | 
				
			||||||
            {span}
 | 
					            type="button"
 | 
				
			||||||
            {span ? " " : null}
 | 
					            className={`${buttonClass} d-inline-flex justify-content-center align-items-center`}
 | 
				
			||||||
            {children}
 | 
					            {...props}
 | 
				
			||||||
 | 
					        >
 | 
				
			||||||
 | 
					            {loading && (
 | 
				
			||||||
 | 
					                <span
 | 
				
			||||||
 | 
					                    className="spinner-border spinner-border-sm mr-1"
 | 
				
			||||||
 | 
					                    role="status"
 | 
				
			||||||
 | 
					                    aria-hidden="true"
 | 
				
			||||||
 | 
					                />
 | 
				
			||||||
 | 
					            )}
 | 
				
			||||||
 | 
					            <span>{children}</span>
 | 
				
			||||||
        </button>
 | 
					        </button>
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,3 +31,7 @@
 | 
				
			|||||||
.spinner-fs-wrapper .spinner-text {
 | 
					.spinner-fs-wrapper .spinner-text {
 | 
				
			||||||
    margin: 1rem;
 | 
					    margin: 1rem;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.spinner-border-sm {
 | 
				
			||||||
 | 
					    min-width: 16px;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user