Skip to content

Commit

Permalink
♻️ [libraryOverview] update to composition API
Browse files Browse the repository at this point in the history
  • Loading branch information
jxn-30 committed Jul 8, 2023
1 parent 7499b09 commit 938a694
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 56 deletions.
73 changes: 27 additions & 46 deletions src/components/libraryOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
</label>
<ul class="auto-sized-grid">
<li
v-for="libraryName in librariesFiltered"
:key="libraryName"
:library="(lib = libraries[libraryName])"
v-for="lib in librariesFiltered"
:key="lib.package"
class="card"
>
<a :href="lib.url" class="lightbox-open">
Expand All @@ -22,18 +21,18 @@
lib.icon ||
'https://github.githubassets.com/pinned-octocat.svg'
"
:alt="libraryName"
:alt="lib.package"
/>
</a>
<div class="linebreak"></div>
<a
:href="
lib.url || `https://yarnpkg.com/package/${libraryName}`
lib.url || `https://yarnpkg.com/package/${lib.package}`
"
class="lightbox-open"
>
<h4>
<b>{{ libraryName }}</b>
<b>{{ lib.package }}</b>
</h4>
</a>
<div class="linebreak"></div>
Expand All @@ -46,50 +45,32 @@
</lightbox>
</template>

<script lang="ts">
import Vue from 'vue';
<script setup lang="ts">
import { computed, ref } from 'vue';
import libraries from '../generated/libraries.json';
import Lightbox from /* webpackChunkName: "components/lightbox" */ './lightbox.vue';
import type { DefaultMethods, DefaultProps } from 'vue/types/options';
import type {
LibraryOverviewComputed,
LibraryOverviewData,
} from 'typings/components/LibraryOverview';
const librarySearch = ref('');
export default Vue.extend<
LibraryOverviewData,
DefaultMethods<Vue>,
LibraryOverviewComputed,
DefaultProps
>({
name: 'libraryOverview',
components: {
Lightbox: () =>
import(
/* webpackChunkName: "components/lightbox" */ './lightbox.vue'
),
},
data() {
return {
librarySearch: '',
libraries,
};
},
computed: {
librariesFiltered(): string[] {
return Object.keys(libraries)
.sort()
.filter(m =>
this.librarySearch.length > 0
? m
.toLowerCase()
.match(this.librarySearch.toLowerCase())
: true
);
},
},
});
const libraryNames = Object.keys(
libraries
).sort() as (keyof typeof libraries)[];
const librariesFiltered = computed(() =>
libraryNames
.filter(m =>
librarySearch.value.length > 0
? m.toLowerCase().match(librarySearch.value.toLowerCase())
: true
)
.map(libraryName => ({
url: '',
icon: '',
...libraries[libraryName],
package: libraryName,
}))
);
</script>

<style scoped lang="sass">
Expand Down
10 changes: 0 additions & 10 deletions typings/components/LibraryOverview.d.ts

This file was deleted.

0 comments on commit 938a694

Please sign in to comment.