mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-16 14:18:29 +00:00
* bump package * Add Logo * remove console * prettify it * add favicons and fix issue * Add categorie page * add drag and drop * Make drag and drop working * Add drag options * Add modal * small styling fixes * fix search * Add code editor * Add more styling * Add more categories * create context provider * refactor eslint thing * update chakra-ui * improve, category bar * Add sortly * Add categories * Try to fix new categories * Fix Categories * Add docs Menu Tree data * Start with sectiontitles * Create link list * Add Docs menu to mobile * Add some more pages and text * Optimize text * add license to the menu * update packages * Fix build * Update title * Remove ModifiedTooltip * Fix assets * add yarn to copy-assets command * install deps * update * try something * new categories page * try something * Add icons reorder * add new icons page * add category view button * add categories * Fix vercel build * Add sidebar and costumize button * fix merge conlfict * Remove console.logs * add sidebar * Add icon overview * Fix key render issue * Fix types * Fix category render * Fix build * update lockfile * Added category icon and icon count in list. Moved scrollbar to the left to make it less intrusive --------- Co-authored-by: Eric Fennis <eric.fennis@endurance.com> Co-authored-by: Eric Fennis <eric@dreamteam.nl> Co-authored-by: Karsa <karsa@karsa.org>
89 lines
2.7 KiB
TypeScript
89 lines
2.7 KiB
TypeScript
import { Box, Text, IconButton, HStack } from '@chakra-ui/react';
|
|
import React, { memo, useEffect, useState } from 'react';
|
|
import useSearch from '../lib/useSearch';
|
|
import IconList from './IconList';
|
|
import { SearchInput } from './SearchInput';
|
|
import { Category, IconEntity } from '../types';
|
|
|
|
import { SidebarClose, SidebarOpen } from 'lucide-react';
|
|
|
|
import IconCategoryList from './IconCategoryList';
|
|
import { IconCustomizerDrawer } from './IconCustomizerDrawer';
|
|
import IconCategoryDrawer from './IconCategoryDrawer';
|
|
|
|
interface IconOverviewProps {
|
|
data: IconEntity[];
|
|
categories: Category[]
|
|
}
|
|
|
|
const IconOverview = ({ data, categories }: IconOverviewProps): JSX.Element => {
|
|
const [query, setQuery] = useState('');
|
|
const [sidebarOpen, setSidebarOpen] = useState<boolean | undefined>();
|
|
const [categoryView, setCategoryView] = useState(false);
|
|
|
|
useEffect(() => {
|
|
if(
|
|
typeof window !== 'undefined' &&
|
|
window.location.href.split('#').length === 2
|
|
) {
|
|
const [,hash] = window.location.href.split('#')
|
|
|
|
setCategoryView(categories.some(({ name }) => name === hash))
|
|
}
|
|
}, [])
|
|
|
|
const SidebarIcon = sidebarOpen ? SidebarOpen : SidebarClose;
|
|
|
|
const searchResults = useSearch(query, data, [
|
|
{ name: 'name', weight: 2 },
|
|
{ name: 'tags', weight: 1 },
|
|
]);
|
|
|
|
return (
|
|
<Box>
|
|
<HStack position="sticky" top={0} zIndex={1} gap={2} padding={5}>
|
|
<IconButton
|
|
aria-label="Close overlay"
|
|
variant="solid"
|
|
color="current"
|
|
onClick={() => setSidebarOpen(currentView => {
|
|
if(currentView == null) {
|
|
return false
|
|
}
|
|
|
|
return !currentView
|
|
})}
|
|
icon={<SidebarIcon />}
|
|
/>
|
|
<SearchInput onChange={setQuery} count={data.length} />
|
|
<IconCustomizerDrawer size="md" paddingX={6} />
|
|
</HStack>
|
|
|
|
<HStack marginBottom="320px" padding={5} alignItems="flex-start">
|
|
<IconCategoryDrawer
|
|
open={sidebarOpen}
|
|
onClose={() => setSidebarOpen(false)}
|
|
categories={categories}
|
|
data={data}
|
|
setCategoryView={setCategoryView}
|
|
/>
|
|
<Box flex={1} paddingTop={1}>
|
|
{searchResults.length > 0 ? (
|
|
categoryView ? (
|
|
<IconCategoryList icons={searchResults} data={data} categories={categories} />
|
|
) : (
|
|
<IconList icons={searchResults} />
|
|
)
|
|
) : (
|
|
<Text fontSize="2xl" fontWeight="bold" textAlign="center" wordBreak="break-word">
|
|
No results found for "{query}"
|
|
</Text>
|
|
)}
|
|
</Box>
|
|
</HStack>
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
export default memo(IconOverview)
|