Done with the discover apps tab revamp : New look

This commit is contained in:
monilprajapati
2024-12-01 19:51:51 +05:30
parent e652d0039c
commit 02db40aa17
2 changed files with 296 additions and 258 deletions
+1 -1
View File
@@ -309,7 +309,7 @@ const AppModal = ({ open, onClose, app, userdata, globalUrl }) => {
}} }}
> >
<Typography variant="h5" component="div" sx={{ fontWeight: 500 }}> <Typography variant="h5" component="div" sx={{ fontWeight: 500 }}>
About Gmail About {app?.name.replace(/_/g, ' ').replace(/\b\w/g, char => char.toUpperCase())}
</Typography> </Typography>
<IconButton <IconButton
onClick={onClose} onClick={onClose}
+81 -43
View File
@@ -299,24 +299,16 @@ const Hits = ({
<Typography variant="body1">No Apps Found</Typography> <Typography variant="body1">No Apps Found</Typography>
</div> </div>
) : ( ) : (
<Grid item spacing={2} justifyContent="flex-start">
<div <div
style={{ style={{
minHeight: 570,
overflowY: "auto",
overflowX: "hidden",
}}>
<div
style={{
rowGap: 16,
columnGap: 16,
marginTop: 16, marginTop: 16,
display: "flex", width: "100%",
flexWrap: "wrap", display: "grid",
justifyContent: "flex-start", gridTemplateColumns: "repeat(auto-fill, minmax(365px, 1fr))",
maxHeight: 570, gap: "20px",
scrollbarWidth: "thin", justifyContent: "space-between",
scrollbarColor: "#494949 #2f2f2f", alignItems: "start",
padding: "0 10px"
}} }}
> >
{hits?.map((data, index) => { {hits?.map((data, index) => {
@@ -332,29 +324,21 @@ const Hits = ({
style={{ style={{
transitionDelay: `${workflowDelay}ms`, transitionDelay: `${workflowDelay}ms`,
}} }}
>
<div
onClick={
() => {
handleAppClick(data);
}
}
style={{
color: "#f85a3e",
}}
> >
<Paper <Paper
elevation={0} elevation={0}
style={{ style={{
backgroundColor: hoverEffect === index ? "rgba(26, 26, 26, 1)" : "#1A1A1A", backgroundColor: hoverEffect === index ? "rgba(26, 26, 26, 1)" : "#212121",
color: "rgba(241, 241, 241, 1)", color: "rgba(241, 241, 241, 1)",
cursor: "pointer", cursor: "pointer",
position: "relative", fontFamily: "Inter",
width: leftSideBarOpenByClick ? 325 : 365, // position: "relative",
width: "100%",
height: 96, height: 96,
borderRadius: 8, borderRadius: 8,
boxShadow: "0px 0px 10px 0px rgba(0, 0, 0, 0.1)", boxShadow: "0px 0px 10px 0px rgba(0, 0, 0, 0.1)",
marginBottom: 20, marginBottom: 20,
transition: "width 0.3s ease",
}} }}
onMouseEnter={() => { onMouseEnter={() => {
setHoverEffect(index); setHoverEffect(index);
@@ -368,10 +352,14 @@ const Hits = ({
fontSize: 16, fontSize: 16,
overflow: "hidden", overflow: "hidden",
display: "flex", display: "flex",
alignItems: "flex-start", fontFamily: "Inter",
width: '100%', width: '100%',
backgroundColor: hoverEffect === index ? "#2F2F2F" : "#212121" backgroundColor: hoverEffect === index ? "#2F2F2F" : "#212121"
}}> }}
onClick={() => {
handleAppClick(data);
}}
>
<img <img
alt={data.name} alt={data.name}
src={data.image_url ? data.image_url : "/images/no_image.png"} src={data.image_url ? data.image_url : "/images/no_image.png"}
@@ -390,10 +378,11 @@ const Hits = ({
flexDirection: "column", flexDirection: "column",
alignItems: "flex-start", alignItems: "flex-start",
width: 339, width: 339,
gap: 8, gap: 6,
fontWeight: '400', fontWeight: '400',
overflow: "hidden", overflow: "hidden",
margin: "12px 0", margin: "12px 0",
fontFamily: "Inter"
}} }}
> >
<div <div
@@ -402,6 +391,7 @@ const Hits = ({
flexDirection: "row", flexDirection: "row",
overflow: "hidden", overflow: "hidden",
gap: 8, gap: 8,
fontWeight:600,
textOverflow: "ellipsis", textOverflow: "ellipsis",
whiteSpace: "nowrap", whiteSpace: "nowrap",
color: '#F1F1F1' color: '#F1F1F1'
@@ -517,19 +507,17 @@ const Hits = ({
</div> </div>
</ButtonBase> </ButtonBase>
</Paper> </Paper>
</div>
</Zoom> </Zoom>
); );
})} })}
</div> </div>
</div>
</Grid>
)} )}
</div> </div>
) : ( ) : (
<div><Box sx={{ position: 'absolute', top: '30%', left: '50%', }}> <CircularProgress /></Box></div> <div><Box sx={{ position: 'absolute', top: '30%', left: '50%', }}> <CircularProgress /></Box></div>
)} )
</div> }
</div >
); );
} }
@@ -540,6 +528,14 @@ const SearchBox = ({ refine, searchQuery, setSearchQuery }) => {
const inputRef = useRef(null); const inputRef = useRef(null);
const [localQuery, setLocalQuery] = useState(searchQuery); const [localQuery, setLocalQuery] = useState(searchQuery);
// Initialize search when component mounts or when switching to Discover tab
useEffect(() => {
if (searchQuery) {
setLocalQuery(searchQuery);
refine(searchQuery); // This will trigger the Algolia search
}
}, [searchQuery, refine]);
// Debounced function to refine search // Debounced function to refine search
const debouncedRefine = useRef( const debouncedRefine = useRef(
debounce((value) => { debounce((value) => {
@@ -600,7 +596,6 @@ const SearchBox = ({ refine, searchQuery, setSearchQuery }) => {
<ClearIcon <ClearIcon
style={{ style={{
cursor: "pointer", cursor: "pointer",
marginRight: 10
}} }}
onClick={() => { onClick={() => {
setLocalQuery(''); setLocalQuery('');
@@ -626,6 +621,7 @@ const CategoryDropdown = ({ items, currentRefinement, refine }) => {
}; };
return ( return (
<div style={{ position: 'relative', width: '100%' }}>
<Select <Select
fullWidth fullWidth
variant="outlined" variant="outlined"
@@ -640,12 +636,28 @@ const CategoryDropdown = ({ items, currentRefinement, refine }) => {
All Categories All Categories
</MenuItem> </MenuItem>
{items.map(item => ( {items.map(item => (
<MenuItem key={item.label} value={item.label} style={{ fontFamily: "Inter" }}> <MenuItem key={item.label} value={item.label} style={{ fontFamily: "Inter", fontSize: 16 }}>
<Checkbox checked={currentRefinement.includes(item.label)} /> <Checkbox checked={currentRefinement.includes(item.label)} />
{item.label} ({item.count}) {item.label} ({item.count})
</MenuItem> </MenuItem>
))} ))}
</Select> </Select>
{currentRefinement.length > 0 && (
<ClearIcon
style={{
position: 'absolute',
right: 35,
top: '50%',
transform: 'translateY(-50%)',
cursor: 'pointer',
color: 'white',
fontSize: 20,
zIndex: 1000
}}
onClick={() => refine([])}
/>
)}
</div>
); );
}; };
const CustomCategoryDropdown = connectRefinementList(CategoryDropdown); const CustomCategoryDropdown = connectRefinementList(CategoryDropdown);
@@ -658,6 +670,7 @@ const LabelDropdown = ({ items, currentRefinement, refine }) => {
}; };
return ( return (
<div style={{ position: 'relative', width: '100%' }}>
<Select <Select
fullWidth fullWidth
variant="outlined" variant="outlined"
@@ -672,12 +685,31 @@ const LabelDropdown = ({ items, currentRefinement, refine }) => {
All Labels All Labels
</MenuItem> </MenuItem>
{items.map(item => ( {items.map(item => (
<MenuItem key={item.label} value={item.label}> <MenuItem key={item.label} value={item.label} style={{
fontFamily: "Inter",
fontSize: 16
}}>
<Checkbox checked={currentRefinement.includes(item.label)} /> <Checkbox checked={currentRefinement.includes(item.label)} />
{item.label} ({item.count}) {item.label} ({item.count})
</MenuItem> </MenuItem>
))} ))}
</Select> </Select>
{currentRefinement.length > 0 && (
<ClearIcon
style={{
position: 'absolute',
right: 35,
top: '50%',
transform: 'translateY(-50%)',
cursor: 'pointer',
color: 'white',
fontSize: 20,
zIndex: 1000
}}
onClick={() => refine([])}
/>
)}
</div>
); );
}; };
const CustomLabelDropdown = connectRefinementList(LabelDropdown); const CustomLabelDropdown = connectRefinementList(LabelDropdown);
@@ -936,6 +968,7 @@ const Apps2 = (props) => {
const handleTabChange = (newTab) => { const handleTabChange = (newTab) => {
setCurrTab(newTab); setCurrTab(newTab);
// Apply filters immediately when changing tabs // Apply filters immediately when changing tabs
if (newTab === 0) { if (newTab === 0) {
const filteredOrgApps = filterApps(orgApps, searchQuery, selectedCategory, selectedLabel); const filteredOrgApps = filterApps(orgApps, searchQuery, selectedCategory, selectedLabel);
@@ -944,15 +977,20 @@ const Apps2 = (props) => {
const filteredUserApps = filterApps(userApps, searchQuery, selectedCategory, selectedLabel); const filteredUserApps = filterApps(userApps, searchQuery, selectedCategory, selectedLabel);
setAppsToShow(filteredUserApps); setAppsToShow(filteredUserApps);
} }
// Note: We don't clear the search when switching to tab 2 (Discover Apps) anymore
// Update URL query params // Update URL query params
const newQueryParam = newTab === 0 ? 'org_apps' : newTab === 1 ? 'my_apps' : 'all_apps'; const newQueryParam = newTab === 0 ? 'org_apps' : newTab === 1 ? 'my_apps' : 'all_apps';
const queryParams = new URLSearchParams(location.search); const queryParams = new URLSearchParams(location.search);
queryParams.set('tab', newQueryParam); queryParams.set('tab', newQueryParam);
// Only remove 'q' param if search is empty
if (!searchQuery) { // Maintain search query in URL regardless of tab
if (searchQuery) {
queryParams.set('q', searchQuery);
} else {
queryParams.delete('q'); queryParams.delete('q');
} }
window.history.replaceState({}, '', `${location.pathname}?${queryParams.toString()}`); window.history.replaceState({}, '', `${location.pathname}?${queryParams.toString()}`);
}; };
@@ -1110,7 +1148,7 @@ const Apps2 = (props) => {
All Categories All Categories
</MenuItem> </MenuItem>
{categories?.map((category) => ( {categories?.map((category) => (
<MenuItem key={category.category} value={category.category} style={{ fontFamily: "Inter" }}> <MenuItem key={category.category} value={category.category} style={{ fontFamily: "Inter", fontSize: 16 }}>
<Checkbox checked={selectedCategory.includes(category.category)} /> <Checkbox checked={selectedCategory.includes(category.category)} />
{category.category} {category.category}
</MenuItem> </MenuItem>
@@ -1153,7 +1191,7 @@ const Apps2 = (props) => {
All Labels All Labels
</MenuItem> </MenuItem>
{labels?.map((tag) => ( {labels?.map((tag) => (
<MenuItem key={tag.tag} value={tag.tag} style={{ fontFamily: "Inter" }}> <MenuItem key={tag.tag} value={tag.tag} style={{ fontFamily: "Inter", fontSize: 16 }}>
<Checkbox checked={selectedLabel.includes(tag.tag)} /> <Checkbox checked={selectedLabel.includes(tag.tag)} />
{tag.tag} {tag.tag}
</MenuItem> </MenuItem>