-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c065b8
commit a596505
Showing
6 changed files
with
162 additions
and
40 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
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,54 @@ | ||
<template> | ||
<!-- action button --> | ||
<button @click.stop="toggleActionDropdown" ref="toggleButton"> | ||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 20 20"> | ||
<g id="tabler-icon-dots__tabler-icon-dots"> | ||
<g id="tabler-icon-dots__Vector"> | ||
<path fill="#fff" d="M3.333 10A.833.833 0 1 0 5 10a.833.833 0 0 0-1.667 0Zm5.833 0a.833.833 0 1 0 1.667 0 .833.833 0 0 0-1.667 0ZM15 10a.833.833 0 1 0 1.667 0A.833.833 0 0 0 15 10Z"/> | ||
<path stroke="#fff" stroke-linecap="round" stroke-linejoin="round" d="M3.333 10A.833.833 0 1 0 5 10a.833.833 0 0 0-1.667 0Zm5.833 0a.833.833 0 1 0 1.667 0 .833.833 0 0 0-1.667 0ZM15 10a.833.833 0 1 0 1.667 0A.833.833 0 0 0 15 10Z"/> | ||
</g> | ||
</g> | ||
</svg> | ||
</button> | ||
|
||
<!-- action dropdown --> | ||
<div class="ns-absolute ns-top-14 ns-right-0 ns-bg-white ns-rounded-lg ns-shadow-lg ns-z-20" v-if="isActionDropdownOpen" ref="dropdown"> | ||
<button class="ns-p-2 ns-w-full ns-text-left ns-text-sm ns-font-medium" @click.prevent="startNewSession">Start a New Session</button> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { ref, onMounted, onUnmounted } from 'vue' | ||
const isActionDropdownOpen = ref(false) | ||
const emit = defineEmits(['startNewSession']) | ||
const toggleButton = ref(null) | ||
const dropdown = ref(null) | ||
const toggleActionDropdown = () => { | ||
isActionDropdownOpen.value = !isActionDropdownOpen.value | ||
} | ||
const startNewSession = () => { | ||
emit('startNewSession') | ||
isActionDropdownOpen.value = false | ||
} | ||
const handleClickOutside = (event) => { | ||
if ( | ||
isActionDropdownOpen.value && | ||
!toggleButton.value.contains(event.target) && | ||
!dropdown.value.contains(event.target) | ||
) { | ||
isActionDropdownOpen.value = false | ||
} | ||
} | ||
onMounted(() => { | ||
document.addEventListener('click', handleClickOutside) | ||
}) | ||
onUnmounted(() => { | ||
document.removeEventListener('click', handleClickOutside) | ||
}) | ||
</script> |
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
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,14 @@ | ||
export function useFormatTimestamp() { | ||
const formatTimestamp = (timestamp) => { | ||
const date = new Date(timestamp) | ||
const today = new Date() | ||
|
||
if (date.toDateString() === today.toDateString()) { | ||
return date.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: true }) | ||
} | ||
|
||
return date.toLocaleString('en-US', { month: 'short', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: true }) | ||
} | ||
|
||
return { formatTimestamp } | ||
} |