Skip to content

Commit ee12d96

Browse files
fix: add visit site button
1 parent fd2f43c commit ee12d96

File tree

3 files changed

+19
-104
lines changed

3 files changed

+19
-104
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"lastUpdated": "2024-07-10T08:04:27+06:00",
2+
"lastUpdated": "2024-07-10T08:27:29+06:00",
33
"numLibraries": 1284
44
}

pages/popup/src/Popup.css

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -53,32 +53,13 @@ body {
5353
/* Shadow to match item cards */
5454
}
5555

56-
.info-button-container {
56+
.button-group {
5757
display: flex;
58-
justify-content: space-between;
59-
align-items: center;
60-
width: 100%;
61-
padding: 10px;
62-
border: 1px solid #555555;
63-
/* Border color */
64-
border-radius: 8px;
65-
margin-bottom: 20px;
66-
/* Ensure even spacing */
67-
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
68-
/* Shadow to match item cards */
58+
gap: 10px;
6959
}
7060

71-
.additional-info {
72-
text-align: left;
73-
color: #ffcc00;
74-
/* Accent color for the additional info */
75-
}
76-
77-
.additional-info p {
78-
margin: 5px 0;
79-
}
80-
81-
.visit-site-button {
61+
.visit-site-button,
62+
.open-all-button {
8263
padding: 8px 12px;
8364
background-color: #ffcc00;
8465
/* Button background color */
@@ -94,13 +75,15 @@ body {
9475
/* Button shadow */
9576
}
9677

97-
.visit-site-button:hover {
78+
.visit-site-button:hover,
79+
.open-all-button:hover {
9880
background-color: #e6b800;
9981
/* Darker yellow on hover */
10082
transform: translateY(-2px);
10183
}
10284

103-
.visit-site-button:active {
85+
.visit-site-button:active,
86+
.open-all-button:active {
10487
background-color: #d1a700;
10588
/* Even darker yellow on active */
10689
}
@@ -111,33 +94,6 @@ body {
11194
/* Accent color */
11295
}
11396

114-
.open-all-button {
115-
padding: 8px 12px;
116-
background-color: #ffcc00;
117-
/* Button background color */
118-
color: #333333;
119-
/* Button text color */
120-
border: none;
121-
border-radius: 5px;
122-
font-size: 0.9rem;
123-
font-weight: bold;
124-
cursor: pointer;
125-
transition: background-color 0.2s ease, transform 0.2s ease;
126-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
127-
/* Button shadow */
128-
}
129-
130-
.open-all-button:hover {
131-
background-color: #e6b800;
132-
/* Darker yellow on hover */
133-
transform: translateY(-2px);
134-
}
135-
136-
.open-all-button:active {
137-
background-color: #d1a700;
138-
/* Even darker yellow on active */
139-
}
140-
14197
.item-list {
14298
display: flex;
14399
flex-direction: column;

pages/popup/src/Popup.tsx

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,9 @@
22
import React, { useEffect, useState } from 'react';
33
import '@src/Popup.css';
44
import { Library } from './types';
5-
import { format } from 'timeago.js';
65
const siteLink = 'https://mrpmohiburrahman.github.io/similar-react-native-libraries/';
7-
const metadataCDN_Url =
8-
'https://cdn.jsdelivr.net/gh/mrpmohiburrahman/similar-react-native-libraries@main/category-selector/data/metadata.json';
96

10-
const MatchedItemsList: React.FC<{ lastUpdated: string; numLibraries: number; siteLink: string }> = ({
11-
lastUpdated,
12-
numLibraries,
13-
siteLink,
14-
}) => {
7+
const MatchedItemsList: React.FC<{ siteLink: string }> = ({ siteLink }) => {
158
const [items, setItems] = useState<Library[]>([]);
169
const [loading, setLoading] = useState(true);
1710

@@ -44,22 +37,16 @@ const MatchedItemsList: React.FC<{ lastUpdated: string; numLibraries: number; si
4437

4538
return (
4639
<>
47-
<div className="info-button-container">
48-
<div className="additional-info">
49-
<p>{lastUpdated}</p>
50-
<p>
51-
Number of Sorted Libraries:<strong> {numLibraries}</strong>
52-
</p>
53-
</div>
54-
<button className="visit-site-button" onClick={() => window.open(siteLink, '_blank')}>
55-
Visit Site
56-
</button>
57-
</div>
5840
<div className="header-button-container">
5941
<h1 className="text-xl">Matched Libraries</h1>
60-
<button className="open-all-button" onClick={openAllLinks}>
61-
Open All Links
62-
</button>
42+
<div className="button-group">
43+
<button className="visit-site-button" onClick={() => window.open(siteLink, '_blank')}>
44+
Visit Site
45+
</button>
46+
<button className="open-all-button" onClick={openAllLinks}>
47+
Open All Links
48+
</button>
49+
</div>
6350
</div>
6451
<div className="item-list">
6552
{items.map((item, index) => (
@@ -87,40 +74,12 @@ const MatchedItemsList: React.FC<{ lastUpdated: string; numLibraries: number; si
8774
</>
8875
);
8976
};
90-
const renderLastUpdatedMessage = (message: string) => {
91-
const parts = message.split('Last updated: ');
92-
if (parts.length > 1) {
93-
return (
94-
<p>
95-
Last updated: <strong>{parts[1]}</strong>
96-
</p>
97-
);
98-
}
99-
return <p>{message}</p>;
100-
};
10177

10278
const Popup: React.FC = () => {
103-
const [lastUpdated, setLastUpdated] = useState<string>('');
104-
const [numLibraries, setNumLibraries] = useState<number>(0);
105-
106-
useEffect(() => {
107-
fetch(metadataCDN_Url)
108-
.then(response => response.json())
109-
.then(data => {
110-
setLastUpdated(`Last updated: ${format(new Date(data.lastUpdated))}`);
111-
setNumLibraries(data.numLibraries);
112-
})
113-
.catch(error => console.error('Error fetching metadata:', error));
114-
}, []);
115-
11679
return (
11780
<div className="App">
11881
<header className="App-header">
119-
<MatchedItemsList
120-
lastUpdated={renderLastUpdatedMessage(lastUpdated)}
121-
numLibraries={numLibraries}
122-
siteLink={siteLink}
123-
/>
82+
<MatchedItemsList siteLink={siteLink} />
12483
</header>
12584
</div>
12685
);

0 commit comments

Comments
 (0)