Skip to content

Commit 42be73d

Browse files
author
David Riches
committed
fix: refactor to use from forma36
1 parent 08c09e3 commit 42be73d

File tree

2 files changed

+29
-46
lines changed

2 files changed

+29
-46
lines changed

src/components/RepeatableReferenceField.tsx

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
SkeletonContainer,
88
TextInput,
99
Paragraph,
10+
Card,
1011
} from "@contentful/forma-36-react-components";
1112
import { FieldExtensionSDK } from "contentful-ui-extensions-sdk";
1213
import { v4 as uuid } from "uuid";
@@ -139,56 +140,50 @@ const RepeatableReferenceField = (props: FieldProps) => {
139140
draggableId={`${row.id}-${index}`}
140141
index={index}
141142
>
142-
{(provided, snapshot) => {
143+
{(provided) => {
143144
return (
144145
<div
145146
key={row.key}
146147
{...provided.draggableProps}
147148
{...provided.dragHandleProps}
148149
ref={provided.innerRef}
149-
className="row"
150150
style={{
151151
userSelect: "none",
152-
backgroundColor: snapshot.isDragging
153-
? "#f7f9fa"
154-
: "white",
155-
boxShadow: snapshot.isDragging
156-
? "0px 0px 0px 1px rgb(25 37 50 / 10%), 0px -6px 16px -6px rgb(25 37 50 / 3%), 0px 8px 16px -8px rgb(25 37 50 / 20%), 0px 13px 27px -5px rgb(25 37 50 / 15%)"
157-
: "none",
158152
...provided.draggableProps.style,
159153
}}
160154
>
161-
<div>
162-
<TextInput
163-
value={row[textKey]}
164-
placeholder={textLabel}
165-
data-index={index}
166-
onChange={onTextChanged}
167-
></TextInput>
168-
</div>
169-
<div style={{ width: "200px" }}>
170-
{row.name ? (
171-
<Paragraph>{row.name}</Paragraph>
172-
) : (
173-
<SkeletonContainer svgHeight="20">
174-
<SkeletonBodyText numberOfLines="1"></SkeletonBodyText>
175-
</SkeletonContainer>
176-
)}
177-
</div>
178-
<div>
179-
<EditorToolbarButton
180-
icon="Delete"
181-
data-index={index}
182-
onClick={() => onDeleteButtonClicked(row)}
183-
></EditorToolbarButton>
184-
</div>
155+
<Card className="row">
156+
<div>
157+
<TextInput
158+
value={row[textKey]}
159+
placeholder={textLabel}
160+
data-index={index}
161+
onChange={onTextChanged}
162+
></TextInput>
163+
</div>
164+
<div style={{ width: "200px" }}>
165+
{row.name ? (
166+
<Paragraph>{row.name}</Paragraph>
167+
) : (
168+
<SkeletonContainer svgHeight="20">
169+
<SkeletonBodyText numberOfLines="1"></SkeletonBodyText>
170+
</SkeletonContainer>
171+
)}
172+
</div>
173+
<div className="delete">
174+
<EditorToolbarButton
175+
icon="Delete"
176+
data-index={index}
177+
onClick={() => onDeleteButtonClicked(row)}
178+
></EditorToolbarButton>
179+
</div>
180+
</Card>
185181
</div>
186182
);
187183
}}
188184
</Draggable>
189185
);
190186
})}
191-
192187
{provided.placeholder}
193188
</div>
194189
);

src/index.css

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,15 @@ div {
99
vertical-align: baseline;
1010
}
1111

12-
.rows {
13-
border-top: 1px solid #e5ebed;
14-
}
15-
1612
.row {
1713
display: flex;
1814
padding: 0.9375rem 0;
1915
align-items: center;
20-
border-bottom: 1px solid #e5ebed;
21-
border-left: 1px solid #e5ebed;
22-
border-right: 1px solid #e5ebed;
23-
}
24-
25-
.row:hover {
26-
background-color: #f7f9fa;
2716
}
2817

2918
.row > div {
3019
padding: 0 1.25rem;
3120
}
32-
3321
.delete {
3422
margin-left: auto;
35-
}
23+
}

0 commit comments

Comments
 (0)