Skip to content

Commit

Permalink
fix(ui): adapt collapser arrow direction for columns
Browse files Browse the repository at this point in the history
  • Loading branch information
madeindjs committed Dec 7, 2024
1 parent bac994b commit 403e6d4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
30 changes: 23 additions & 7 deletions src/ui/src/components/core/base/BaseCollapseButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,37 @@
</button>
</template>

<script lang="ts">
export type Direction =
| "left-right"
| "top-bottom"
| "bottom-top"
| "right-left";
</script>

<script setup lang="ts">
import { computed, PropType } from "vue";
const props = defineProps({
direction: {
type: String as PropType<"left-right" | "top-bottom">,
required: true,
},
direction: { type: String as PropType<Direction>, required: true },
});
const isCollapsed = defineModel({ type: Boolean, required: true });
const icon = computed(() =>
props.direction === "left-right" ? "chevron_left" : "keyboard_arrow_up",
);
const icon = computed(() => {
switch (props.direction) {
case "left-right":
return "chevron_left";
case "top-bottom":
return "keyboard_arrow_up";
case "right-left":
return "chevron_right";
case "bottom-top":
return "keyboard_arrow_down";
default:
return "keyboard_arrow_up";
}
});
</script>

<style scoped>
Expand Down
12 changes: 9 additions & 3 deletions src/ui/src/components/core/layout/CoreColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
v-if="isCollapsible"
v-model="isCollapsed"
class="collapser"
direction="top-bottom"
:direction="collapseDirection"
/>
</div>
<div v-if="isCollapsed && fields.title.value" class="collapsedTitle">
Expand Down Expand Up @@ -48,7 +48,6 @@ import {
startCollapsed,
isCollapsible as isCollapsibleField,
} from "@/renderer/sharedStyleFields";
import BaseCollapseButton from "../base/BaseCollapseButton.vue";
const description =
"A layout component that organizes its child components in columns. Must be inside a Column Container component.";
Expand Down Expand Up @@ -100,7 +99,10 @@ export default {
<script setup lang="ts">
import { computed, ComputedRef, inject, Ref, ref, watch } from "vue";
import injectionKeys from "@/injectionKeys";
import BaseContainer from "../base/BaseContainer.vue";
import BaseContainer from "@/components/core/base/BaseContainer.vue";
import BaseCollapseButton from "@/components/core/base/BaseCollapseButton.vue";
import type { Direction } from "@/components/core/base/BaseCollapseButton.vue";
const instancePath = inject(injectionKeys.instancePath);
const instanceData = inject(injectionKeys.instanceData);
const wf = inject(injectionKeys.core);
Expand Down Expand Up @@ -138,6 +140,10 @@ const isCollapsibleToRight = computed(
columnsData.value?.value?.minimumNonCollapsiblePosition,
);
const collapseDirection = computed<Direction>(() =>
isCollapsibleToRight.value ? "right-left" : "left-right",
);
const columnsData: ComputedRef<Ref> = computed(() => {
for (let i = -1; i > -1 * instancePath.length; i--) {
const item = instancePath.at(i);
Expand Down

0 comments on commit 403e6d4

Please sign in to comment.