-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(selectionCard): update states and spacing in selection card #2240
feat(selectionCard): update states and spacing in selection card #2240
Conversation
ca173cb
to
14f2b26
Compare
44c5058
to
471830c
Compare
@@ -41,20 +41,22 @@ export const SelectionCard = (props: SelectionCardProps) => { | |||
|
|||
const classes = classNames( | |||
{ | |||
['Selection-card']: true, | |||
['Selection-card--selected']: selected, | |||
['Selection-card']: !disabled, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create a separate class for non-disabled states such as Selection-card--default
. Selection-card
here should act as a generic class with common css properties for both the default and disabled state.
css/src/components/selectionCard.css
Outdated
border-radius: var(--spacing-m); | ||
position: relative; | ||
cursor: not-allowed; | ||
box-shadow: inset 0 0 0 var(--spacing-xs) var(--secondary-lighter); | ||
transition: var(--duration--fast-01) var(--standard-productive-curve); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of repeating the css properties in both Selection-card
and Selection-card--disabled
please move all the common properties into one css class
css/src/components/selectionCard.css
Outdated
border-radius: var(--spacing-m); | ||
position: relative; | ||
cursor: not-allowed; | ||
box-shadow: inset 0 0 0 var(--spacing-xs) var(--primary-lighter); | ||
transition: var(--duration--fast-01) var(--standard-productive-curve); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refactor this as well according to above mentioned comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write a test case for click and keyboard event handler not being called for disabled state
Please check this once if we need a separate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please write a test case ensuring that user is not able to select/deselect disabled cards. Write test case for both single-select and multi-select cards. |
3423c6f
to
a042b48
Compare
const element3 = getByTestId('Selection-card-3'); | ||
fireEvent.click(element3); | ||
expect(element3).not.toHaveClass('Selection-card--selected'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check this test case once as on selection of element3 it should have Selection-card--selected
class present. This test contradicts with the expected behavior. Please check how this test case is passing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@anuradha9712 element3 is a disabled card so it must not be selected if it get clicked.
<SelectionCard | ||
id="item1" | ||
data-test="Selection-card-3" | ||
disabled={true} | ||
onClick={() => updateCardSelection('item1')} | ||
selected={isCardSelected('item1')} | ||
> | ||
Single Selection Item 3 | ||
</SelectionCard> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove item1
with item3
<SelectionCard | ||
id="item1" | ||
data-test="Selection-card-3" | ||
disabled={true} | ||
onClick={() => updateCardSelection('item1')} | ||
selected={isCardSelected('item1')} | ||
> | ||
Single Selection Item 3 | ||
</SelectionCard> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove item1
with item3
a042b48
to
ec5e317
Compare
ec5e317
to
8ea2982
Compare
What does this implement/fix? Explain your changes.
...
Does this close any currently open issues?
...
Any other comments?
...
Dependent PRs/Commits
...
Describe breaking changes, if any.
...
Checklist
Check all those that are applicable and complete.
master
branch