-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added condition for onchain data and adjusted required fields for pro…
…file editing modals (#257) * Added condition for onchain data and adjusted required fields * Updated tests and added ids
- Loading branch information
1 parent
b6dda13
commit 329bd6a
Showing
7 changed files
with
119 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
export default function ConditionCheckbox({ | ||
label, | ||
agreedToCondition, | ||
setAgreedToCondition, | ||
}: any) { | ||
return ( | ||
<div className="flex gap-2 items-center"> | ||
<label | ||
className="relative flex items-center p-3 rounded-full cursor-pointer" | ||
htmlFor="link" | ||
> | ||
<input | ||
checked={agreedToCondition} | ||
onChange={(e) => setAgreedToCondition(e.target.checked)} | ||
type="checkbox" | ||
className="before:content[''] peer relative h-5 w-5 cursor-pointer appearance-none rounded-md border border-[#D7594F] transition-all before:absolute before:top-2/4 before:left-2/4 before:block before:h-12 before:w-12 before:-translate-y-2/4 before:-translate-x-2/4 before:rounded-full before:bg-blue-gray-500 before:opacity-0 before:transition-opacity checked:border-[#D7594F] checked:bg-gray-900 checked:before:bg-gray-900 hover:before:opacity-10" | ||
id="link" | ||
/> | ||
<span className="absolute text-white transition-opacity opacity-0 pointer-events-none top-2/4 left-2/4 -translate-y-2/4 -translate-x-2/4 peer-checked:opacity-100"> | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
className="h-3.5 w-3.5" | ||
viewBox="0 0 20 20" | ||
fill="currentColor" | ||
stroke="currentColor" | ||
strokeWidth="1" | ||
> | ||
<path | ||
fillRule="evenodd" | ||
d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" | ||
clipRule="evenodd" | ||
></path> | ||
</svg> | ||
</span> | ||
</label> | ||
<label | ||
className="font-light text-gray-700 select-none max-w-[550px]" | ||
htmlFor="link" | ||
> | ||
<p className="dark:text-white">{label}</p> | ||
</label> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import ConditionCheckbox from '@/components/layout/ConditionCheckbox' | ||
|
||
describe('<ConditionCheckbox />', () => { | ||
let props: any | ||
|
||
beforeEach(() => { | ||
props = { | ||
label: 'Test Condition', | ||
agreedToCondition: false, | ||
setAgreedToCondition: cy.spy().as('setAgreedToCondition'), | ||
} | ||
|
||
cy.mount(<ConditionCheckbox {...props} />) | ||
}) | ||
|
||
it('Renders with label and responds to clicks', () => { | ||
cy.contains('Test Condition').should('be.visible') | ||
cy.get('input[type="checkbox"]').should('not.be.checked') | ||
cy.get('input[type="checkbox"]').click() | ||
cy.get('@setAgreedToCondition').should('have.been.calledWith', true) | ||
}) | ||
|
||
it('Renders correctly when initially checked', () => { | ||
cy.mount(<ConditionCheckbox {...props} agreedToCondition={true} />) | ||
cy.get('input[type="checkbox"]').should('be.checked') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters