Skip to content

Commit

Permalink
fix: Refactor components in widget to show articles (#7874)
Browse files Browse the repository at this point in the history
  • Loading branch information
nithindavid committed Sep 11, 2023
1 parent 8d43101 commit 6c39aed
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 23 deletions.
30 changes: 20 additions & 10 deletions app/javascript/widget/components/ArticleCategoryCard.vue
@@ -1,21 +1,27 @@
<template>
<div class="py-2">
<h3 class="text-sm font-semibold text-slate-900 mb-0">{{ title }}</h3>
<article-list :articles="articles" />
<div>
<h3 class="text-base font-medium text-slate-900 dark:text-slate-50 mb-0">
{{ title }}
</h3>
<article-list :articles="articles" @click="onArticleClick" />
<button
class="inline-flex text-sm font-medium rounded-md px-2 py-1 -ml-2 leading-6 text-slate-800 justify-between items-center hover:bg-slate-25 see-articles"
@click="$emit('view-all-articles')"
class="inline-flex text-sm font-medium rounded-md px-2 py-1 -ml-2 leading-6 text-slate-800 dark:text-slate-50 justify-between items-center hover:bg-slate-25 dark:hover:bg-slate-800 see-articles"
:style="{ color: widgetColor }"
@click="$emit('view-all')"
>
<span class="pr-2">{{ $t('PORTAL.VIEW_ALL_ARTICLES') }}</span>
<span class="pr-2 text-sm">{{ $t('PORTAL.VIEW_ALL_ARTICLES') }}</span>
<fluent-icon icon="arrow-right" size="14" />
</button>
</div>
</template>

<script>
import { mapGetters } from 'vuex';
import ArticleList from './ArticleList.vue';
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
export default {
components: { ArticleList },
components: { FluentIcon, ArticleList },
props: {
title: {
type: String,
Expand All @@ -25,9 +31,13 @@ export default {
type: Array,
default: () => [],
},
categoryPath: {
type: String,
default: '',
},
computed: {
...mapGetters({ widgetColor: 'appConfig/getWidgetColor' }),
},
methods: {
onArticleClick(link) {
this.$emit('view', link);
},
},
};
Expand Down
20 changes: 11 additions & 9 deletions app/javascript/widget/components/ArticleHero.vue
@@ -1,13 +1,10 @@
<template>
<div>
<h2 class="text-base font-bold leading-6 text-slate-800 mb-0">
{{ $t('PORTAL.POPULAR_ARTICLES') }}
</h2>
<category-card
:articles="articles.slice(0, 4)"
@view-all-articles="$emit('view-all-articles')"
/>
</div>
<category-card
:title="$t('PORTAL.POPULAR_ARTICLES')"
:articles="articles.slice(0, 4)"
@view-all="$emit('view-all')"
@view="onArticleClick"
/>
</template>

<script>
Expand All @@ -24,6 +21,11 @@ export default {
default: '',
},
},
methods: {
onArticleClick(link) {
this.$emit('view', link);
},
},
};
</script>

Expand Down
3 changes: 2 additions & 1 deletion app/javascript/widget/components/ArticleList.vue
Expand Up @@ -2,13 +2,14 @@
<ul role="list" class="py-2">
<article-list-item
v-for="article in articles"
:key="article.id"
:key="article.slug"
:link="article.link"
:title="article.title"
@click="onClick"
/>
</ul>
</template>

<script>
import ArticleListItem from './ArticleListItem';
Expand Down
11 changes: 8 additions & 3 deletions app/javascript/widget/components/ArticleListItem.vue
@@ -1,20 +1,25 @@
<template>
<li
class="py-1 flex items-center justify-between -mx-1 px-1 hover:bg-slate-25"
class="py-1 flex items-center justify-between -mx-1 px-1 hover:bg-slate-75 dark:hover:bg-slate-600 rounded cursor-pointer text-slate-700 dark:text-slate-50 dark:hover:text-slate-25 hover:text-slate-900 "
@click="onClick"
>
<button
class="text-slate-700 hover:text-slate-900 underline-offset-2 text-sm leading-6"
class="underline-offset-2 text-sm leading-6 text-left"
@click="onClick"
>
{{ title }}
</button>
<span class="pl-1 text-slate-700 arrow">
<span class="pl-1 arrow">
<fluent-icon icon="arrow-right" size="14" />
</span>
</li>
</template>

<script>
import FluentIcon from 'shared/components/FluentIcon/Index.vue';
export default {
components: { FluentIcon },
props: {
link: {
type: String,
Expand Down

0 comments on commit 6c39aed

Please sign in to comment.