Skip to content

Commit cc8e14a

Browse files
Input/textarea styles
1 parent e36994c commit cc8e14a

9 files changed

Lines changed: 124 additions & 114 deletions

File tree

src/components/Checkbox/Checkbox.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.fieldset {
1+
.component {
22
display: flex;
33
flex-direction: row;
44
align-items: center;

src/components/Checkbox/Checkbox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
2222
const helperId = `${checkboxId}-helper`
2323

2424
return (
25-
<fieldset className={classes.fieldset}>
25+
<div className={classes.component}>
2626
<div className={classes.checkboxContainer}>
2727
<input
2828
ref={ref}
@@ -51,7 +51,7 @@ export const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>(
5151
{helperText}
5252
</span>
5353
)}
54-
</fieldset>
54+
</div>
5555
)
5656
}
5757
)

src/components/Document/DocumentBlockForm.tsx

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export const DocumentBlockForm = ({
154154
{!isCollapsed && (
155155
<>
156156
{!currentBlockData.id && (
157-
<fieldset>
157+
<fieldset className={classes.fieldset}>
158158
<label htmlFor="block_type">Type</label>
159159
<select
160160
name="type"
@@ -172,41 +172,47 @@ export const DocumentBlockForm = ({
172172
</fieldset>
173173
)}
174174
{['heading2', 'heading3'].includes(currentBlockData.type) && (
175-
<Input
176-
id={`title_${currentBlockData.id}`}
177-
label="Title"
178-
name="title"
179-
type="text"
180-
value={currentBlockData.title || ''}
181-
onChange={handleChange}
182-
required
183-
/>
175+
<fieldset className={classes.fieldset}>
176+
<Input
177+
id={`title_${currentBlockData.id}`}
178+
label="Title"
179+
name="title"
180+
type="text"
181+
value={currentBlockData.title || ''}
182+
onChange={handleChange}
183+
required
184+
/>
185+
</fieldset>
184186
)}
185187
{['paragraph', 'list', 'quote'].includes(currentBlockData.type) && (
186-
<TextArea
187-
id={`content_${currentBlockData.id}`}
188-
label="Content"
189-
name="content"
190-
rows={10}
191-
value={currentBlockData.content}
192-
onChange={(e) => {
193-
setCurrentBlockData({
194-
...currentBlockData,
195-
[e.target.name]: e.target.value,
196-
})
197-
}}
198-
/>
188+
<fieldset className={classes.fieldset}>
189+
<TextArea
190+
id={`content_${currentBlockData.id}`}
191+
label="Content"
192+
name="content"
193+
rows={10}
194+
value={currentBlockData.content}
195+
onChange={(e) => {
196+
setCurrentBlockData({
197+
...currentBlockData,
198+
[e.target.name]: e.target.value,
199+
})
200+
}}
201+
/>
202+
</fieldset>
199203
)}
200204
{['youtube', 'image', 'quote'].includes(currentBlockData.type) && (
201-
<Input
202-
id={`url_${currentBlockData.id}`}
203-
label="URL"
204-
name="url"
205-
type="url"
206-
value={currentBlockData.url || ''}
207-
onChange={handleChange}
208-
placeholder="https://example.com"
209-
/>
205+
<fieldset className={classes.fieldset}>
206+
<Input
207+
id={`url_${currentBlockData.id}`}
208+
label="URL"
209+
name="url"
210+
type="url"
211+
value={currentBlockData.url || ''}
212+
onChange={handleChange}
213+
placeholder="https://example.com"
214+
/>
215+
</fieldset>
210216
)}
211217
<div className={classes.blockActions}>
212218
<Button type="submit">

src/components/Document/DocumentForm.tsx

Lines changed: 55 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -221,33 +221,37 @@ const DocumentForm = ({
221221
return (
222222
<div className={classes.documentFormContainer}>
223223
<form className={classes.documentForm} onSubmit={handleSubmit}>
224-
<Input
225-
id="title"
226-
label="Title"
227-
name="title"
228-
type="text"
229-
required
230-
value={currentDocument.title}
231-
onChange={(e) => {
232-
setCurrentDocument({
233-
...currentDocument,
234-
title: e.target.value,
235-
})
236-
}}
237-
/>
238-
<TextArea
239-
id="description"
240-
label="Description"
241-
name="description"
242-
rows={5}
243-
value={currentDocument.description}
244-
onChange={(e) => {
245-
setCurrentDocument({
246-
...currentDocument,
247-
description: e.target.value,
248-
})
249-
}}
250-
/>
224+
<fieldset className={classes.fieldset}>
225+
<Input
226+
id="title"
227+
label="Title"
228+
name="title"
229+
type="text"
230+
required
231+
value={currentDocument.title}
232+
onChange={(e) => {
233+
setCurrentDocument({
234+
...currentDocument,
235+
title: e.target.value,
236+
})
237+
}}
238+
/>
239+
</fieldset>
240+
<fieldset className={classes.fieldset}>
241+
<TextArea
242+
id="description"
243+
label="Description"
244+
name="description"
245+
rows={5}
246+
value={currentDocument.description}
247+
onChange={(e) => {
248+
setCurrentDocument({
249+
...currentDocument,
250+
description: e.target.value,
251+
})
252+
}}
253+
/>
254+
</fieldset>
251255
<Checkbox
252256
id="is_published"
253257
label="Is published"
@@ -260,34 +264,36 @@ const DocumentForm = ({
260264
})
261265
}}
262266
/>
263-
<div style={{ marginTop: '1rem' }}>
267+
<div className={classes.actions}>
264268
<Button type="submit">Save document</Button>
265269
<Button type="button" variant="secondary">
266270
Cancel
267271
</Button>
268272
</div>
269273
</form>
270-
<div style={{ marginTop: '1rem' }}>
271-
<h3>Blocks:</h3>
272-
<div style={{ display: 'flex', gap: '1rem' }}>
273-
<Button
274-
type="button"
275-
variant="secondary"
276-
onClick={() => {
277-
setIsCollapsed(true)
278-
}}
279-
>
280-
Collapse all
281-
</Button>
282-
<Button
283-
type="button"
284-
variant="secondary"
285-
onClick={() => setIsCollapsed(false)}
286-
>
287-
Expand all
288-
</Button>
289-
</div>
290-
<div className={classes.blocksContainer}>
274+
<div className={classes.blocksContainer}>
275+
{blocksData.length > 0 && <h3>Document blocks:</h3>}
276+
{blocksData.length > 0 && (
277+
<div style={{ display: 'flex', gap: '1rem' }}>
278+
<Button
279+
type="button"
280+
variant="secondary"
281+
onClick={() => {
282+
setIsCollapsed(true)
283+
}}
284+
>
285+
Collapse all
286+
</Button>
287+
<Button
288+
type="button"
289+
variant="secondary"
290+
onClick={() => setIsCollapsed(false)}
291+
>
292+
Expand all
293+
</Button>
294+
</div>
295+
)}
296+
<div className={classes.blocks}>
291297
{currentDocument.id && (
292298
<>
293299
{/* Drop zone at the beginning */}

src/components/Document/document.module.css

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,24 @@
11
.documentFormContainer {
2+
margin-top: 4rem;
23
display: block;
34
}
45

56
.documentForm {
67
display: block;
78
width: 100%;
8-
9-
label {
10-
display: block;
11-
margin-bottom: 0.5rem;
12-
}
13-
14-
input,
15-
textarea {
16-
padding: 0.5rem 0.5rem;
17-
box-sizing: border-box;
18-
width: 100%;
19-
}
209
}
2110

2211
.container {
2312
display: block;
2413
width: 100%;
14+
box-sizing: border-box;
15+
}
2516

26-
label {
27-
display: block;
28-
margin-bottom: 0.5rem;
29-
}
30-
31-
input,
32-
textarea {
33-
padding: 0.5rem 0.5rem;
34-
box-sizing: border-box;
35-
width: 100%;
36-
}
17+
.fieldset {
18+
display: block;
19+
border: none;
20+
padding: 0;
21+
margin-bottom: 2rem;
3722
}
3823

3924
.deleteButton {
@@ -93,6 +78,7 @@
9378
.container {
9479
position: relative;
9580
transition: all 0.2s ease;
81+
padding: 20px;
9682
}
9783

9884
.container.dragging {
@@ -103,7 +89,6 @@
10389

10490
.form {
10591
display: block;
106-
width: 100%;
10792
}
10893

10994
.dragging .blockHeader {
@@ -176,6 +161,13 @@
176161
position: relative;
177162
}
178163

164+
.blocks {
165+
display: flex;
166+
flex-direction: column;
167+
gap: 10px;
168+
margin-top: 10px;
169+
}
170+
179171
/* Collapsed content during dragging */
180172
.collapsedContent {
181173
padding: 10px;
@@ -326,3 +318,9 @@
326318
}
327319
}
328320
}
321+
322+
.actions {
323+
display: flex;
324+
gap: 10px;
325+
margin-top: 2rem;
326+
}

src/components/Input/Input.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.fieldset {
1+
.component {
22
display: flex;
33
flex-direction: column;
44
gap: 10px;

src/components/Input/Input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
2121
const helperId = `${inputId}-helper`
2222

2323
return (
24-
<fieldset className={classes.fieldset}>
24+
<div className={classes.component}>
2525
<label htmlFor={inputId} className={classes.label}>
2626
{label}
2727
{required && <span className={classes.required}>*</span>}
@@ -45,7 +45,7 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
4545
{helperText}
4646
</div>
4747
)}
48-
</fieldset>
48+
</div>
4949
)
5050
}
5151
)

src/components/TextArea/TextArea.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.fieldset {
1+
.component {
22
display: flex;
33
flex-direction: column;
44
gap: 10px;

src/components/TextArea/TextArea.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(
3232
const helperId = `${textareaId}-helper`
3333

3434
return (
35-
<fieldset className={classes.fieldset}>
35+
<div className={classes.component}>
3636
<label htmlFor={textareaId} className={classes.label}>
3737
{label}
3838
{required && <span className={classes.required}>*</span>}
@@ -57,7 +57,7 @@ export const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(
5757
{helperText}
5858
</div>
5959
)}
60-
</fieldset>
60+
</div>
6161
)
6262
}
6363
)

0 commit comments

Comments
 (0)