Skip to content

Commit

Permalink
Merge pull request #7 from nih-sparc/ListCard
Browse files Browse the repository at this point in the history
listcard and listcarditem migrated
  • Loading branch information
egauzens authored Dec 4, 2023
2 parents 8004a1a + a6405a6 commit ce8bc4d
Show file tree
Hide file tree
Showing 3 changed files with 289 additions and 1 deletion.
67 changes: 66 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,20 @@
</content-overview-card>
</el-row>
</el-col>
<el-col>
<el-row style="margin: 2rem 2rem">
<list-card
:data="listCardDataStyleOne"
/>
</el-row>
<el-row style="margin: 2rem 2rem">
<list-card
:data="listCardDataStyleTwo.data"
:sectionText="listCardDataStyleTwo.text"
:sectionUrl="listCardDataStyleTwo.url"
/>
</el-row>
</el-col>
<el-select v-model="value" placeholder="Select">
<el-option
v-for="item in options"
Expand Down Expand Up @@ -369,6 +383,7 @@
</template>

<script>
import ListCard from './components/ListCard/ListCard.vue'
import HelloWorld from './components/HelloWorld.vue'
import SparcTooltip from './components/SparcTooltip.vue'
import SparcLogo from './components/SparcLogo.vue'
Expand All @@ -387,6 +402,53 @@
import { ref } from 'vue'
import { successMessage, infoMessage, failMessage, informationNotification, iconInformationNotification } from "../utils/notificationMessages"
const listCardDataStyleOne= [
{
title: "Prototype simulation of undiseased human cardiac ventricular cells",
summary: "A prototype use-case package consisting of a single-cell, 1D and 2D tissue model for simulation of autonomic effects on the cardiovascular system derived from the human ventricular model developed by O'Hara and Rudy group.",
date: "2020-04-04T10:36:01.516Z",
url: "/#",
image: "https://via.placeholder.com/128"
},
{
title: "Prototype simulation of undiseased human cardiac ventricular cells",
summary: "A prototype use-case package consisting of a single-cell, 1D and 2D tissue model for simulation of autonomic effects on the cardiovascular system derived from the human ventricular model developed by O'Hara and Rudy group.",
date: "2020-04-04T10:36:01.516Z",
url: "/#",
image: "https://via.placeholder.com/128"
},
{
title: "Prototype simulation of undiseased human cardiac ventricular cells",
summary: "A prototype use-case package consisting of a single-cell, 1D and 2D tissue model for simulation of autonomic effects on the cardiovascular system derived from the human ventricular model developed by O'Hara and Rudy group.",
date: "2020-04-04T10:36:01.516Z",
url: "/#",
image: "https://via.placeholder.com/128"
}
];
const listCardDataStyleTwo ={
data: [{
title: "Prototype simulation of undiseased human cardiac ventricular cells",
summary: "A prototype use-case package consisting of a single-cell, 1D and 2D tissue model for simulation of autonomic effects on the cardiovascular system derived from the human ventricular model developed by O'Hara and Rudy group.",
date: "2020-04-04T10:36:01.516Z",
url: "/#"
},
{
title: "Prototype simulation of undiseased human cardiac ventricular cells",
summary: "A prototype use-case package consisting of a single-cell, 1D and 2D tissue model for simulation of autonomic effects on the cardiovascular system derived from the human ventricular model developed by O'Hara and Rudy group.",
date: "2020-04-04T10:36:01.516Z",
url: "/#"
},
{
title: "Prototype simulation of undiseased human cardiac ventricular cells",
summary: "A prototype use-case package consisting of a single-cell, 1D and 2D tissue model for simulation of autonomic effects on the cardiovascular system derived from the human ventricular model developed by O'Hara and Rudy group.",
date: "2020-04-04T10:36:01.516Z",
url: "/#"
}],
text: "Show all News",
url: "/#"
}
const eventCardEvent = {
type: "Conference",
image: "https://via.placeholder.com/736",
Expand All @@ -397,6 +459,7 @@
url: "/#"
}
const checkboxItem = ref([
{
label: 1,
Expand Down Expand Up @@ -1032,6 +1095,7 @@
IconCard,
ContentOverviewCard,
ContentTabCard,
ListCard,
EventCard
},
name: 'App',
Expand Down Expand Up @@ -1108,9 +1172,10 @@
breadcrumbs,
iconCardData,
contentOverviewCard,
listCardDataStyleOne,
listCardDataStyleTwo,
contentTabCard: tabCard,
eventCardEvent
}
},
methods: {
Expand Down
106 changes: 106 additions & 0 deletions src/components/ListCard/ListCard.vue
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>
117 changes: 117 additions & 0 deletions src/components/ListCard/ListCardItem.vue
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>

0 comments on commit ce8bc4d

Please sign in to comment.