Skip to content

Commit 9408df6

Browse files
committed
Use tailwind transition for requested fields too
1 parent 58de930 commit 9408df6

File tree

1 file changed

+21
-40
lines changed

1 file changed

+21
-40
lines changed

src/components/Popups/SelectCredentials.js

Lines changed: 21 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
1717
const [currentSelectionMap, setCurrentSelectionMap] = useState({});
1818
const [requestedFields, setRequestedFields] = useState([]);
1919
const [showRequestedFields, setShowRequestedFields] = useState(false);
20-
const [renderContent, setRenderContent] = useState(showRequestedFields);
21-
const [applyTransition, setApplyTransition] = useState(false);
2220
const [credentialDisplay, setCredentialDisplay] = useState({});
2321

2422
useEffect(() => {
@@ -46,17 +44,6 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
4644
getData();
4745
}, [api, currentIndex]);
4846

49-
useEffect(() => {
50-
if (showRequestedFields) {
51-
setRenderContent(true);
52-
} else if (applyTransition) {
53-
setTimeout(() => setRenderContent(false), 500);
54-
} else {
55-
setRenderContent(false);
56-
}
57-
}, [showRequestedFields, applyTransition]);
58-
59-
6047
const goToNextSelection = () => {
6148
setCurrentIndex((i) => i + 1);
6249
}
@@ -67,12 +54,9 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
6754
currentMap[descriptorId] = credentialIdentifier;
6855
return currentMap;
6956
});
70-
setApplyTransition(false);
71-
setShowRequestedFields(false);
7257
goToNextSelection();
7358
};
7459

75-
7660
const handleCancel = () => {
7761
setShowPopup(false);
7862
navigate('/'); // Navigate to home page or any other route
@@ -82,6 +66,10 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
8266
return null;
8367
};
8468

69+
const toggleRequestedFields = () => {
70+
setShowRequestedFields(!showRequestedFields);
71+
};
72+
8573
const toggleCredentialDisplay = (identifier) => {
8674
setCredentialDisplay(prev => ({
8775
...prev,
@@ -102,36 +90,29 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
10290
{t('selectCredentialPopup.description')}
10391
</p>
10492
{requestedFields && (
105-
106-
107-
<div className="lg:p-0 p-2 mt-4 w-full">
93+
<div className="lg:p-0 p-2 my-4 w-full">
10894
<div className="mb-2 flex items-center">
10995
<button
110-
onClick={() => { setApplyTransition(true); setShowRequestedFields(!showRequestedFields) }}
111-
className="px-2 py-2 text-white cursor-pointer flex items-center bg-custom-blue hover:bg-custom-blue-hover font-medium rounded-lg text-sm px-4 py-2 text-center dark:bg-custom-blue-hover dark:hover:bg-custom-blue-hover"
96+
onClick={toggleRequestedFields}
97+
className="px-2 py-2 text-white cursor-pointer flex items-center bg-custom-blue hover:bg-custom-blue-hover font-medium rounded-lg text-xs px-4 py-2 text-center dark:bg-custom-blue-hover dark:hover:bg-custom-blue-hover"
11298
>
11399
{showRequestedFields ? `${t('selectCredentialPopup.requestedFieldsHide')}` : `${t('selectCredentialPopup.requestedFieldsShow')}`}
114100
</button>
115101
</div>
116102

117-
<hr className="border-t border-gray-300 py-1" />
118-
119-
<div
120-
className={`overflow-hidden transition-height ${showRequestedFields ? 'max-h-96' : 'max-h-0'}`}
121-
style={{ transition: 'max-height 0.5s ease-in-out' }}
122-
123-
>
124-
{renderContent && (
125-
<>
126-
<p className='mb-2 text-sm italic text-gray-700'>{t('selectCredentialPopup.requestedFieldsinfo')} {verifierDomainName}</p>
127-
<textarea
128-
readOnly
129-
value={requestedFields.join('\n')}
130-
className="w-full border rounded p-2 rounded-xl"
131-
rows={Math.min(3, Math.max(1, requestedFields.length))}
132-
></textarea>
133-
</>
134-
)}
103+
<hr className="border-t border-gray-300" />
104+
105+
<div className={`transition-all ease-in-out duration-1000 p-2 overflow-hidden rounded-xl shadow-xl ${showRequestedFields ? 'max-h-[500px] opacity-100' : 'max-h-0 opacity-0 m-0 p-0'}`}>
106+
<>
107+
<p className='mb-2 text-sm italic text-gray-700'>{t('selectCredentialPopup.requestedFieldsinfo')} {verifierDomainName}</p>
108+
<textarea
109+
readOnly
110+
value={requestedFields.join('\n')}
111+
className="p-2 border rounded-lg text-sm"
112+
style={{ width: '-webkit-fill-available' }}
113+
rows={Math.min(3, Math.max(1, requestedFields.length))}
114+
></textarea>
115+
</>
135116
</div>
136117
</div>
137118
)}
@@ -150,7 +131,7 @@ function SelectCredentials({ showPopup, setShowPopup, setSelectionMap, conforman
150131
{credentialDisplay[image.credentialIdentifier] ? 'Hide Details' : 'Show Details'}
151132
</button>
152133
<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'}`}
134+
className={`transition-all ease-in-out duration-1000 overflow-hidden shadow-lg rounded-lg ${credentialDisplay[image.credentialIdentifier] ? 'max-h-[500px] opacity-100' : 'max-h-0 opacity-0'}`}
154135
>
155136
<CredentialInfo credential={image.credential} mainClassName={"text-xs w-full"} />
156137
</div>

0 commit comments

Comments
 (0)