Skip to content

Commit bff7ee9

Browse files
committed
PC-104: Add the Ability to Remove a Category Accordion via Trash Icon, Pill Close Button, and Checkbox Toggle
1 parent a472923 commit bff7ee9

22 files changed

Lines changed: 317 additions & 169 deletions
Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 4 additions & 0 deletions
Loading

app/assets/images/icons/trash.svg

Lines changed: 6 additions & 0 deletions
Loading
Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,54 @@
1-
.accordion-button {
2-
padding: 22.4px;
3-
border: 1px solid $primary;
4-
border-radius: 8px !important;
5-
background-color: $light !important;
6-
transition: border-radius 0.8s ease-out;
1+
// Accordion styles for bsPrefix={'pc-category-accordion'}
2+
.pc-category-accordion {
3+
.accordion-button {
4+
padding: 22.4px;
5+
border: 1px solid $primary;
6+
border-radius: 8px !important;
7+
background-color: $light !important;
8+
transition: border-radius 0.8s ease-out;
79

8-
&:not(.collapsed) {
9-
border-bottom: 1px solid $teal-blue;
10-
border-radius: 8px 8px 0 0 !important;
10+
&:not(.collapsed) {
11+
border-bottom: 1px solid $teal-blue;
12+
border-radius: 8px 8px 0 0 !important;
13+
}
1114
}
12-
}
1315

14-
.accordion-button:not(.collapsed):focus,
15-
.accordion-button.collapsed:focus {
16-
outline-offset: none;
17-
box-shadow: none;
18-
}
16+
.accordion-button:not(.collapsed):focus,
17+
.accordion-button.collapsed:focus {
18+
outline-offset: none;
19+
box-shadow: none;
20+
}
1921

20-
.accordion-button::after {
21-
display: none !important;
22-
}
22+
.accordion-button::after {
23+
display: none !important;
24+
}
2325

24-
.pc-accordion-body {
25-
padding: 20px 32px;
26-
}
26+
.pc-accordion-body {
27+
padding: 20px 32px;
28+
}
29+
30+
.accordion-bottom-filling {
31+
height: 24px;
32+
}
2733

28-
.accordion-bottom-filling {
29-
height: 24px;
34+
.pc-extra-actions {
35+
right: 60px;
36+
}
3037
}
3138

32-
.pc-accordion-quote {
39+
// Accordion styles for bsPrefix={'pc-item-accordion'}
40+
.pc-item-accordion {
3341
.accordion-button {
3442
padding: 0;
3543
border: transparent;
3644
background-color: $white !important;
45+
46+
&:not(.collapsed) {
47+
border: transparent;
48+
}
3749
}
3850

51+
.pc-extra-actions {
52+
right: 44px;
53+
}
3954
}

app/assets/stylesheets/application/buttons.scss

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@
1515
}
1616

1717
&:disabled {
18-
border-color: $secondary!important;
19-
color: $secondary!important;
18+
border-color: $secondary !important;
19+
color: $secondary !important;
2020
background: $white !important;
2121
}
2222
}
2323

24-
// styles for variant="warning"
25-
&-warning {
24+
// styles for variant="danger"
25+
&-danger {
26+
border-color: $danger !important;
2627
color: $white;
27-
border-color: $coral-primary !important;
28-
background: $coral-primary !important;
28+
background: $danger !important;
2929

3030
&:hover,
3131
&:focus {
32-
color: $white;
3332
border-color: $coral-primary !important;
33+
color: $white;
3434
background: $coral-primary !important;
3535
}
3636

@@ -67,29 +67,30 @@
6767
}
6868

6969
&:disabled {
70-
border-color: $gray-light !important;
71-
color: $text-gray-disable !important;
70+
border-color: $secondary !important;
71+
color: $secondary !important;
7272
}
7373
}
7474
}
7575

76+
// Styles for btn close "x"
77+
.btn-close {
78+
&:focus {
79+
box-shadow: none;
80+
}
81+
}
82+
7683
// Additional styles for buttons
7784
.pc-btn {
78-
&-reset, &-back, &-download, &-next {
79-
height: 38px;
80-
}
85+
width: 96px;
86+
height: 38px;
8187

8288
&-reset {
8389
width: 103.71px;
8490
font-family: $font-family-lato !important;
8591
}
8692

87-
&-back, &-next {
88-
width: 96px;
89-
}
90-
9193
&-download {
9294
width: 106px;
9395
}
9496
}
95-
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
.pc-pointer {
22
cursor: pointer;
33
}
4+
5+
.pc-mw-524 {
6+
max-width: 524px !important;
7+
}

