-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from nih-sparc/ListCard
listcard and listcarditem migrated
- Loading branch information
Showing
3 changed files
with
289 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<template> | ||
<el-table | ||
class="sparc-design-system-list-card-table" | ||
:data="data" | ||
:show-header="false" | ||
empty-text="No Results" | ||
> | ||
<el-table-column> | ||
<template v-slot="scope"> | ||
<el-row> | ||
<list-card-item | ||
:title="scope.row.title" | ||
:summary="scope.row.summary" | ||
:url="scope.row.url" | ||
:date="scope.row.date" | ||
:image="scope.row.image" | ||
/> | ||
</el-row> | ||
<el-row v-if="sectionText && scope.$index === data.length-1"> | ||
<div class="section-container"> | ||
<a class="section-text" v-if="sectionUrl" :href="sectionUrl"> | ||
{{sectionText}} | ||
</a> | ||
<h3 v-else class="section-text"> | ||
{{sectionText}} | ||
</h3> | ||
</div> | ||
</el-row> | ||
</template> | ||
</el-table-column> | ||
</el-table> | ||
</template> | ||
|
||
<script> | ||
import ListCardItem from './ListCardItem.vue' | ||
export default { | ||
components: { ListCardItem }, | ||
name: 'ListCard', | ||
props: { | ||
data: { | ||
type: Array, | ||
default: () => [], | ||
required: true | ||
}, | ||
sectionText: { | ||
type: String, | ||
default: "" | ||
}, | ||
sectionUrl: { | ||
type: String, | ||
default: "" | ||
} | ||
} | ||
} | ||
</script> | ||
<style lang="scss"> | ||
.sparc-design-system-list-card-table::before { | ||
display: none; | ||
} | ||
.sparc-design-system-list-card-table td.el-table__cell { | ||
border: none; | ||
padding: 0; | ||
} | ||
.sparc-design-system-list-card-table tbody { | ||
tr:not(:last-child)>td .cell::after { | ||
content: ""; | ||
border-bottom: 2px solid #D8D8D8; | ||
width: 100%; | ||
margin: 0 auto; | ||
display: block; | ||
} | ||
tr:last-of-type>td { | ||
background-color: white !important; | ||
} | ||
tr:last-of-type>td .cell { | ||
padding: 0; | ||
.list-item { | ||
padding-left: 1rem; | ||
padding-right: 1rem; | ||
} | ||
.list-item:hover { | ||
background-color: #F7FAFF; | ||
transition: background-color 0.25s ease; | ||
} | ||
} | ||
} | ||
</style> | ||
<style lang="scss" scoped> | ||
@import '../../assets/_variables.scss'; | ||
.sparc-design-system-list-card-table { | ||
border: 1px solid #DBDFE6; | ||
} | ||
.section-container { | ||
width:100%; | ||
border-top: 2px solid #D8D8D8; | ||
margin: 0 1rem; | ||
padding: 1.5rem 0 | ||
} | ||
.section-text { | ||
margin-left: 1rem; | ||
font-weight: bold; | ||
color: $darkBlue; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<template> | ||
<div class="list-item"> | ||
<el-row type="flex"> | ||
<el-col :xs="image === undefined ? 0 : 4" :sm="image === undefined ? 0 : 3" :md="image === undefined ? 0 : 2" :lg="image === undefined ? 0 : 2"> | ||
<img | ||
:src="image" | ||
class="list-card-image" | ||
/> | ||
</el-col> | ||
<el-col :xs="image === undefined ? 24 : 20" :sm="image === undefined ? 24 : 21" :md="image === undefined ? 24 : 22" :lg="image === undefined ? 24 : 22"> | ||
<div class="list-card-content"> | ||
<div class="body1 mt-0"> | ||
<a | ||
:href="url" | ||
:target="openInNewTab ? '_self' : '_blank'" | ||
> | ||
{{ title }} | ||
</a> | ||
</div> | ||
<div v-if="image !== undefined"> | ||
<p class="list-item__date spacing"> | ||
{{ formattedDate }} | ||
</p> | ||
<p class="spacing">{{ summary }}</p> | ||
</div> | ||
<div v-else> | ||
<p class="spacing">{{ summary }}</p> | ||
<p class="list-item__date spacing"> | ||
{{ formattedDate }} | ||
</p> | ||
</div> | ||
</div> | ||
</el-col> | ||
</el-row> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { format, parseISO } from 'date-fns' | ||
export default { | ||
name: 'ListCardItem', | ||
props: { | ||
title: { | ||
type: String, | ||
required: true | ||
}, | ||
summary: { | ||
type: String, | ||
required: true | ||
}, | ||
url: { | ||
type: String, | ||
required: true | ||
}, | ||
date: { | ||
type: String, | ||
required: true | ||
}, | ||
openInNewTab: { | ||
type: Boolean, | ||
default: false | ||
}, | ||
image: { | ||
type: String, | ||
default: undefined | ||
} | ||
}, | ||
computed: { | ||
/** | ||
* Compute and formate start date | ||
* @returns {String} | ||
*/ | ||
formattedDate: function() { | ||
return this.formatDate(this.date || '') | ||
} | ||
}, | ||
methods: { | ||
formatDate: function(date) { | ||
return date != '' ? format(parseISO(date), 'MMMM d, yyyy') : '' | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
h3 { | ||
font-size: 1rem; | ||
line-height: 1.15rem; | ||
margin-bottom: 0; | ||
} | ||
p { | ||
margin-bottom: 0rem; | ||
cursor: default; | ||
} | ||
.list-item { | ||
padding: 1.5rem 0; | ||
} | ||
.list-item__date { | ||
font-size: 1rem; | ||
font-style: italic; | ||
cursor: default; | ||
} | ||
.list-card-image { | ||
width: stretch; | ||
aspect-ratio: 1 / 1; | ||
} | ||
.list-card-content { | ||
margin-left: 1rem; | ||
} | ||
.spacing { | ||
margin-top: .5rem; | ||
} | ||
</style> |