Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vue Rewrite] Explore Page styles and behavior #2376

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/Explore/feeds/feeds.en.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
{
"Nextcloud": [{
"title": "Nextcloud News",
"favicon": "https://nextcloud.com/wp-content/themes/next/assets/img/common/favicon-touch.png",
"url": "https://nextcloud.com/news/",
"feed": "https://nextcloud.com/blog/feed",
"description": "See what is going on in and around Nextcloud",
"votes": 1000
},
{
"title": "Nextcloud Podcast",
"favicon": "https://nextcloud.com/wp-content/themes/next/assets/img/common/favicon-touch.png",
"url": "https://nextcloud.com/podcast/",
"feed": "https://nextcloud.com/podcast-feed.rss",
"description": "Digital Sovereignty, self hosting, privacy and more",
Expand Down
13 changes: 12 additions & 1 deletion src/components/AddFeed.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ export default Vue.extend({
NcButton,
NcSelect,
},
props: {
feed: {
type: Object,
required: false,
default: () => {
return { url: '' }
},
},
},
data: (): AddFeedState => {
return {
folder: undefined,
Expand All @@ -152,7 +161,9 @@ export default Vue.extend({
},
},
created() {
if (this.$route.query.subscribe_to) {
if (this.feed.feed) {
this.feedUrl = this.feed.feed
} else if (this.$route.query.subscribe_to) {
this.feedUrl = this.$route.query.subscribe_to as string
}
},
Expand Down
115 changes: 101 additions & 14 deletions src/components/routes/Explore.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<template>
<div id="explore">
<AddFeed v-if="showAddFeed" :feed="feed" @close="closeShowAddFeed()" />
<div class="grid-container">
<div v-if="!exploreSites" style="margin: auto;">
{{ t('news', 'No feeds found to add') }}
</div>
<div v-else class="grid-container">
<div v-for="entry in exploreSites"
:key="entry.title"
class="explore-feed grid-item">
<h2 v-if="entry.favicon"
class="explore-title"
class="explore-title icon"
:style="{ backgroundImage: 'url(' + entry.favicon + ')' }">
<a target="_blank" rel="noreferrer" :href="entry.url">
{{ entry.title }}
Expand All @@ -15,14 +18,14 @@
<h2 v-if="!entry.favicon" class="icon-rss explore-title">
{{ entry.title }}
</h2>
<div class="explore-content">
<div class="explore-content" style="flex-grow: 1">
<p>{{ entry.description }}</p>

<div class="explore-logo">
<div v-if="entry.image" class="explore-logo">
<img :src="entry.image">
</div>
</div>
<NcButton @click="subscribe(entry.feed)">
<NcButton style="max-width: 100%;" @click="subscribe(entry)">
{{ t("news", "Subscribe to") }} {{ entry.title }}
</NcButton>
</div>
Expand All @@ -48,8 +51,12 @@ const ExploreComponent = Vue.extend({
NcButton,
AddFeed,
},
data: () => {
const exploreSites: ExploreSite[] = []
data: (): {
exploreSites: ExploreSite[] | undefined;
feed: Feed;
showAddFeed: boolean;
} => {
const exploreSites: ExploreSite[] | undefined = []
const feed: Feed = {} as Feed
const showAddFeed = false

Expand All @@ -68,15 +75,25 @@ const ExploreComponent = Vue.extend({
const settings = await axios.get(router.generateUrl('/apps/news/settings'))

const exploreUrl = settings.data.settings?.exploreUrl + 'feeds.en.json'
const explore = await axios.get(exploreUrl)
try {
const explore = await axios.get(exploreUrl)

Object.keys(explore.data).forEach((key) =>
explore.data[key].forEach((value: ExploreSite) => {
if (this.exploreSites) {
this.exploreSites.push(value)
} else {
this.exploreSites = [value]
}
},
),
)
} catch {
this.exploreSites = undefined
}

Object.keys(explore.data).forEach((key) =>
explore.data[key].forEach((value: ExploreSite) =>
this.exploreSites.push(value),
),
)
},
async subscribe(feed: Feed) {
subscribe(feed: Feed) {
this.feed = feed
this.showAddFeed = true
},
Expand All @@ -89,3 +106,73 @@ const ExploreComponent = Vue.extend({
export default ExploreComponent

</script>

<style scoped>
#explore {
height: 100%;
width: 100%;
padding: 45px 0 45px 45px;
display: flex;
justify-items: center;
}

#explore .grid-container {
display:flex;
flex-wrap: wrap;
}

#explore .grid-item {
width: 300px;
border: 2px solid var(--color-border);
border-radius: var(--border-radius-large);
margin: 0 24px 24px 0;
padding: 24px;
flex-grow: 1;
max-width: calc(50% - 24px);
display: flex;
flex-direction: column;
}

#explore .grid-item .explore-title {
background-repeat: no-repeat;
background-position: 0 center;
background-size: 24px;
}

#explore .grid-item .explore-title.icon {
padding-left: 32px;
}

#explore .grid-item .explore-title a {
word-wrap: break-word;
}

#explore .grid-item .explore-title a:hover,
#explore .grid-item .explore-title a:focus {
text-decoration: underline;
}

#explore .grid-item .explore-logo {
text-align: center;
margin-top: 25px;
}

#explore .grid-item .explore-logo img {
width: 100%;
}

#explore .grid-item .explore-subscribe {
margin-top: 16px;
max-width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

#explore .grid-item .explore-content {
justify-content: center;
display: flex;
flex-direction: column;
margin-bottom: 10px;
}
</style>