Skip to content

Commit 443df0d

Browse files
authored
Merge pull request #6 from getlinksc/added-remove-selector
add remove selector
2 parents 79835d3 + ca4fa88 commit 443df0d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

components/data-builder.js

+15-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export function DataBuilder({ html, setElements, defaultLayout = [265, 440, 755]
3838
setSelectors([...selectors, {"key": "", "selector": ""}])
3939
}
4040

41+
const removeSelector = (index) => {
42+
setSelectors([...selectors.slice(0, index), ...selectors.splice(index+1)]);
43+
}
44+
4145
const parseForSelectors = (e) => {
4246
if (html){
4347
const $ = cheerio.load(html);
@@ -93,20 +97,30 @@ export function DataBuilder({ html, setElements, defaultLayout = [265, 440, 755]
9397
<CardContent className="grid gap-4">
9498
{selectors.map((input, index) => {
9599
return (
96-
<div className="grid grid-cols-2 gap-6" key={index}>
100+
<div className="grid grid-cols-10 gap-1" key={index}>
97101
<Input
102+
className="col-span-4"
98103
id="key"
99104
type="text"
100105
placeholder={`key${index}`}
101106
onChange={(e) => {updateSelectorKey(e, index)}}
102107
/>
103108
<Input
109+
className="col-span-4"
104110
id="selector"
105111
type="text"
106112
placeholder={`selector${index}`}
107113
onChange={(e) => {updateSelectorValue(e, index)}}
108114
/>
115+
<Button
116+
className="col-span-2"
117+
variant="secondary"
118+
onClick={(e) => removeSelector(index)}
119+
>
120+
<MinusCircledIcon className="mr-2 h-4 w-4" />
121+
</Button>
109122
</div>
123+
110124
)
111125
})}
112126
<Button

0 commit comments

Comments
 (0)