diff --git a/docs/.vitepress/components/CategoriesList.data.ts b/docs/.vitepress/components/CategoryList.data.ts similarity index 56% rename from docs/.vitepress/components/CategoriesList.data.ts rename to docs/.vitepress/components/CategoryList.data.ts index 1fa2e449a..cb63e9a05 100644 --- a/docs/.vitepress/components/CategoriesList.data.ts +++ b/docs/.vitepress/components/CategoryList.data.ts @@ -1,5 +1,6 @@ import fs from 'fs' import path from 'path' +import { getAllData } from '../lib/icons'; export function getAllCategoryFiles() { const fileNames = fs.readdirSync(path.join('../categories')).filter((file) => path.extname(file) === '.json'); @@ -15,8 +16,20 @@ export function getAllCategoryFiles() { export default { async load() { + const icons = await getAllData() + const categories = getAllCategoryFiles() + + const categoryIconCounts = Object.fromEntries( + categories.map(({ name }) => { + const categoryIcons = icons.filter(({ categories }) => categories.includes(name)) + + return [name, categoryIcons.length]; + }) + ) + return { - categories: getAllCategoryFiles(), + categories, + categoryIconCounts, } } } diff --git a/docs/.vitepress/components/CategoriesList.vue b/docs/.vitepress/components/CategoryList.vue similarity index 85% rename from docs/.vitepress/components/CategoriesList.vue rename to docs/.vitepress/components/CategoryList.vue index 48f686b53..fab128ebe 100644 --- a/docs/.vitepress/components/CategoriesList.vue +++ b/docs/.vitepress/components/CategoryList.vue @@ -6,13 +6,10 @@ import VPLink from 'vitepress/dist/client/theme-default/components/VPLink.vue' import { isActive } from 'vitepress/dist/client/theme-default/support/utils' import { onContentUpdated } from 'vitepress' import { useActiveAnchor } from '../composables/useActiveAnchor' -import { data } from './CategoriesList.data' -import { useRouter } from 'vitepress'; +import { data } from './CategoryList.data' +import CategoryListItem from './CategoryListItem.vue' - -const { go } = useRouter() - -const { frontmatter, theme, params, page } = useData() +const { page } = useData() const categoriesIsActive = computed(() => { return isActive(page.value.relativePath, '/icons/categories'); @@ -22,17 +19,6 @@ const overviewIsActive = computed(() => { return isActive(page.value.relativePath, '/icons/'); }); -interface Header { - level: number - title: string - slug: string - link: string - children: Header[] -} -type MenuItem = Omit & { - children?: MenuItem[] -} - const headers = computed(() => { const linkPrefix = page.value.relativePath.startsWith('icons/categories') ? '' : '/icons/categories' @@ -61,7 +47,7 @@ useActiveAnchor(container, marker)
diff --git a/docs/.vitepress/components/CategoryListItem.vue b/docs/.vitepress/components/CategoryListItem.vue new file mode 100644 index 000000000..7018eefa7 --- /dev/null +++ b/docs/.vitepress/components/CategoryListItem.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/docs/.vitepress/components/EndOfPage.vue b/docs/.vitepress/components/EndOfPage.vue new file mode 100644 index 000000000..64e6b4f45 --- /dev/null +++ b/docs/.vitepress/components/EndOfPage.vue @@ -0,0 +1,15 @@ + + + diff --git a/docs/.vitepress/components/IconsCategoryOverview.vue b/docs/.vitepress/components/IconsCategoryOverview.vue index 7f80f2ce4..ceb5bf3ce 100644 --- a/docs/.vitepress/components/IconsCategoryOverview.vue +++ b/docs/.vitepress/components/IconsCategoryOverview.vue @@ -1,58 +1,97 @@ @@ -60,7 +99,6 @@ const activeIcon = computed(() => .icons { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); - /* padding: 32px 32px 96px; */ gap: 8px; width: 100%; } @@ -77,4 +115,24 @@ const activeIcon = computed(() => .category { margin-bottom: 32px; } + +.input-wrapper:deep(.input) { + padding: 12px 24px; + font-size: 14px; + height: 48px; +} + +.input-wrapper { + margin-bottom: 16px; +} + +.hidden-category { + clip: rect(0 0 0 0); + clip-path: inset(50%); + height: 1px; + overflow: hidden; + position: absolute; + white-space: nowrap; + width: 1px; +} diff --git a/docs/.vitepress/components/IconsOverview.vue b/docs/.vitepress/components/IconsOverview.vue index 7277b365b..c2ab52b33 100644 --- a/docs/.vitepress/components/IconsOverview.vue +++ b/docs/.vitepress/components/IconsOverview.vue @@ -1,11 +1,13 @@ diff --git a/docs/.vitepress/composables/useActiveAnchor.ts b/docs/.vitepress/composables/useActiveAnchor.ts index aa5db16c0..68586b6aa 100644 --- a/docs/.vitepress/composables/useActiveAnchor.ts +++ b/docs/.vitepress/composables/useActiveAnchor.ts @@ -1,6 +1,10 @@ import { onMounted, onUpdated, onUnmounted } from 'vue'; import { throttleAndDebounce } from 'vitepress/dist/client/theme-default/support/utils' +/* +* This file is compied and adjusted from vitepress/dist/client/theme-default/composables/useActiveAnchor.ts +*/ + export function useActiveAnchor(container, marker) { const onScroll = throttleAndDebounce(setActiveLink, 100); let prevActiveLink = null; diff --git a/docs/.vitepress/composables/useCategoryView.ts b/docs/.vitepress/composables/useCategoryView.ts new file mode 100644 index 000000000..ca7f9899d --- /dev/null +++ b/docs/.vitepress/composables/useCategoryView.ts @@ -0,0 +1,27 @@ +/* eslint-disable no-console */ + +import { + ref, inject, Ref +} from 'vue'; + +export const CATEGORY_VIEW_CONTEXT = Symbol('categoryView'); + +interface CategoryViewContext { + selectedCategory: Ref + categoryCounts: Ref> +} + +export const categoryViewContext = { + selectedCategory: ref(''), + categoryCounts: ref({}), +}; + +export function useCategoryView(): CategoryViewContext { + const context = inject(CATEGORY_VIEW_CONTEXT); + + if (!context) { + throw new Error('useCategoryView must be used with categoryView context'); + } + + return context; +} diff --git a/docs/.vitepress/composables/useIconStyle.ts b/docs/.vitepress/composables/useIconStyle.ts index 3df4144df..e6b631bbe 100644 --- a/docs/.vitepress/composables/useIconStyle.ts +++ b/docs/.vitepress/composables/useIconStyle.ts @@ -1,7 +1,7 @@ /* eslint-disable no-console */ import { - ref, provide, inject, Ref + ref, inject, Ref } from 'vue'; export const ICON_STYLE_CONTEXT = Symbol('size'); @@ -12,18 +12,12 @@ interface IconSizeContext { color: Ref } -export const context = { +export const iconStyleContext = { size: ref(24), strokeWidth: ref(2), color: ref('currentColor'), }; -export function useIconStyleProvider(): IconSizeContext { - provide(ICON_STYLE_CONTEXT, context); - - return context; -} - export function useIconStyleContext(): IconSizeContext{ const context = inject(ICON_STYLE_CONTEXT); diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index 0a7ea527e..650eeba3f 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -4,7 +4,8 @@ import './style.css' import { Theme } from 'vitepress' import IconsSidebarNavAfter from './layouts/IconsSidebarNavAfter.vue' import HomeHeroIconsCard from '../components/HomeHeroIconsCard.vue' -import { ICON_STYLE_CONTEXT, context } from '../composables/useIconStyle' +import { ICON_STYLE_CONTEXT, iconStyleContext } from '../composables/useIconStyle' +import { CATEGORY_VIEW_CONTEXT, categoryViewContext } from '../composables/useCategoryView' const theme: Partial = { extends: DefaultTheme, @@ -15,7 +16,8 @@ const theme: Partial = { }) }, enhanceApp({ app }) { - app.provide(ICON_STYLE_CONTEXT, context) + app.provide(ICON_STYLE_CONTEXT, iconStyleContext) + app.provide(CATEGORY_VIEW_CONTEXT, categoryViewContext) } } diff --git a/docs/.vitepress/theme/layouts/IconsSidebarNavAfter.vue b/docs/.vitepress/theme/layouts/IconsSidebarNavAfter.vue index aadf17fd1..ab3f3ce99 100644 --- a/docs/.vitepress/theme/layouts/IconsSidebarNavAfter.vue +++ b/docs/.vitepress/theme/layouts/IconsSidebarNavAfter.vue @@ -3,7 +3,7 @@ import { onMounted } from 'vue' import { useData } from 'vitepress' import { useSidebar } from 'vitepress/dist/client/theme-default/composables/sidebar.js' -import CategoriesList from '../../components/CategoriesList.vue' +import CategoryList from '../../components/CategoryList.vue' import IconCustomizer from '../../components/IconCustomizer.vue' const { frontmatter, page } = useData() @@ -19,6 +19,6 @@ onMounted(() => { diff --git a/docs/.vitepress/theme/style.css b/docs/.vitepress/theme/style.css index 90568194f..373f92f7c 100644 --- a/docs/.vitepress/theme/style.css +++ b/docs/.vitepress/theme/style.css @@ -83,7 +83,7 @@ position: relative; } } - +/* html:has(* .outline-link:target) { scroll-behavior: smooth; -} +} */ diff --git a/docs/package.json b/docs/package.json index fbf4b62a7..18273d807 100644 --- a/docs/package.json +++ b/docs/package.json @@ -26,14 +26,15 @@ }, "dependencies": { "@headlessui/vue": "^1.7.13", + "@vueuse/components": "^10.1.0", "@vueuse/core": "^10.1.0", "element-to-path": "^1.2.1", "fuse.js": "^6.5.3", "js-yaml": "^4.1.0", "jszip": "^3.7.0", "lodash-es": "^4.17.21", - "lucide-vue-next": "workspace:*", "lucide-react": "workspace:*", + "lucide-vue-next": "workspace:*", "react": "^18.2.0", "react-dom": "^18.2.0", "svg-pathdata": "^6.0.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7a566859f..63c5fec51 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -46,6 +46,9 @@ importers: '@headlessui/vue': specifier: ^1.7.13 version: 1.7.13(vue@3.2.47) + '@vueuse/components': + specifier: ^10.1.0 + version: 10.1.0(vue@3.2.47) '@vueuse/core': specifier: ^10.1.0 version: 10.1.0(vue@3.2.47) @@ -10265,6 +10268,17 @@ packages: vue: 3.2.45 dev: true + /@vueuse/components@10.1.0(vue@3.2.47): + resolution: {integrity: sha512-U3c5tPUAxfwWoBSpFbCNFMEM8/jSZ0+5M1n9YWcahyb+uRNo4UmsofX/Hzs6K56PSm0g+uuhZVwSnMq8ttD8Lw==} + dependencies: + '@vueuse/core': 10.1.0(vue@3.2.47) + '@vueuse/shared': 10.1.0(vue@3.2.47) + vue-demi: 0.14.0(vue@3.2.47) + transitivePeerDependencies: + - '@vue/composition-api' + - vue + dev: false + /@vueuse/core@10.1.0(vue@3.2.47): resolution: {integrity: sha512-3Znoa5m5RO+z4/C9w6DRaKTR3wCVJvD5rav8HTDGsr+7rOZRHtcgFJ8NcCs0ZvIpmev2kExTa311ns5j2RbzDQ==} dependencies: