Skip to content

Commit

Permalink
Merge pull request #134 from Perdolique/65-confirmation-dialog
Browse files Browse the repository at this point in the history
style: Update base.scss and dialog styles
  • Loading branch information
Perdolique authored Sep 14, 2024
2 parents e5bc859 + 4b99875 commit e26fcf1
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 15 deletions.
8 changes: 7 additions & 1 deletion app/assets/styles/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
--button-color-text: ghostwhite;
--button-color-disabled: #ccc;
--button-color-disabled-text: #666;

// Inputs
--input-height: 3rem;
--input-spacing-horizontal: 1rem;
Expand All @@ -82,7 +83,6 @@
--input-color-placeholder: #8c8c8c;
--input-color-background: ghostwhite;


// Secondary inputs
--input-secondary-color-main: ghostwhite;
--input-secondary-color-text: #287892;
Expand All @@ -103,4 +103,10 @@
--element-color-background: ghostwhite;
--element-color-background-hover: #f0fafb;
--element-color-background-active: #d8f2f5;

// Dialogs
--dialog-color-background: #f0fafb;
--dialog-color-border: #266278;
--dialog-padding: 1.5rem;
--dialog-border-radius: 1.5rem;
}
14 changes: 13 additions & 1 deletion app/components/PerdHeading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<script lang="ts" setup>
interface Props {
readonly level: 1;
readonly level: 1 | 2;
}
const { level } = defineProps<Props>();
Expand All @@ -22,6 +22,13 @@
className: 'h1'
};
}
case 2: {
return {
name: 'h2',
className: 'h2'
};
}
}
});
</script>
Expand All @@ -35,5 +42,10 @@
font-size: var(--font-size-24);
font-weight: var(--font-weight-bold);
}
&:global(.h2) {
font-size: var(--font-size-20);
font-weight: var(--font-weight-bold);
}
}
</style>
2 changes: 2 additions & 0 deletions app/components/PerdMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
onClickOutside(rootRef, () => {
isMenuVisible.value = false
}, {
ignore: ['dialog']
});
</script>

Expand Down
100 changes: 100 additions & 0 deletions app/components/dialogs/ConfirmationDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<template>
<ModalDialog v-model="isOpened">
<div :class="$style.content">
<PerdHeading
:class="$style.header"
:level="2"
>
{{ headerText }}
</PerdHeading>

<div :class="$style.body">
<slot />
</div>

<div :class="$style.buttons">
<PerdButton
secondary
:class="$style.cancelButton"
@click="close"
>
{{ cancelButtonText }}
</PerdButton>

<PerdButton
:class="$style.confirmButton"
@click="emitConfirm"
>
{{ confirmButtonText }}
</PerdButton>
</div>
</div>
</ModalDialog>
</template>

<script lang="ts" setup>
import PerdButton from '~/components/PerdButton.vue'
import PerdHeading from '~/components/PerdHeading.vue';
import ModalDialog from './ModalDialog.vue'
interface Props {
readonly headerText: string;
readonly confirmButtonText: string;
readonly cancelButtonText?: string;
}
type Emits = (event: 'confirm') => void
const isOpened = defineModel<boolean>({
required: true
})
const {
cancelButtonText = 'Cancel'
} = defineProps<Props>()
const emit = defineEmits<Emits>()
function close() {
isOpened.value = false
}
function emitConfirm() {
emit('confirm')
close()
}
</script>

<style lang="scss" module>
.content {
display: grid;
row-gap: var(--spacing-24);
column-gap: var(--spacing-16);
background-color: var(--dialog-color-background);
padding: var(--dialog-padding);
border-radius: var(--dialog-border-radius);
border: 1px solid var(--dialog-color-border);
}
.header {
@include overflow-ellipsis();
}
.body {
word-break: break-word;
}
.buttons {
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
gap: var(--spacing-16);
}
.confirmButton,
.cancelButton {
max-width: 200px;
@include overflow-ellipsis();
}
</style>
8 changes: 4 additions & 4 deletions app/components/dialogs/CreateChecklistDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@
.content {
display: grid;
row-gap: var(--spacing-24);
background-color: var(--color-background);
padding: var(--spacing-16) var(--spacing-32);
border-radius: var(--border-radius-24);
border: 1px solid var(--color-blue-700);
background-color: var(--dialog-color-background);
padding: var(--dialog-padding);
border-radius: var(--dialog-border-radius);
border: 1px solid var(--dialog-color-border);
}
.header {
Expand Down
2 changes: 1 addition & 1 deletion app/components/dialogs/ModalDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
});
useEventListener(dialogRef, 'close', (event) => {
useEventListener(dialogRef, 'close', () => {
isOpened.value = false
})
Expand Down
4 changes: 2 additions & 2 deletions app/pages/auth/twitch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@

<style module>
.component {
width: 100vw;
height: 100vh;
width: 100%;
height: 100%;
display: flex;
overflow: hidden;
padding: var(--spacing-24);
Expand Down
30 changes: 28 additions & 2 deletions app/pages/checklists/[checklistId].vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
>
<OptionButton
icon="tabler:trash"
@click="deleteChecklist"
@click="showDeleteConfirmation"
>
Delete
<template v-if="isDeleting">
Deleting...
</template>

<template v-else>
Delete
</template>
</OptionButton>

<OptionToggle v-model="isCheckMode">
Expand Down Expand Up @@ -54,6 +60,15 @@
/>
</div>
</PageContent>

<ConfirmationDialog
v-model="isDeleteDialogOpened"
header-text="Delete checklist"
:confirm-button-text="deleteButtonText"
@confirm="deleteChecklist"
>
Cheklist <strong>{{ name }}</strong> will be deleted
</ConfirmationDialog>
</template>

<script lang="ts" setup>
Expand All @@ -65,6 +80,7 @@
import OptionButton from '~/components/PerdMenu/OptionButton.vue';
import OptionToggle from '~/components/PerdMenu/OptionToggle.vue';
import PerdButton from '~/components/PerdButton.vue';
import ConfirmationDialog from '~/components/dialogs/ConfirmationDialog.vue'
definePageMeta({
layout: 'page'
Expand All @@ -83,8 +99,10 @@
const options = ref<InventoryItem[]>([])
const isSearching = ref(false)
const isCheckMode = ref(false)
const isDeleteDialogOpened = ref(false)
const { resetAll: resetAllToggles } = useChecklistToggle(checklistId)
const { data: checklistData } = await useFetch(`/api/checklists/${checklistId}`)
const deleteButtonText = computed(() => `Delete ${name.value}`)
await useChecklistItemsData(checklistId)
Expand All @@ -97,6 +115,10 @@
}
async function deleteChecklist() {
if (isDeleting.value) {
return
}
try {
isDeleting.value = true
Expand Down Expand Up @@ -143,6 +165,10 @@
options.value = options.value.filter(({ id }) => id !== equipmentId)
}
function showDeleteConfirmation() {
isDeleteDialogOpened.value = true
}
</script>

<style module>
Expand Down
12 changes: 8 additions & 4 deletions app/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<template>
<div :class="$style.component">
Hello, {{ user.userId }}
<br />
Your admin status is: {{ user.isAdmin }}
<div>
Hello, {{ user.userId }}
</div>

<div>
Your admin status is: {{ user.isAdmin }}
</div>
</div>
</template>

Expand All @@ -16,7 +20,7 @@

<style module>
.component {
display: flex;
display: grid;
justify-content: center;
gap: var(--spacing-16);
padding-top: var(--spacing-32);
Expand Down

0 comments on commit e26fcf1

Please sign in to comment.