app/assets/stylesheets/application/icons.scss

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,31 @@
99
height: 25px;
1010
}
1111
}
12+
13+
//Styles for trash-icon on category header accordion
14+
.pc-icon-hover-btn {
15+
position: relative;
16+
display: inline-flex;
17+
align-items: center;
18+
padding: 0;
19+
border: none;
20+
background: transparent;
21+
22+
.icon-default {
23+
display: inline;
24+
}
25+
26+
.icon-hover {
27+
display: none;
28+
}
29+
30+
&:hover {
31+
.icon-default {
32+
display: none;
33+
}
34+
35+
.icon-hover {
36+
display: inline;
37+
}
38+
}
39+
}

app/assets/stylesheets/application/typography.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ h2,
3939
line-height: 1.7;
4040
}
4141

42+
.pc-ff-lato {
43+
font-family: $font-family-lato;
44+
}
45+
4246
// Utility Classes
4347
$custom-colors: (
4448
'gray': $gray,
@@ -53,6 +57,7 @@ $custom-colors: (
5357
'teal-dark': $teal-dark,
5458
'teal-light': $teal-light,
5559
'teal-blue': $teal-blue,
60+
'dark-700': $dark-700,
5661
);
5762

5863
@each $name, $color in $custom-colors {

app/assets/stylesheets/application/variables.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ $teal: #a0c9c8;
2020
$teal-dark: #115d5b;
2121
$teal-light: #dce8f3;
2222
$teal-blue: #90bddb;
23+
$dark-700: rgba($dark, 0.7);
2324

2425
// Button Colors
2526
$coral-primary: #fe6d75;

app/javascript/components/pages/ItemsPricing.jsx

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { useState } from 'react'
22
import { Button, Container, Form } from 'react-bootstrap'
33
import { useAppHooks } from '../hooks'
4-
import { ItemsPricingTopBar, ItemTotalPrice, QuoteCreation, ROUTES } from '../shared'
5-
import { PcAccordion, PcItemAccordion, PcItemFormGroup, PcItemTextareaControl } from '../ui'
4+
import { DeleteItemModal, ItemsPricingTopBar, ItemTotalPrice, QuoteCreation, ROUTES } from '../shared'
5+
import { PcCategoryAccordion, PcItemAccordion, PcItemFormGroup, PcItemTextareaControl } from '../ui'
66
import { getCurrentStepId } from '../utils'
77

88
export const ItemsPricing = () => {
@@ -24,6 +24,11 @@ export const ItemsPricing = () => {
2424
prev.includes(id) ? prev.filter(item => item !== id) : [...prev, id],
2525
)
2626
}
27+
const handleDeleteCategory = (categoryId) => {
28+
setSelectedCategories((prev) => prev.filter((category) => category.id !== categoryId))
29+
setExpandedAccordions((prev) => prev.filter((id) => id !== categoryId))
30+
}
31+
2732
const expandAll = () => setExpandedAccordions(selectedCategories.map(category => category.id))
2833
const collapseAll = () => setExpandedAccordions([])
2934
const handleDownload = () => {
@@ -59,13 +64,14 @@ export const ItemsPricing = () => {
5964

6065
<section className={'d-flex flex-column gap-4 mb-8'}>
6166
{selectedCategories.length > 0 && selectedCategories.map((category) => (
62-
<PcAccordion
67+
<PcCategoryAccordion
6368
key={category.id}
6469
categoryName={category.name}
6570
isOpen={expandedAccordions.includes(category.id)}
6671
onToggle={() => handleToggle(category.id)}
72+
onDelete={() => handleDeleteCategory(category.id)}
6773
>
68-
{/*List of items */}
74+
{/*TODO: Skeleton for displaying item inside accordion */}
6975
<div className={'d-flex flex-column gap-5'}>
7076
{/*TODO: Example of Fixed Price. Will be changed after adding logic*/}
7177
<PcItemAccordion
@@ -95,17 +101,21 @@ export const ItemsPricing = () => {
95101
</PcItemFormGroup>
96102
}
97103
</PcItemAccordion>
104+
98105
</div>
99-
</PcAccordion>
106+
</PcCategoryAccordion>
100107
))}
101108
</section>
102109

103110
{/* Buttons section */}
104111
<section className={'d-flex justify-content-center align-items-center gap-4 mb-5'}>
105-
<Button variant={'outline-primary'} className={'fw-bold pc-btn-back'} onClick={handleBack}>Back</Button>
106-
<Button variant={'outline-primary'} className={'fw-bold pc-btn-download'} onClick={handleDownload}
112+
<Button variant={'outline-primary'} className={'fw-bold pc-btn'} onClick={handleBack}>Back</Button>
113+
<Button variant={'outline-primary'} className={'fw-bold pc-btn pc-btn-download'} onClick={handleDownload}
107114
disabled={true}>Download</Button>
108115
</section>
116+
117+
{/*Modal for confirm delete/cancel category*/}
118+
<DeleteItemModal />
109119
</Container>
110120
)
111121
}

0 commit comments

Comments
 (0)