11import { React } from "react" ;
2- import { Button , FormLabel } from "react-bootstrap" ;
2+ import { Button , FormLabel , Row , Col } from "react-bootstrap" ;
33import { useTranslation } from "react-i18next" ;
44import { useNavigate } from "react-router-dom" ;
55import PropTypes from "prop-types" ;
66import Form from "react-bootstrap/Form" ;
77import LoadingComponent from "../util/loading-component/loading-component" ;
88import FormInputArea from "../util/forms/form-input-area" ;
99import ContentBody from "../util/content-body/content-body" ;
10- import ContentFooter from "../util/content-footer/content-footer" ;
1110import FormInput from "../util/forms/form-input" ;
1211import ImageUploader from "../util/image-uploader/image-uploader" ;
12+ import StickyFooter from "../util/sticky-footer" ;
1313
1414/**
1515 * The theme form component.
@@ -26,81 +26,94 @@ import ImageUploader from "../util/image-uploader/image-uploader";
2626function ThemeForm ( {
2727 handleInput,
2828 handleSubmit,
29+ handleSaveNoClose,
2930 headerText,
3031 isLoading = false ,
3132 loadingMessage = "" ,
3233 theme = null ,
3334} ) {
34- const { t } = useTranslation ( "common" ) ;
35+ const { t } = useTranslation ( "common" , { keyPrefix : "theme-form" } ) ;
3536 const navigate = useNavigate ( ) ;
3637
3738 return (
38- < >
39+ < div >
40+ < LoadingComponent
41+ isLoading = { isLoading }
42+ loadingMessage = { loadingMessage }
43+ />
3944 < Form >
40- < LoadingComponent
41- isLoading = { isLoading }
42- loadingMessage = { loadingMessage }
43- />
44- < h1 id = "themeTitle" > { headerText } </ h1 >
45- < ContentBody >
46- < FormInput
47- name = "title"
48- type = "text"
49- label = { t ( "theme-form.theme-name-label" ) }
50- value = { theme . title }
51- onChange = { handleInput }
52- />
53- < FormInputArea
54- name = "description"
55- type = "text"
56- label = { t ( "theme-form.theme-description-label" ) }
57- value = { theme . description }
58- onChange = { handleInput }
59- />
60- </ ContentBody >
61- < ContentBody >
62- < h2 className = "h4" > { t ( "theme-form.css-header" ) } </ h2 >
63- < FormInputArea
64- name = "cssStyles"
65- type = "text"
66- label = { t ( "theme-form.theme-css-label" ) }
67- value = { theme . cssStyles }
68- onChange = { handleInput }
69- />
70- < FormLabel htmlFor = "logo" className = "mt-5" >
71- { t ( "theme-form.logo-title" ) }
72- </ FormLabel >
73- < ImageUploader
74- multipleImages = { false }
75- handleImageUpload = { handleInput }
76- inputImage = { theme . logo }
77- name = "logo"
78- showLibraryButton
79- />
80- </ ContentBody >
81- < ContentFooter >
45+ < Row className = "m-2" >
46+ < h1 id = "themeTitle" > { headerText } </ h1 >
47+ < Col >
48+ < ContentBody >
49+ < FormInput
50+ name = "title"
51+ type = "text"
52+ label = { t ( "theme-name-label" ) }
53+ value = { theme . title }
54+ onChange = { handleInput }
55+ />
56+ < FormInputArea
57+ name = "description"
58+ type = "text"
59+ label = { t ( "theme-description-label" ) }
60+ value = { theme . description }
61+ onChange = { handleInput }
62+ />
63+ </ ContentBody >
64+ < ContentBody >
65+ < h2 className = "h4" > { t ( "css-header" ) } </ h2 >
66+ < FormInputArea
67+ name = "cssStyles"
68+ type = "text"
69+ label = { t ( "theme-css-label" ) }
70+ value = { theme . cssStyles }
71+ onChange = { handleInput }
72+ />
73+ < FormLabel htmlFor = "logo" className = "mt-5" >
74+ { t ( "logo-title" ) }
75+ </ FormLabel >
76+ < ImageUploader
77+ multipleImages = { false }
78+ handleImageUpload = { handleInput }
79+ inputImage = { theme . logo ?? null }
80+ name = "logo"
81+ showLibraryButton
82+ />
83+ </ ContentBody >
84+ </ Col >
85+ </ Row >
86+
87+ < StickyFooter >
8288 < Button
8389 variant = "secondary"
8490 type = "button"
8591 id = "cancel_theme"
8692 onClick = { ( ) => navigate ( "/themes/list" ) }
87- size = "lg"
8893 className = "margin-right-button"
8994 >
90- { t ( "theme-form.cancel-button" ) }
95+ { t ( "cancel-button" ) }
96+ </ Button >
97+ < Button
98+ variant = "outline-primary"
99+ type = "button"
100+ id = "save_without_close"
101+ onClick = { handleSaveNoClose }
102+ className = "margin-right-button"
103+ >
104+ { t ( "save-without-close-button" ) }
91105 </ Button >
92106 < Button
93107 variant = "primary"
94108 type = "button"
95109 onClick = { handleSubmit }
96110 id = "save_theme"
97- size = "lg"
98111 >
99- { t ( "theme-form. save-button" ) }
112+ { t ( "save-button" ) }
100113 </ Button >
101- </ ContentFooter >
114+ </ StickyFooter >
102115 </ Form >
103- </ >
116+ </ div >
104117 ) ;
105118}
106119
@@ -113,6 +126,7 @@ ThemeForm.propTypes = {
113126 } ) ,
114127 handleInput : PropTypes . func . isRequired ,
115128 handleSubmit : PropTypes . func . isRequired ,
129+ handleSaveNoClose : PropTypes . func . isRequired ,
116130 headerText : PropTypes . string . isRequired ,
117131 isLoading : PropTypes . bool ,
118132 loadingMessage : PropTypes . string ,
0 commit comments