Skip to content

Commit

Permalink
[studio] add transition to dropdown and modal #1454 (#1457)
Browse files Browse the repository at this point in the history
* studio - fade transition + types

* studio - fade transition
  • Loading branch information
janavlachova authored Jan 4, 2025
1 parent 1adcf9e commit d285278
Show file tree
Hide file tree
Showing 13 changed files with 65 additions and 39 deletions.
19 changes: 11 additions & 8 deletions agdb_studio/src/components/base/dropdown/AgdbDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { vOnClickOutside } from "@vueuse/components";
import { ref } from "vue";
import DropdownContent from "./DropdownContent.vue";
import FadeTrasition from "@/components/transitions/FadeTrasition.vue";
const opened = ref(false);
const close = () => {
Expand All @@ -24,14 +25,16 @@ const buttonRef = ref<HTMLElement>();
<slot name="trigger"></slot>
</button>
<Teleport to="body">
<DropdownContent
:button-ref="buttonRef"
:opened="opened"
v-on-click-outside="close"
@close="close"
>
<slot name="content"></slot>
</DropdownContent>
<FadeTrasition>
<DropdownContent
:button-ref="buttonRef"
:opened="opened"
v-on-click-outside="close"
@close="close"
>
<slot name="content"></slot>
</DropdownContent>
</FadeTrasition>
</Teleport>
</div>
</template>
Expand Down
13 changes: 8 additions & 5 deletions agdb_studio/src/components/base/menu/AgdbMenu.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts" setup>
import { ref, type PropType } from "vue";
import { AkChevronRightSmall } from "@kalimahapps/vue-icons";
import FadeTrasition from "@/components/transitions/FadeTrasition.vue";
const props = defineProps({
actions: { type: Array as PropType<Action[]>, required: true },
Expand Down Expand Up @@ -40,11 +41,13 @@ const openSubmenu = (key: string) => {
<AkChevronRightSmall />
</span>
</a>
<AgdbMenu
class="sub-menu"
v-if="openedSubmenu === action.key && action.actions"
:actions="action.actions"
/>
<FadeTrasition>
<AgdbMenu
class="sub-menu"
v-if="openedSubmenu === action.key && action.actions"
:actions="action.actions"
/>
</FadeTrasition>
</li>
</ul>
</template>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, it, expect, vi } from "vitest";
import { mount } from "@vue/test-utils";
import MainLayout from "@/layouts/MainLayout.vue";
import MainLayout from "./MainLayout.vue";
import { createRouter, createWebHistory } from "vue-router";

const { loginMock, isLoggedInMock, logoutMock } = vi.hoisted(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useAuth } from "@/composables/user/auth";
import LogoIcon from "@/components/base/icons/LogoIcon.vue";
import { useAccount } from "@/composables/user/account";
import AgdbModal from "@/components/base/modal/AgdbModal.vue";
import FadeTrasition from "@/components/transitions/FadeTrasition.vue";
const { logout } = useAuth();
const { username } = useAccount();
Expand Down Expand Up @@ -31,7 +32,9 @@ const { username } = useAccount();
<RouterView />
</main>
<footer></footer>
<AgdbModal />
<FadeTrasition>
<AgdbModal />
</FadeTrasition>
</div>
</template>

Expand Down
17 changes: 17 additions & 0 deletions agdb_studio/src/components/transitions/FadeTrasition.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<transition name="fade">
<slot></slot>
</transition>
</template>

<style lang="less" scoped>
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.25s ease;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
</style>
6 changes: 3 additions & 3 deletions agdb_studio/src/composables/graph/class/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type EdgeOptions = {
id: number;
from?: Node;
to?: Node;
values: { [key: string]: string };
values: Record<string, string>;
};

export default class Edge {
Expand Down Expand Up @@ -60,8 +60,8 @@ export default class Edge {
return this.values;
}

public getValuesObject(): { [key: string]: string } {
const result: { [key: string]: string } = {};
public getValuesObject(): Record<string, string> {
const result: Record<string, string> = {};
for (const [key, value] of this.values.entries()) {
result[key] = value;
}
Expand Down
6 changes: 3 additions & 3 deletions agdb_studio/src/composables/graph/class/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type Coordinates = {

type NodeOptions = {
id: number;
values: { [key: string]: string };
values: Record<string, string>;
coordinates: Coordinates;
};

Expand Down Expand Up @@ -49,8 +49,8 @@ export default class Node {
return this.values;
}

public getValuesObject(): { [key: string]: string } {
const result: { [key: string]: string } = {};
public getValuesObject(): Record<string, string> {
const result: Record<string, string> = {};
for (const [key, value] of this.values.entries()) {
result[key] = value;
}
Expand Down
8 changes: 4 additions & 4 deletions agdb_studio/src/composables/graph/composable/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type EdgeOptions = {
id: number;
from?: Node;
to?: Node;
values: { [key: string]: string };
values: Record<string, string>;
};

export type Edge = {
Expand All @@ -19,7 +19,7 @@ export type Edge = {
getTo: () => Node | undefined;
setTo: (toNode: Node) => void;
getValues: () => Map<string, string>;
getValuesObject: () => { [key: string]: string };
getValuesObject: () => Record<string, string>;
};

const useEdge = function (options: EdgeOptions): Edge {
Expand Down Expand Up @@ -68,8 +68,8 @@ const useEdge = function (options: EdgeOptions): Edge {
return values;
};

const getValuesObject = (): { [key: string]: string } => {
const result: { [key: string]: string } = {};
const getValuesObject = (): Record<string, string> => {
const result: Record<string, string> = {};
for (const [key, value] of values.entries()) {
result[key] = value;
}
Expand Down
8 changes: 4 additions & 4 deletions agdb_studio/src/composables/graph/composable/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type Coordinates = {

export type NodeOptions = {
id: number;
values: { [key: string]: string };
values: Record<string, string>;
coordinates: Coordinates;
};

Expand All @@ -26,7 +26,7 @@ export type Node = {
getZ: () => number;
dist: (v: Node) => number;
getValues: () => Map<string, string>;
getValuesObject: () => { [key: string]: string };
getValuesObject: () => Record<string, string>;
};

function useNode(options: NodeOptions): Node {
Expand All @@ -51,8 +51,8 @@ function useNode(options: NodeOptions): Node {
return values;
};

const getValuesObject = (): { [key: string]: string } => {
const result: { [key: string]: string } = {};
const getValuesObject = (): Record<string, string> => {
const result: Record<string, string> = {};
for (const [key, value] of values.entries()) {
result[key] = value;
}
Expand Down
8 changes: 4 additions & 4 deletions agdb_studio/src/composables/graph/prototype/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export type EdgeOptions = {
id: number;
from?: Node;
to?: Node;
values: { [key: string]: string };
values: Record<string, string>;
};

export interface Edge {
Expand All @@ -18,7 +18,7 @@ export interface Edge {

getValues(): Map<string, string>;

getValuesObject(): { [key: string]: string };
getValuesObject(): Record<string, string>;

getValuesEntries(): IterableIterator<[string, string]>;

Expand Down Expand Up @@ -93,8 +93,8 @@ export const Edge = (function () {
return this[symbol].values;
};

Edge.prototype.getValuesObject = function (): { [key: string]: string } {
const result: { [key: string]: string } = {};
Edge.prototype.getValuesObject = function (): Record<string, string> {
const result: Record<string, string> = {};
for (const [key, value] of this[symbol].values.entries()) {
result[key] = value;
}
Expand Down
8 changes: 4 additions & 4 deletions agdb_studio/src/composables/graph/prototype/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export type Coordinates = {

type NodeOptions = {
id: number;
values: { [key: string]: string };
values: Record<string, string>;
coordinates: Coordinates;
};

Expand All @@ -19,7 +19,7 @@ export interface Node {

getValues(): Map<string, string>;

getValuesObject(): { [key: string]: string };
getValuesObject(): Record<string, string>;

getValuesEntries(): IterableIterator<[string, string]>;

Expand Down Expand Up @@ -91,8 +91,8 @@ export const Node = (function () {
return this[symbol].values;
};

Node.prototype.getValuesObject = function (): { [key: string]: string } {
const result: { [key: string]: string } = {};
Node.prototype.getValuesObject = function (): Record<string, string> {
const result: Record<string, string> = {};
for (const [key, value] of this[symbol].values.entries()) {
result[key] = value;
}
Expand Down
2 changes: 1 addition & 1 deletion agdb_studio/src/router/routes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import MainLayout from "@/layouts/MainLayout.vue";
import MainLayout from "@/components/layouts/MainLayout.vue";

export const createRoutes = () => {
return [
Expand Down
2 changes: 1 addition & 1 deletion agdb_studio/src/types/graph.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type GraphElementBase = {
id: number;
values: { [key: string]: string };
values: Record<string, string>;
};

type GraphNode = GraphElementBase;
Expand Down

0 comments on commit d285278

Please sign in to comment.