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

Add TreeSection actions container styling #1390

Merged
merged 7 commits into from
Apr 18, 2024
Merged
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
152 changes: 131 additions & 21 deletions extensions/vscode/webviews/homeView/src/components/TreeSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,41 @@
<div class="pane" :class="{ expanded: expanded }">
<div
class="pane-header"
tabindex="0"
:class="{ expanded: expanded }"
@click="expanded = !expanded"
@keydown.enter.self="toggleExpanded"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This makes it so ONLY the pane-header listens for keydown.enter otherwise focus on the children would have caused the toggle.

>
<div
class="twisty-container codicon"
:class="expanded ? 'codicon-chevron-down' : 'codicon-chevron-right'"
/>
<h3 class="title">{{ title }}</h3>
<div class="pane-header-title-container" @click="toggleExpanded">
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Created this, and used justify-content: space-between to better handle toggleExpanded in Vue.

This is not how VSCode structures the DOM or styles it, but it looks and behaves functionality the same.

<div
class="twisty-container codicon"
:class="expanded ? 'codicon-chevron-down' : 'codicon-chevron-right'"
/>
<h3 class="title">{{ title }}</h3>
</div>
<div class="actions">
<div class="monaco-toolbar">
<div class="monaco-action-bar">
<ul
class="actions-container"
role="toolbar"
:aria-label="`${title} actions`"
>
<li
class="action-item menu-entry"
role="presentation"
custom-hover="true"
>
<a
class="action-label codicon codicon-refresh"
role="button"
aria-label="Refresh Deployment Files"
tabindex="0"
></a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div v-if="expanded" class="pane-body">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nemo ad adipisci
Expand All @@ -28,9 +55,76 @@ const expanded = defineModel("expanded", { required: false, default: false });
defineProps<{
title: string;
}>();

const toggleExpanded = () => {
expanded.value = !expanded.value;
};
</script>

<style lang="scss" scoped>
.pane {
.actions {
display: none;
margin-left: auto;

.monaco-toolbar {
height: 100%;

.monaco-action-bar {
white-space: nowrap;
height: 100%;

.actions-container {
align-items: center;
display: flex;
height: 100%;
margin: 0 auto;
padding: 0;
width: 100%;

.action-item {
display: block;
cursor: pointer;
position: relative;
z-index: 2;
margin-right: 4px;

.action-label {
border-radius: 5px;
padding: 2px;
font-size: 16px;
align-items: center;
display: flex;
height: 20px;
width: 20px;
color: var(--vscode-icon-foreground);

&:focus {
opacity: 1;
outline-color: var(--vscode-focusBorder);
outline-offset: -1px;
outline-style: solid;
outline-width: 1px;
}

&:hover {
background-color: var(--vscode-toolbar-hoverBackground);
outline: 1px dashed var(--vscode-toolbar-hoverOutline);
outline-offset: -1px;
}
}
}
}
}
}
}

&.expanded:hover .actions,
&.expanded:focus-within .actions {
display: initial;
}
}

.pane-header {
line-height: 22px;
color: var(--vscode-sideBarSectionHeader-foreground);
Expand All @@ -40,31 +134,47 @@ defineProps<{
align-items: center;
cursor: pointer;
display: flex;
justify-content: space-between;
font-size: 11px;
font-weight: 700;
height: 22px;
overflow: hidden;

.twisty-container {
margin: 0 2px;
font-size: 16px;
color: var(--vscode-icon-foreground);
&:focus {
opacity: 1;
outline-color: var(--vscode-focusBorder);
outline-offset: -1px;
outline-style: solid;
outline-width: 1px;
}

.pane-header-title-container {
display: flex;
flex: 1;
align-items: center;

.twisty-container {
margin: 0 2px;
font-size: 16px;
color: var(--vscode-icon-foreground);
}

.title {
font-size: 11px;
min-width: 3ch;
overflow: hidden;
text-overflow: ellipsis;
text-transform: uppercase;
white-space: nowrap;
user-select: none;
-webkit-margin-before: 0;
-webkit-margin-after: 0;
}
}
}

.pane-body {
flex: 1;
overflow: hidden;
}

.title {
font-size: 11px;
min-width: 3ch;
overflow: hidden;
text-overflow: ellipsis;
text-transform: uppercase;
white-space: nowrap;
-webkit-margin-before: 0;
-webkit-margin-after: 0;
}
</style>