Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): improve design of collapse button #682

Merged
merged 2 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
31 changes: 9 additions & 22 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="left-right"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you understood this one, it collapses horizontally, but the direction depends on its position relative to other columns. You have an isCollapsibleToRight variable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha ok, I'll adapt it

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be good now 403e6d4 . This is the expected behavior, right ?

Screencast.From.2024-12-07.12-12-03.mp4

: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 Expand Up @@ -212,25 +218,6 @@ watch(
flex: 0 0 32px;
}

.CoreColumn > .header > .collapser > .collapserArrow {
transition: all 0.5s ease-in-out;
transform: rotate(0deg);
}

.CoreColumn:not(.collapsibleToRight).collapsed
> .header
> .collapser
> .collapserArrow {
transform: rotate(180deg);
}

.CoreColumn.collapsibleToRight:not(.collapsed)
> .header
> .collapser
> .collapserArrow {
transform: rotate(180deg);
}

.CoreColumn.collapsibleToRight > .header {
justify-content: left;
}
Expand Down
1 change: 1 addition & 0 deletions src/ui/src/components/core/layout/CoreSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ const isCollapsed = ref<boolean>(
margin: 16px 16px 0 16px;
display: grid;
grid-template-columns: 1fr auto;
align-items: center;
}
.CoreSection__title--collapsed {
margin: 16px;
Expand Down
21 changes: 0 additions & 21 deletions src/ui/src/components/core/layout/CoreSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,6 @@ onMounted(() => {
margin-bottom: 16px;
}

.collapserContainer > .collapser {
flex: 0 0 32px;
}

.collapserContainer .collapserArrow {
transition: all 0.5s ease-in-out;
transform: rotate(0deg);
}

.CoreSidebar.collapsed .collapserArrow {
transform: rotate(180deg);
}

.collapserContainer > .collapser:hover {
background: var(--separatorColor);
}

@media only screen and (max-width: 768px) {
.CoreSidebar {
min-width: 100%;
Expand All @@ -164,9 +147,5 @@ onMounted(() => {
.CoreSidebar.collapsed > .collapserContainer {
margin-bottom: 0;
}

.collapserContainer > .collapser {
transform: rotate(90deg);
}
}
</style>
Loading