Skip to content

Commit

Permalink
feat: APPS-2411 Use nuxt/appollo composable to fetch data for the hom…
Browse files Browse the repository at this point in the history
…epage (#752)

* feat: Add useAsyncQuery wrapper for useasyncdata by nuxt/appollo to make gragphQL queries to craft

* ci: update job name

* fix: linting errors
  • Loading branch information
pghorpade authored Nov 7, 2023
1 parent a46bd3e commit d62b4eb
Show file tree
Hide file tree
Showing 10 changed files with 810 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
run: |
echo "ES_INDEX=${{secrets.ES_INDEX_TEST}}-deploy-preview" >> $GITHUB_ENV
if: github.ref_name!='nuxt3.x'
- name: Sets env vars for main merge
- name: Sets env vars for nuxt3.x merge
run: |
echo "ES_INDEX=${{secrets.ES_INDEX_TEST}}" >> $GITHUB_ENV
if: github.ref_name=='nuxt3.x'
Expand Down
2 changes: 1 addition & 1 deletion gql/queries/Homepage.gql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "~/gql/fragments/Image"
#import "../gql/fragments/Image.gql"

query Homepage {
entry(section: "homepage") {
Expand Down
16 changes: 8 additions & 8 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ const classes = computed(() => [
<div :class="classes">
<!-- VueSkipTo to="#main" label="Skip to main content" / -->
<!-- this is not working in static build -->
<!-- header-smart / -->
<header-smart />

<!-- section-wrapper class="section-alert" theme="divider" -->
<site-notification-alert v-if="libraryAlert" class="library-alert" v-bind="libraryAlert" />
<!-- /section-wrapper -->
<section-wrapper class="section-alert" theme="divider">
<site-notification-alert v-if="libraryAlert" class="library-alert" v-bind="libraryAlert" />
</section-wrapper>

<slot />

<!-- footer>
<footer-primary :form="true" />
<footer-sock />
</footer -->
<footer>
<footer-primary :form="true" />
<footer-sock />
</footer>
<div id="libchat_5a44dfe7cc29aaee5bba635ab13fa753" />
</div>
</template>
Expand Down
45 changes: 23 additions & 22 deletions layouts/impact.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script setup>
// MOCK DATA
import * as MOCK_API from '~/data/mock-api.json'
/* const footerPrimaryItems = [...MOCK_API.shortLinks]
const footerPrimaryItems = [...MOCK_API.shortLinks]
const parsedItems = computed(() => {
// Restructuring item to support text key
return footerPrimaryItems.map((obj) => {
Expand All @@ -20,13 +21,14 @@ const parsedPressItems = computed(() => {
text: obj.name,
}
})
}) */
})
const globalStore = useGlobalStore()
const classes = computed(() => [
'layout',
'layout-default',
{ 'has-scrolled': sTop.value },
{ 'has-scrolled-past-header': sTop.value >= 150 }
{ 'has-scrolled': globalStore.sTop },
{ 'has-scrolled-past-header': globalStore.sTop >= 150 }
])
useHead({
Expand All @@ -36,32 +38,31 @@ useHead({

<template>
<div :class="classes">
<!-- nav-primary class="primary" / -->
<main>
<slot />
</main>
<nav-primary class="primary" />

<slot />

<!-- footer-primary :social-items="parsedItems" :press-items="parsedPressItems" :form="false" / -->
<footer-primary :social-items="parsedItems" :press-items="parsedPressItems" :form="false" />
</div>
</template>

<style lang="scss" scoped>
.layout-default {
min-height: 100vh;
min-height: 100vh;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: space-between;
align-content: center;
align-items: center;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: space-between;
align-content: center;
align-items: center;
> * {
width: 100%;
}
>* {
width: 100%;
}
.page {
flex: 1 1 auto;
}
.page {
flex: 1 1 auto;
}
}
</style>
2 changes: 1 addition & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default defineNuxtConfig({
],

imports: {
dirs: ['stores', 'gql'],
dirs: ['stores'],
},

apollo: {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"nuxt": "^v3.7.3",
"sass": "^1.66.1",
"ucla-library-design-tokens": "^5.5.0",
"ucla-library-website-components": "2.39.0-alpha.10"
"ucla-library-website-components": "2.39.0-alpha.15",
"lodash": "^4.17.21"
}
}
122 changes: 120 additions & 2 deletions pages/components.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,100 @@ const propsForMediaWithText = {
}
const itemVideo = MEDIA.VideoFile
const coverImage = MEDIA.VideoFileCoverImage
const mockStaff = {
subjectArea: 'African American Studies',
nameFirst: 'Ariane',
nameLast: 'Bicho',
to: '/about/staff/ariane-bicho',
staffName: 'Ariane Bicho 娘の洋子より',
image: null,
jobTitle: 'Director of Communications and Marketing',
departments: [
{
id: '7272',
title: 'Communications',
},
{
id: '7373',
title: 'Marketing',
},
],
alternativeName: [
{
fullName: '娘の洋子より',
languageAltName: 'zh',
},
],
uri: 'about/staff/ariane-bicho',
phone: '(222) 444-5555',
email: '[email protected]',
consultation: 'https://calendar.library.ucla.edu/appointments/aogarcia',
academicDepartments: [
{
id: '11947',
title: 'African American Studies',
},
{
id: '11955',
title: 'Cluster 60: America in Sixties: Politics, Society, and Culture, 1954 to 1974',
},
],
locations: [
{
title: 'DIIT',
to: 'location/bar',
},
],
}
const mockStaff2 = {
title: 'Humanities and Social Sciences Librarian',
alternativeFullName: '陳餘敏卿纪念基金',
language: 'zh',
text:
'<p><span>The UCLA Library seeks a highly collaborative, user-focused professional for the position of Humanities and Social Sciences Librarian. The incumbent will join a multi-location, cross disciplinary team that supports teaching and all levels of research in the humanities and social sciences. </span><span>Note: Two positions are being filled.</span><br /></p>',
jobType: [
{
title: 'Academic Librarian',
},
],
jobRequisitionNumber: 'JPF08053',
jobPostingURL: 'https://recruit.apo.ucla.edu/JPF08053',
department: [
{
title: 'User Engagement',
},
{
title: 'Human Resources',
},
],
associatedLocations: [
{
title: 'UCLA Film & Television Archive',
uri: 'visit/locations/film-television-archive',
},
{
title: 'Powell Library',
uri: 'visit/locations/powell-library',
},
],
}
const amenities = [
'icon-clock',
'icon-accessible',
'icon-chair',
'icon-virtual',
'icon-laptop',
'icon-locker',
'icon-light',
'icon-share-printer',
'icon-book',
]
</script>

<template>
<div>
<div class="components">
<hr>
<h2>DividerGeneral Component</h2>
<DividerGeneral />
Expand Down Expand Up @@ -126,7 +216,35 @@ const coverImage = MEDIA.VideoFileCoverImage
<BlockCallToActionTwoUp :items="mockItemsBlockCallToActionTwoUp" />
<hr>
<br>
<br>
<h2>BlockStaffSubjectLibrarian Component</h2>
<table>
<tbody>
<BlockStaffSubjectLibrarian v-bind="mockStaff" />
</tbody>
</table>
<br>
<hr>
<br>
<h2>BlockGenericList Component</h2>
<ul>
<BlockGenericList v-bind="mockStaff2" />
</ul>
<br>
<hr>
<br>
<block-amenities :amenities="amenities" />
<br>
<br>
</div>
</template>

<style scoped></style>
<style scoped>
div.components,
ul,
li,
div,
table {
margin: 20px;
}
</style>
Loading

0 comments on commit d62b4eb

Please sign in to comment.