-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
kadiryazici
committed
Oct 22, 2023
1 parent
27f1a01
commit ab73ee6
Showing
10 changed files
with
270 additions
and
9 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,85 @@ | ||
<script lang="ts"> | ||
function transitionHandle(bg: HTMLElement, done: () => void, enter = true) { | ||
const content = bg.querySelector('.dialog-body') as HTMLElement | ||
bg.animate([ | ||
{ backgroundColor: 'rgba(0, 0, 0, 0)' }, | ||
{ backgroundColor: bg.style.backgroundColor }, | ||
], { | ||
duration: 250, | ||
fill: 'forwards', | ||
direction: enter ? 'normal' : 'reverse', | ||
}) | ||
content.animate([ | ||
{ transform: 'scale(0.9)', opacity: 0 }, | ||
{ transform: 'scale(1)', opacity: 1 }, | ||
], { | ||
duration: 250, | ||
fill: 'forwards', | ||
direction: enter ? 'normal' : 'reverse', | ||
}).onfinish = done | ||
} | ||
</script> | ||
|
||
<script lang="ts" setup> | ||
interface Props { | ||
title: string | ||
visible: boolean | ||
} | ||
interface Emits { | ||
(name: 'update:visible', value: boolean): void | ||
} | ||
const props = defineProps<Props>() | ||
const emit = defineEmits<Emits>() | ||
</script> | ||
|
||
<template> | ||
<Teleport to="body"> | ||
<Transition | ||
appear | ||
@enter="(el, done) => transitionHandle(el as HTMLElement, done, true)" | ||
Check failure on line 43 in src/components/Dialog.vue GitHub Actions / Type Check
|
||
@leave="(el, done) => transitionHandle(el as HTMLElement, done, false)" | ||
Check failure on line 44 in src/components/Dialog.vue GitHub Actions / Type Check
|
||
> | ||
<div | ||
v-if="props.visible" | ||
class="dialog-bg" | ||
@click.self="emit('update:visible', false)" | ||
> | ||
<div class="dialog-body"> | ||
<div class="dialog-title"> | ||
{{ props.title }} | ||
</div> | ||
<div class="dialog-content"> | ||
<slot /> | ||
</div> | ||
</div> | ||
</div> | ||
</Transition> | ||
</Teleport> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
.dialog-bg { | ||
position: fixed; | ||
inset: 0; | ||
background-color: rgba(0, 0, 0, 0.5); | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
z-index: 1000; | ||
padding: 25px; | ||
.dialog-content { | ||
background-color: var(--content-bg); | ||
border-radius: 8px; | ||
min-width: 33%; | ||
overflow: hidden; | ||
display: flex; | ||
flex-direction: column; | ||
box-shadow: 0px 3px 8px -5px rgba(0, 0, 0, 0.3); | ||
} | ||
} | ||
</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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<script lang="ts"> | ||
export const SilentHourDays = { | ||
Monday: 1, | ||
Tuesday: 2, | ||
Wednesday: 3, | ||
Thursday: 4, | ||
Friday: 5, | ||
Saturday: 6, | ||
Sunday: 0, | ||
} | ||
export interface SilentHourContext { | ||
repoName: string | ||
start: string | ||
end: string | ||
days: number[] | ||
} | ||
interface Props { | ||
context?: SilentHourContext[] | ||
} | ||
const mockListData = [ | ||
{ | ||
repoName: 'test', | ||
start: '10:00', | ||
end: '12:00', | ||
days: [SilentHourDays.Monday, SilentHourDays.Tuesday], | ||
}, | ||
{ | ||
repoName: 'test2', | ||
start: '10:00', | ||
end: '12:00', | ||
days: [SilentHourDays.Monday, SilentHourDays.Tuesday], | ||
}, | ||
] | ||
</script> | ||
|
||
<script lang="ts" setup> | ||
import { ref } from 'vue' | ||
import Dialog from './Dialog.vue' | ||
import PageHeader from './PageHeader.vue' | ||
import SettingsSilentHoursAddButton from './SettingsSilentHoursAddButton.vue' | ||
import SettingsSilentHoursItem from './SettingsSilentHoursItem.vue' | ||
withDefaults(defineProps<Props>(), { | ||
context: () => [], | ||
}) | ||
const dialogVisible = ref(false) | ||
</script> | ||
|
||
<template> | ||
<PageHeader | ||
dot | ||
style="margin: 20px 0px;" | ||
info="You can select specific hours not to receive any system notification and not to play sound for a spesific repository." | ||
> | ||
Silent Hours | ||
</PageHeader> | ||
|
||
<SettingsSilentHoursItem | ||
v-for="item in mockListData" | ||
:key="item.repoName" | ||
:context="item" | ||
/> | ||
|
||
<SettingsSilentHoursAddButton @click="dialogVisible = true" /> | ||
|
||
<Dialog | ||
v-model:visible="dialogVisible" | ||
title="Add Silent Hour" | ||
> | ||
Bruh | ||
</Dialog> | ||
</template> |
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,37 @@ | ||
<script lang="ts" setup> | ||
import { Icons } from './Icons' | ||
import SlotRef from './SlotRef.vue' | ||
import Tooltip from './Tooltip.vue' | ||
</script> | ||
|
||
<template> | ||
<SlotRef> | ||
<template #default> | ||
<button class="settings-silent-hours-add-button"> | ||
<Icons.Plus16 /> | ||
</button> | ||
</template> | ||
|
||
<template #ref="{ el }"> | ||
<Tooltip | ||
text="Create new silent hour" | ||
:target="el" | ||
/> | ||
</template> | ||
</SlotRef> | ||
</template> | ||
|
||
<style lang="scss" scoped> | ||
.settings-silent-hours-add-button { | ||
width: 100%; | ||
background-color: var(--item-bg); | ||
padding: 10px; | ||
font-size: 16px; | ||
border-radius: 8px; | ||
color: var(--text); | ||
&:hover { | ||
background-color: var(--item-hover-bg); | ||
} | ||
} | ||
</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,17 @@ | ||
<script lang="ts"> | ||
import { type SilentHourContext } from './SettingsSilentHours.vue' | ||
interface Props { | ||
context: SilentHourContext | ||
} | ||
</script> | ||
|
||
<script lang="ts" setup> | ||
defineProps<Props>() | ||
</script> | ||
|
||
<template> | ||
<div> | ||
Testo | ||
</div> | ||
</template> |
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,8 +1,19 @@ | ||
import { type Ref, type UnwrapRef } from 'vue' | ||
|
||
/** | ||
* Just returns value of passed ref, used for reactivity tracking. | ||
* Used for singleton composable functions | ||
* | ||
* @example | ||
* ```ts | ||
* const fn = singletonFn(() => { | ||
* const state = reactive({ count: 0 }) | ||
* const increment = () => state.count++ | ||
* const decrement = () => state.count-- | ||
* return { state, increment, decrement } | ||
* }) | ||
* | ||
* const { state, increment, decrement } = fn() | ||
* ``` | ||
*/ | ||
export function trackRef<T extends Ref<any>>(ref: T): UnwrapRef<T> { | ||
return ref.value | ||
export function singleton<T>(fn: () => T): () => T { | ||
const context = fn() | ||
return () => context | ||
} |