Skip to content

Commit 58de930

Browse files
committed
SelectCredentials popup display the main info with a collapse button with animation
1 parent 5f9fa8d commit 58de930

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/components/Credentials/CredentialInfo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const renderRow = (fieldName, fieldValue) => {
4545
return null;
4646
};
4747

48-
const CredentialInfo = ({ credential }) => {
48+
const CredentialInfo = ({ credential, mainClassName="pt-5 pr-2 w-full" }) => {
4949

5050
const [parsedCredential, setParsedCredential] = useState(null);
5151

@@ -56,7 +56,7 @@ const CredentialInfo = ({ credential }) => {
5656
}, []);
5757

5858
return (
59-
<div className=" pt-5 pr-2 w-full">
59+
<div className={mainClassName}>
6060
<table className="lg:w-4/5">
6161
<tbody className="divide-y-4 divide-transparent">
6262
{parsedCredential && (

src/components/Popups/SelectCredentials.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
1919
const [showRequestedFields, setShowRequestedFields] = useState(false);
2020
const [renderContent, setRenderContent] = useState(showRequestedFields);
2121
const [applyTransition, setApplyTransition] = useState(false);
22+
const [credentialDisplay, setCredentialDisplay] = useState({});
2223

2324
useEffect(() => {
2425
const getData = async () => {
@@ -81,6 +82,13 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
8182
return null;
8283
};
8384

85+
const toggleCredentialDisplay = (identifier) => {
86+
setCredentialDisplay(prev => ({
87+
...prev,
88+
[identifier]: !prev[identifier]
89+
}));
90+
};
91+
8492
return (
8593
<div className="fixed inset-0 flex items-center justify-center z-50">
8694
<div className="absolute inset-0 bg-black opacity-50"></div>
@@ -130,18 +138,25 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
130138

131139
<div className='flex flex-wrap justify-center flex overflow-y-auto max-h-[40vh]'>
132140
{images.map(image => (
133-
<div className="m-3 flex justify-center">
134-
<div className='w-1/2'>
135-
<div className="relative rounded-xl w-full overflow-hidden transition-shadow shadow-md hover:shadow-lg cursor-pointer">
141+
<>
142+
<div key={image.credentialIdentifier} className="m-3 flex flex-col items-center">
143+
<div className="relative rounded-xl w-2/3 overflow-hidden transition-shadow shadow-md hover:shadow-lg cursor-pointer">
136144
<CredentialImage key={image.credentialIdentifier} credential={image.credential} onClick={() => handleClick(image.credentialIdentifier)} className={"w-full object-cover rounded-xl"} />
137145
</div>
146+
<div className='w-2/3 mt-2'>
147+
<button
148+
onClick={() => toggleCredentialDisplay(image.credentialIdentifier)}
149+
className="text-xs py-2 w-full bg-custom-blue hover:bg-custom-blue-hover text-white font-medium rounded-lg">
150+
{credentialDisplay[image.credentialIdentifier] ? 'Hide Details' : 'Show Details'}
151+
</button>
152+
<div
153+
className={`transition-all ease-in-out duration-500 overflow-hidden shadow-lg rounded-lg ${credentialDisplay[image.credentialIdentifier] ? 'max-h-[500px] opacity-100' : 'max-h-0 opacity-0'}`}
154+
>
155+
<CredentialInfo credential={image.credential} mainClassName={"text-xs w-full"} />
156+
</div>
157+
</div>
138158
</div>
139-
<div className='w-1/2'>
140-
<CredentialInfo credential={image} />
141-
</div>
142-
143-
144-
</div>
159+
</>
145160
))}
146161
</div>
147162
<button

0 commit comments

Comments
 (0)