Merge pull request 'Add search box' (#20) from search-box into master
Reviewed-on: #20
This commit is contained in:
commit
44ea62bce5
@ -33,3 +33,25 @@ body {
|
|||||||
display: inline-block;
|
display: inline-block;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-bottom: 2px solid #2e6dc0;
|
||||||
|
color: white;
|
||||||
|
font-family: 'Rajdhani', sans-serif;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
padding: 0.4rem 0;
|
||||||
|
width: 240px;
|
||||||
|
transition: border-color 0.3s ease;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input::placeholder {
|
||||||
|
color: #7a8aa5;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input:focus {
|
||||||
|
border-bottom: 2px solid #4a90e2;
|
||||||
|
}
|
||||||
|
|||||||
@ -20,6 +20,7 @@ function App() {
|
|||||||
const [editData, setEditData] = useState(null);
|
const [editData, setEditData] = useState(null);
|
||||||
const [showAdd, setShowAdd] = useState(false);
|
const [showAdd, setShowAdd] = useState(false);
|
||||||
const [confirmData, setConfirmData] = useState(null);
|
const [confirmData, setConfirmData] = useState(null);
|
||||||
|
const [searchTerm, setSearchTerm] = useState('');
|
||||||
|
|
||||||
const loadSections = () => {
|
const loadSections = () => {
|
||||||
fetchSections()
|
fetchSections()
|
||||||
@ -28,7 +29,7 @@ function App() {
|
|||||||
setSections(filtered);
|
setSections(filtered);
|
||||||
})
|
})
|
||||||
.catch(err => console.error('Failed to fetch sections:', err));
|
.catch(err => console.error('Failed to fetch sections:', err));
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadSections();
|
loadSections();
|
||||||
@ -87,6 +88,13 @@ function App() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const filteredSections = sections.map(section => ({
|
||||||
|
...section,
|
||||||
|
apps: section.apps.filter(app =>
|
||||||
|
app.name.toLowerCase().includes(searchTerm.toLowerCase())
|
||||||
|
),
|
||||||
|
})).filter(section => section.apps.length > 0);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="App">
|
<div className="App">
|
||||||
<Clock />
|
<Clock />
|
||||||
@ -95,6 +103,17 @@ function App() {
|
|||||||
Navix
|
Navix
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
|
{/* 🔍 Search Box */}
|
||||||
|
<div style={{ display: 'flex', justifyContent: 'flex-start', marginLeft: '2rem' }}>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Search apps..."
|
||||||
|
value={searchTerm}
|
||||||
|
onChange={(e) => setSearchTerm(e.target.value)}
|
||||||
|
className="search-input"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
{showAdd && (
|
{showAdd && (
|
||||||
<AppModal
|
<AppModal
|
||||||
mode="add"
|
mode="add"
|
||||||
@ -122,7 +141,7 @@ function App() {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{sections.map((section) => (
|
{filteredSections.map((section) => (
|
||||||
<SectionGrid
|
<SectionGrid
|
||||||
key={section.name}
|
key={section.name}
|
||||||
section={section}
|
section={section}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user