Skip to content

Commit

Permalink
feat(ui): use WdsButton for BaseCollapseButton - WF-132
Browse files Browse the repository at this point in the history
The `BaseCollapseButton` used a custom button with a different `:focus` state. I moved it to the standard `WdsButton` and implemented a `:focus-visible` to it to improve tab navigation.

The change should be almost transparent in term of UI.
  • Loading branch information
madeindjs committed Dec 18, 2024
1 parent 22d0248 commit 5ba6893
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
33 changes: 12 additions & 21 deletions src/ui/src/components/core/base/BaseCollapseButton.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<template>
<button
role="button"
<WdsButton
class="BaseCollapseIcon"
:class="{ 'BaseCollapseIcon--collapsed': isCollapsed }"
variant="tertiary"
size="icon"
@click="isCollapsed = !isCollapsed"
>
<i class="material-symbols-outlined">{{ icon }}</i>
</button>
<i class="BaseCollapseIcon__icon material-symbols-outlined">{{
icon
}}</i>
</WdsButton>
</template>

<script lang="ts">
Expand All @@ -18,6 +21,7 @@ export type Direction =
</script>

<script setup lang="ts">
import WdsButton from "@/wds/WdsButton.vue";
import { computed, PropType } from "vue";
const props = defineProps({
Expand All @@ -44,28 +48,15 @@ const icon = computed(() => {

<style scoped>
.BaseCollapseIcon {
border: none;
border-radius: 50%;
padding: 4px;
display: flex;
align-items: center;
justify-content: center;
background-color: transparent;
height: 32px;
width: 32px;
cursor: pointer;
border-color: var(--separatorColor);
}
.BaseCollapseIcon__icon {
transition: all 0.3s ease-in-out;
transform: rotate(0deg);
border: 1px solid var(--separatorColor);
}
.BaseCollapseIcon:hover {
background: var(--separatorColor);
}
.BaseCollapseIcon--collapsed {
.BaseCollapseIcon--collapsed .BaseCollapseIcon__icon {
transform: rotate(180deg);
}
</style>
2 changes: 1 addition & 1 deletion src/ui/src/wds/WdsButton.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<button class="WdsButton colorTransformer" :class="className">
<button class="WdsButton colorTransformer" :class="className" role="button">
<slot></slot>
</button>
</template>
Expand Down

0 comments on commit 5ba6893

Please sign in to comment.