mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-23 11:09:27 +01:00
Add call for iconNodes
This commit is contained in:
21
docs/.vitepress/theme/components/icons/IconsOverview.data.ts
Normal file
21
docs/.vitepress/theme/components/icons/IconsOverview.data.ts
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import { getAllData } from '../../../lib/icons';
|
||||||
|
import { getAllCategoryFiles, mapCategoryIconCount } from '../../../lib/categories';
|
||||||
|
import iconsMetaData from '../../../data/iconMetaData';
|
||||||
|
import { fetchAllReleases } from '../../../../scripts/writeReleaseMetadata.mts';
|
||||||
|
import { satisfies } from 'semver';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
async load() {
|
||||||
|
const versions = await fetchAllReleases();
|
||||||
|
|
||||||
|
const mappedVersions = versions
|
||||||
|
.map((tag) => tag.replace('v', ''))
|
||||||
|
.reverse()
|
||||||
|
|
||||||
|
mappedVersions.length = 100
|
||||||
|
|
||||||
|
return {
|
||||||
|
versions: mappedVersions,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -11,12 +11,13 @@ import useSearchShortcut from '../../utils/useSearchShortcut';
|
|||||||
import StickyBar from './StickyBar.vue';
|
import StickyBar from './StickyBar.vue';
|
||||||
import useFetchTags from '../../composables/useFetchTags';
|
import useFetchTags from '../../composables/useFetchTags';
|
||||||
import useFetchCategories from '../../composables/useFetchCategories';
|
import useFetchCategories from '../../composables/useFetchCategories';
|
||||||
import useFetchReleaseInfo from '../../composables/useFetchReleaseInfo';
|
import useFetchVersionIcons from '../../composables/useFetchVersionIcons';
|
||||||
import chunkArray from '../../utils/chunkArray';
|
import chunkArray from '../../utils/chunkArray';
|
||||||
import CarbonAdOverlay from './CarbonAdOverlay.vue';
|
import CarbonAdOverlay from './CarbonAdOverlay.vue';
|
||||||
import VersionSelect from './VersionSelect.vue';
|
import VersionSelect from './VersionSelect.vue';
|
||||||
import { sort, satisfies } from 'semver';
|
import { sort, satisfies } from 'semver';
|
||||||
import useSearchPlaceholder from '../../utils/useSearchPlaceholder.ts';
|
import useSearchPlaceholder from '../../utils/useSearchPlaceholder.ts';
|
||||||
|
import { data as versionData } from './IconsOverview.data';
|
||||||
|
|
||||||
const ICON_SIZE = 56;
|
const ICON_SIZE = 56;
|
||||||
const ICON_GRID_GAP = 8;
|
const ICON_GRID_GAP = 8;
|
||||||
@@ -35,11 +36,15 @@ const props = defineProps<{
|
|||||||
}>();
|
}>();
|
||||||
|
|
||||||
const activeIconName = ref(null);
|
const activeIconName = ref(null);
|
||||||
const selectedVersion = ref('Latest version');
|
const selectedVersion = ref();
|
||||||
|
|
||||||
const { execute: fetchTags, data: tags } = useFetchTags();
|
const { execute: fetchTags, data: tags } = useFetchTags();
|
||||||
const { execute: fetchCategories, data: categories } = useFetchCategories();
|
const { execute: fetchCategories, data: categories } = useFetchCategories();
|
||||||
const { execute: fetchReleaseInfo, data: releaseInfo } = useFetchReleaseInfo();
|
const { execute: fetchVersionIcons, data: versionIcons } = useFetchVersionIcons(selectedVersion);
|
||||||
|
|
||||||
|
watch(selectedVersion, () => {
|
||||||
|
fetchVersionIcons();
|
||||||
|
});
|
||||||
|
|
||||||
const overviewEl = ref<HTMLElement | null>(null);
|
const overviewEl = ref<HTMLElement | null>(null);
|
||||||
const { width: containerWidth } = useElementSize(overviewEl);
|
const { width: containerWidth } = useElementSize(overviewEl);
|
||||||
@@ -64,28 +69,16 @@ const mappedIcons = computed(() => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedVersion.value === 'Latest version' || releaseInfo.value == null) {
|
if (selectedVersion.value == null || versionIcons.value == null) {
|
||||||
console.log('no release info');
|
console.log('no release info');
|
||||||
|
|
||||||
return icons;
|
return icons;
|
||||||
}
|
}
|
||||||
|
|
||||||
return icons.filter((icon) => {
|
return Object.values(versionIcons.value).filter(([name, iconNode]) => ({
|
||||||
return satisfies(releaseInfo.value[icon.name], `<=${selectedVersion.value}`);
|
name,
|
||||||
});
|
iconNode,
|
||||||
});
|
}));
|
||||||
|
|
||||||
const versions = computed(() => {
|
|
||||||
if (releaseInfo.value == null) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
const allVersions = Array.from<string>(
|
|
||||||
new Set(Object.values<string>(releaseInfo.value)).values(),
|
|
||||||
);
|
|
||||||
|
|
||||||
return sort(allVersions, {
|
|
||||||
loose: true,
|
|
||||||
}).reverse();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { searchInput, searchQuery, searchQueryDebounced } = useSearchInput();
|
const { searchInput, searchQuery, searchQueryDebounced } = useSearchInput();
|
||||||
@@ -135,11 +128,11 @@ function onFocusSearchInput() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFocusVersionSelect() {
|
// function onFocusVersionSelect() {
|
||||||
if (releaseInfo.value == null) {
|
// if (releaseInfo.value == null) {
|
||||||
fetchReleaseInfo();
|
// fetchReleaseInfo();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
const NoResults = defineAsyncComponent(() => import('./NoResults.vue'));
|
const NoResults = defineAsyncComponent(() => import('./NoResults.vue'));
|
||||||
|
|
||||||
@@ -172,8 +165,7 @@ function handleCloseDrawer() {
|
|||||||
/>
|
/>
|
||||||
<VersionSelect
|
<VersionSelect
|
||||||
v-model="selectedVersion"
|
v-model="selectedVersion"
|
||||||
:versions="versions"
|
:versions="versionData.versions"
|
||||||
@focus="onFocusVersionSelect"
|
|
||||||
/>
|
/>
|
||||||
</StickyBar>
|
</StickyBar>
|
||||||
<NoResults
|
<NoResults
|
||||||
|
|||||||
@@ -1,38 +1,38 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue';
|
||||||
import {
|
import {
|
||||||
Combobox,
|
Combobox,
|
||||||
ComboboxInput,
|
ComboboxInput,
|
||||||
ComboboxButton,
|
ComboboxButton,
|
||||||
ComboboxOptions,
|
ComboboxOptions,
|
||||||
ComboboxOption,
|
ComboboxOption,
|
||||||
} from '@headlessui/vue'
|
} from '@headlessui/vue';
|
||||||
|
|
||||||
import { chevronsUpDown, check } from '../../../data/iconNodes'
|
import { chevronsUpDown, check } from '../../../data/iconNodes';
|
||||||
import createLucideIcon from 'lucide-vue-next/src/createLucideIcon'
|
import createLucideIcon from 'lucide-vue-next/src/createLucideIcon';
|
||||||
|
|
||||||
const model = defineModel<string>()
|
const model = defineModel<string | undefined>();
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
versions: string[]
|
versions: string[];
|
||||||
}>()
|
}>();
|
||||||
|
|
||||||
let query = ref('')
|
let query = ref('');
|
||||||
|
|
||||||
let filteredVersions = computed(() =>
|
let filteredVersions = computed(() =>
|
||||||
query.value === ''
|
query.value === ''
|
||||||
? ['Latest version', ...props.versions]
|
? [...props.versions]
|
||||||
: props.versions.filter((version) =>
|
: props.versions.filter((version) =>
|
||||||
version
|
version
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.replace(/\s+/g, '')
|
.replace(/\s+/g, '')
|
||||||
.includes(query.value.toLowerCase().replace(/\s+/g, ''))
|
.includes(query.value.toLowerCase().replace(/\s+/g, '')),
|
||||||
)
|
),
|
||||||
)
|
);
|
||||||
|
|
||||||
const emit = defineEmits(['focus'])
|
const emit = defineEmits(['focus']);
|
||||||
|
|
||||||
const ChevronUpDown = createLucideIcon('ChevronUpDown', chevronsUpDown)
|
const ChevronUpDown = createLucideIcon('ChevronUpDown', chevronsUpDown);
|
||||||
const Check = createLucideIcon('Check', check)
|
const Check = createLucideIcon('Check', check);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@@ -46,11 +46,13 @@ const Check = createLucideIcon('Check', check)
|
|||||||
@focus="emit('focus')"
|
@focus="emit('focus')"
|
||||||
/>
|
/>
|
||||||
<ComboboxButton class="combobox-button">
|
<ComboboxButton class="combobox-button">
|
||||||
<ChevronUpDown class="icon-chevron" aria-hidden="true" />
|
<ChevronUpDown
|
||||||
|
class="icon-chevron"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
</ComboboxButton>
|
</ComboboxButton>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<ComboboxOptions class="combobox-options">
|
<ComboboxOptions class="combobox-options">
|
||||||
<div
|
<div
|
||||||
v-if="versions.length === 0 && query !== ''"
|
v-if="versions.length === 0 && query !== ''"
|
||||||
@@ -68,20 +70,23 @@ const Check = createLucideIcon('Check', check)
|
|||||||
>
|
>
|
||||||
<li
|
<li
|
||||||
class="combobox-option"
|
class="combobox-option"
|
||||||
:class="{ 'active': active }"
|
:class="{ active: active }"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
class="combobox-option-text"
|
class="combobox-option-text"
|
||||||
:class="{ 'selected': selected }"
|
:class="{ selected: selected }"
|
||||||
>
|
>
|
||||||
{{ version }}
|
{{ version }}
|
||||||
</span>
|
</span>
|
||||||
<span
|
<span
|
||||||
v-if="selected"
|
v-if="selected"
|
||||||
class="combobox-option-icon"
|
class="combobox-option-icon"
|
||||||
:class="{ 'active': active }"
|
:class="{ active: active }"
|
||||||
>
|
>
|
||||||
<Check class="icon-check" aria-hidden="true" />
|
<Check
|
||||||
|
class="icon-check"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
</ComboboxOption>
|
</ComboboxOption>
|
||||||
@@ -113,10 +118,11 @@ const Check = createLucideIcon('Check', check)
|
|||||||
line-height: 1.25rem;
|
line-height: 1.25rem;
|
||||||
color: var(--vp-c-text-1);
|
color: var(--vp-c-text-1);
|
||||||
border: 1px solid transparent;
|
border: 1px solid transparent;
|
||||||
transition: border-color .15s ease-in-out;
|
transition: border-color 0.15s ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
.combobox-input:hover, .combobox-input:focus {
|
.combobox-input:hover,
|
||||||
|
.combobox-input:focus {
|
||||||
border-color: var(--vp-c-brand);
|
border-color: var(--vp-c-brand);
|
||||||
background: var(--vp-c-bg-alt);
|
background: var(--vp-c-bg-alt);
|
||||||
}
|
}
|
||||||
@@ -129,7 +135,7 @@ const Check = createLucideIcon('Check', check)
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding-right: 0.5rem;
|
padding-right: 0.5rem;
|
||||||
z-index: 10;;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-chevron {
|
.icon-chevron {
|
||||||
@@ -173,7 +179,9 @@ const Check = createLucideIcon('Check', check)
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
transition: background-color .25s,color .25s;
|
transition:
|
||||||
|
background-color 0.25s,
|
||||||
|
color 0.25s;
|
||||||
}
|
}
|
||||||
|
|
||||||
.combobox-option.active {
|
.combobox-option.active {
|
||||||
@@ -207,7 +215,7 @@ const Check = createLucideIcon('Check', check)
|
|||||||
}
|
}
|
||||||
|
|
||||||
.icon-check {
|
.icon-check {
|
||||||
height:20px;
|
height: 20px;
|
||||||
width:20px;
|
width: 20px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
import { useFetch } from '@vueuse/core';
|
|
||||||
|
|
||||||
const useFetchTags = () =>
|
|
||||||
useFetch<Record<string, string>>(
|
|
||||||
`${import.meta.env.DEV ? 'http://localhost:3000' : ''}/api/release-info`,
|
|
||||||
{
|
|
||||||
immediate:
|
|
||||||
typeof window !== 'undefined' && new URLSearchParams(window.location.search).has('version'),
|
|
||||||
},
|
|
||||||
).json();
|
|
||||||
|
|
||||||
export default useFetchTags;
|
|
||||||
17
docs/.vitepress/theme/composables/useFetchVersionIcons.ts
Normal file
17
docs/.vitepress/theme/composables/useFetchVersionIcons.ts
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import { useFetch } from '@vueuse/core';
|
||||||
|
import { computed, Ref } from 'vue';
|
||||||
|
|
||||||
|
const useFetchVersionIcons = (version: Ref<string | undefined>) =>{
|
||||||
|
const fetchUrl = computed(() => {
|
||||||
|
if(version.value == null ) return ''
|
||||||
|
return `https://unpkg.com/lucide-static@${version.value}/icon-nodes.json`
|
||||||
|
})
|
||||||
|
return useFetch<Record<string, string>>(
|
||||||
|
fetchUrl,
|
||||||
|
{
|
||||||
|
refetch: true
|
||||||
|
}
|
||||||
|
).json();
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useFetchVersionIcons;
|
||||||
@@ -9,14 +9,14 @@
|
|||||||
"docs:build": "pnpm run /^prebuild:.*/ && vitepress build",
|
"docs:build": "pnpm run /^prebuild:.*/ && vitepress build",
|
||||||
"docs:preview": "vitepress preview",
|
"docs:preview": "vitepress preview",
|
||||||
"build:docs": "vitepress build",
|
"build:docs": "vitepress build",
|
||||||
"prebuild:iconNodes": "node ./scripts/writeIconNodes.mjs",
|
"prebuild:iconNodes": "node ./scripts/writeIconNodes.mts",
|
||||||
"prebuild:metaJson": "node ./scripts/writeIconMetaIndex.mjs",
|
"prebuild:metaJson": "node ./scripts/writeIconMetaIndex.mts",
|
||||||
"prebuild:releaseJson": "node ./scripts/writeReleaseMetadata.mjs",
|
"prebuild:releaseJson": "node ./scripts/writeReleaseMetadata.mts",
|
||||||
"prebuild:categoriesJson": "node ./scripts/writeCategoriesMetadata.mjs",
|
"prebuild:categoriesJson": "node ./scripts/writeCategoriesMetadata.mts",
|
||||||
"prebuild:relatedIcons": "node ./scripts/writeIconRelatedIcons.mjs",
|
"prebuild:relatedIcons": "node ./scripts/writeIconRelatedIcons.mts",
|
||||||
"prebuild:iconDetails": "node ./scripts/writeIconDetails.mjs",
|
"prebuild:iconDetails": "node ./scripts/writeIconDetails.mts",
|
||||||
"prebuild:brandStopwords": "node ./scripts/writeBrandStopwords.mjs",
|
"prebuild:brandStopwords": "node ./scripts/writeBrandStopwords.mts",
|
||||||
"postbuild:vercelJson": "node ./scripts/writeVercelOutput.mjs",
|
"postbuild:vercelJson": "node ./scripts/writeVercelOutput.mts",
|
||||||
"dev": "npx nitropack dev",
|
"dev": "npx nitropack dev",
|
||||||
"prebuild:api": "npx nitropack prepare",
|
"prebuild:api": "npx nitropack prepare",
|
||||||
"build:api": "npx nitropack build",
|
"build:api": "npx nitropack build",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ const getRelatedIcons = (currentIcon, icons) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const iconsMetaDataPromises = svgFiles.map(async (iconName) => {
|
const iconsMetaDataPromises = svgFiles.map(async (iconName) => {
|
||||||
const metaDataFileContent = await fs.promises.readFile(`../icons/${iconName}`);
|
const metaDataFileContent = await fs.promises.readFile(`../icons/${iconName}`, 'utf-8');
|
||||||
const metaData = JSON.parse(metaDataFileContent);
|
const metaData = JSON.parse(metaDataFileContent);
|
||||||
|
|
||||||
const name = iconName.replace('.json', '');
|
const name = iconName.replace('.json', '');
|
||||||
@@ -29,7 +29,7 @@ if (!fs.existsSync(releaseMetaDataDirectory)) {
|
|||||||
fs.mkdirSync(releaseMetaDataDirectory);
|
fs.mkdirSync(releaseMetaDataDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchAllReleases = async () => {
|
export const fetchAllReleases = async () => {
|
||||||
await git.fetch('https://github.com/lucide-icons/lucide.git', '--tags');
|
await git.fetch('https://github.com/lucide-icons/lucide.git', '--tags');
|
||||||
|
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
@@ -73,7 +73,7 @@ const comparisonsPromises = tags.map(async (tag, index) => {
|
|||||||
const comparisons = await Promise.all(comparisonsPromises);
|
const comparisons = await Promise.all(comparisonsPromises);
|
||||||
const newReleaseMetaData = {};
|
const newReleaseMetaData = {};
|
||||||
|
|
||||||
comparisons.forEach(({ tag, iconFiles, date } = {}) => {
|
comparisons.forEach(({ tag, iconFiles, date } = {} as typeof comparisons[number]) => {
|
||||||
if (tag == null) return;
|
if (tag == null) return;
|
||||||
|
|
||||||
iconFiles.forEach(({ status, file, renamedFile }) => {
|
iconFiles.forEach(({ status, file, renamedFile }) => {
|
||||||
@@ -11,7 +11,7 @@ const iconMetaData = await getIconMetaData(path.resolve(scriptDir, '../../icons'
|
|||||||
const iconAliasesRedirectRoutes = Object.entries(iconMetaData)
|
const iconAliasesRedirectRoutes = Object.entries(iconMetaData)
|
||||||
.filter(([, { aliases }]) => aliases?.length)
|
.filter(([, { aliases }]) => aliases?.length)
|
||||||
.map(([iconName, { aliases }]) => {
|
.map(([iconName, { aliases }]) => {
|
||||||
const aliasRouteMatches = aliases.map((alias) => alias.name).join('|');
|
const aliasRouteMatches = aliases.map((alias) => typeof alias === 'string' ? alias : alias.name).join('|');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
src: `/icons/${aliasRouteMatches}`,
|
src: `/icons/${aliasRouteMatches}`,
|
||||||
Reference in New Issue
Block a user