-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[beam] add DayDivider to list views (#180)
* added DayDivider to Beam * fixed some padding styles for the list elements and updated prefixed variables * DayDivider now uses linkComponent. Added sample to data.json. * updated daydivider prop to accept Date object. Added optional flag for ISOString output vs. dateString output * fix: modify date formatter * updated day divider to use cell-changed color --------- Co-authored-by: Rohan Bansal <[email protected]>
- Loading branch information
Showing
8 changed files
with
134 additions
and
12 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<template> | ||
<div class="beam_day-divider"> | ||
<h2>{{ date }}</h2> | ||
</div> | ||
|
||
<slot></slot> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { defineProps, computed } from 'vue' | ||
import type { ListViewItem } from '@/types' | ||
defineSlots<{ default(): any }>() | ||
const { item } = defineProps<{ item: ListViewItem }>() | ||
const date = computed(() => { | ||
if (!item.date || isNaN(Date.parse(item.date))) { | ||
return item.date | ||
} | ||
// if needed, the user can specify a Date format flag that will dictate how the output is formatted, | ||
// defaults to toDateString(); using switch/case here in case more values wanted to be added | ||
const dateObj = new Date(item.date) | ||
if (item.dateFormat) { | ||
switch (item.dateFormat.toLowerCase()) { | ||
case 'iso': | ||
return dateObj.toISOString() | ||
} | ||
} | ||
return dateObj.toDateString() | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
.beam_day-divider { | ||
text-align: left; | ||
padding: 1rem; | ||
background: var(--sc-cell-changed-color); | ||
border-bottom: 1px solid var(--sc-row-border-color); | ||
box-sizing: border-box; | ||
margin: 1rem 0; | ||
& h2 { | ||
text-align: left; | ||
font-size: 1rem; | ||
color: var(--sc-primary-text-color); | ||
margin: 0; | ||
padding: 0; | ||
} | ||
} | ||
.beam_day-divider:first-of-type { | ||
margin-top: 0; | ||
} | ||
</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
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 |
---|---|---|
@@ -1,13 +1,16 @@ | ||
export type ListViewItem = { | ||
description: string | ||
label: string | ||
|
||
checked?: boolean | ||
debounce?: number | ||
linkComponent?: string | ||
route?: string | ||
count?: { | ||
count: number | ||
of: number | ||
uom: string | ||
} | ||
date?: string | ||
dateFormat?: string | ||
debounce?: number | ||
linkComponent?: string | ||
route?: string | ||
} |
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
10 changes: 10 additions & 0 deletions
10
common/changes/@stonecrop/beam/feat-beam-listview-day-divider_2024-11-04-16-47.json
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,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@stonecrop/beam", | ||
"comment": "added day divider to beam", | ||
"type": "none" | ||
} | ||
], | ||
"packageName": "@stonecrop/beam" | ||
} |
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