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

feat(ui): Improve wds builder #700

Merged
merged 6 commits into from
Dec 18, 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
7 changes: 6 additions & 1 deletion src/ui/src/builder/BuilderSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const { floatingStyles, update: updateFloatingStyle } = useFloating(
dropdown,
{
placement: "bottom",
middleware: [autoPlacement()],
middleware: [autoPlacement({ allowedPlacements: ["bottom", "top"] })],
},
);
Expand Down Expand Up @@ -131,6 +131,11 @@ function onSelect(value: string) {
cursor: pointer;
}
.BuilderSelect__trigger:focus {
border: 1px solid var(--softenedAccentColor);
box-shadow: 0px 0px 0px 3px rgba(81, 31, 255, 0.05);
outline: none;
}
.BuilderSelect__trigger__label {
text-overflow: ellipsis;
overflow: hidden;
Expand Down
109 changes: 52 additions & 57 deletions src/ui/src/builder/settings/BuilderSettingsHandlers.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
</WdsFieldWrapper>
</div>
</div>
<WdsButton variant="tertiary" @click="showCustomHandlerModal">
<i class="material-symbols-outlined">add</i>Add custom handler
</WdsButton>
</div>
<BuilderModal
v-if="stubModal"
Expand All @@ -45,62 +48,57 @@
<div class="codeContainer">
<code v-dompurify-html="stubModal.highlightedCodeHtml"> </code>
</div>
<button @click="copyToClipboard(stubModal.code)">
<i class="material-symbols-outlined"> content_copy </i>
<WdsButton
variant="tertiary"
@click="copyToClipboard(stubModal.code)"
>
<i class="material-symbols-outlined">content_copy</i>
Copy code to clipboard
</button>
</WdsButton>
</BuilderModal>
<div class="customHandler">
<button
title="Add a custom event handler"
@click="showCustomHandlerModal"
>
<i class="material-symbols-outlined">add</i>Add custom handler
</button>
<BuilderModal
v-if="customHandlerModal"
:close-action="customHandlerModalCloseAction"
icon="bolt"
modal-title="Add Custom Event Handler"
allow-overflow
>
<div class="customHandlerModalForm">
<WdsFieldWrapper
label="Event type"
hint="Can be any event type."
>
<WdsTextInput
v-model="customHandlerModal.eventType"
type="text"
list="commonEventTypes"
/>
<datalist id="commonEventTypes">
<option
v-for="commonEventType in commonEventTypes"
:key="commonEventType"
:value="commonEventType"
>
{{ commonEventType }}
</option>
</datalist>
</WdsFieldWrapper>
<WdsFieldWrapper
label="Handler function"
hint="The function that will handle the event."
>
<BuilderSelect
v-model="customHandlerModal.handlerFunctionName"
:options="options"
enable-search
/>
</WdsFieldWrapper>
</div>
<BuilderModal
v-if="customHandlerModal"
:close-action="customHandlerModalCloseAction"
icon="bolt"
modal-title="Add Custom Event Handler"
allow-overflow
>
<div class="customHandlerModalForm">
<WdsFieldWrapper
label="Event type"
hint="Can be any event type."
>
<WdsTextInput
v-model="customHandlerModal.eventType"
type="text"
list="commonEventTypes"
/>
<datalist id="commonEventTypes">
<option
v-for="commonEventType in commonEventTypes"
:key="commonEventType"
:value="commonEventType"
>
{{ commonEventType }}
</option>
</datalist>
</WdsFieldWrapper>
<WdsFieldWrapper
label="Handler function"
hint="The function that will handle the event."
>
<BuilderSelect
v-model="customHandlerModal.handlerFunctionName"
:options="options"
enable-search
/>
</WdsFieldWrapper>
</div>

<button @click="addCustomEventHandler()">
<i class="material-symbols-outlined">add</i>Add
</button>
</BuilderModal>
</div>
<WdsButton variant="tertiary" @click="addCustomEventHandler()">
<i class="material-symbols-outlined">add</i>Add
</WdsButton>
</BuilderModal>
</div>
</template>

Expand All @@ -116,6 +114,7 @@ import BuilderSelect from "../BuilderSelect.vue";
import type { Option } from "../BuilderSelect.vue";
import WdsFieldWrapper from "@/wds/WdsFieldWrapper.vue";
import WdsTextInput from "@/wds/WdsTextInput.vue";
import WdsButton from "@/wds/WdsButton.vue";
const wf = inject(injectionKeys.core);
const ssbm = inject(injectionKeys.builderManager);
Expand Down Expand Up @@ -343,10 +342,6 @@ const copyToClipboard = (text: string) => {
gap: 24px;
}
.customHandler {
margin-top: 24px;
}
.addHandler .fields {
display: flex;
gap: 16px;
Expand Down
12 changes: 7 additions & 5 deletions src/ui/src/builder/settings/BuilderSettingsProperties.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,13 @@ const fields = computed(() => {
return definition.fields;
});
const fieldCategories = [
FieldCategory.General,
FieldCategory.Style,
FieldCategory.Tools,
];
const fieldCategories = computed(() => {
return [
FieldCategory.General,
FieldCategory.Style,
FieldCategory.Tools,
].filter((c) => fieldsByCategory.value[c]?.length);
});
const fieldsByCategory = computed(() => {
const entries = Object.entries(fields.value);
Expand Down
34 changes: 20 additions & 14 deletions src/ui/src/wds/WdsDropdownMenu.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<template>
<div class="WdsDropdownMenu">
<div v-if="enableSearch" class="WdsDropdownMenu__search">
<i class="material-symbols-outlined">search</i>
<input
ref="searchInput"
v-model="searchTerm"
class="WdsDropdownMenu__search__input"
type="text"
placeholder="Search"
autocomplete="off"
/>
<div v-if="enableSearch" class="WdsDropdownMenu__search-wrapper">
<div class="WdsDropdownMenu__search">
<i class="material-symbols-outlined">search</i>
<input
ref="searchInput"
v-model="searchTerm"
class="WdsDropdownMenu__search__input"
type="text"
placeholder="Search"
autocomplete="off"
/>
</div>
</div>
<button
v-for="option in optionsFiltered"
Expand Down Expand Up @@ -100,7 +102,7 @@ watch(searchTerm, () => emits("search", searchTerm.value));
box-shadow: 0px 1px 8px 0px #bfcbff40;
box-sizing: border-box;
}
.WdsDropdownMenu:has(.WdsDropdownMenu__search) {
.WdsDropdownMenu:has(.WdsDropdownMenu__search-wrapper) {
padding-top: 0px;
}
Expand Down Expand Up @@ -139,22 +141,26 @@ watch(searchTerm, () => emits("search", searchTerm.value));
overflow: hidden;
text-align: left;
}
.WdsDropdownMenu__search-wrapper {
position: sticky;
top: 0px;
padding-top: 8px;
padding-bottom: 8px;
background: #fff;
}
.WdsDropdownMenu__search {
background-color: #fafafa;
border-radius: 4px;
height: 36px;
width: 100%;
margin-bottom: 8px;
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
padding: 8px;
padding-top: 16px;
border: 1px solid transparent;
color: currentcolor;
Expand Down
25 changes: 9 additions & 16 deletions src/ui/src/wds/WdsFieldWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,27 @@
>&nbsp;:&nbsp;{{ unit }}</span
>
</label>
<button
<WdsButton
v-if="helpButton"
class="WdsFieldWrapper__title__help"
variant="subtle"
:title="typeof helpButton === 'string' ? helpButton : undefined"
variant="neutral"
size="smallIcon"
Comment on lines +13 to +14
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@ramedina86 , about the help button, the issue is: The help icon includes the circle (here), thus tertiary variant feels weird

image

I thought about using question_mark icon instead, but it's still not that pretty

image

So I decided to stik to neutral and this is the result.

Screencast.From.2024-12-17.13-02-20.mp4

WDYT ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Neutral looks great

:data-writer-tooltip="
typeof helpButton === 'string' ? helpButton : undefined
"
@click="$emit('helpClick')"
>
<i class="material-symbols-outlined">help</i>
</button>
</WdsButton>
</div>
<div class="WdsFieldWrapper__slot"><slot></slot></div>
<div v-if="hint" class="WdsFieldWrapper__hint">{{ hint }}</div>
</div>
</template>

<script setup lang="ts">
import WdsButton from "./WdsButton.vue";
defineProps({
label: { type: String, required: false, default: undefined },
unit: { type: String, required: false, default: undefined },
Expand Down Expand Up @@ -57,18 +62,6 @@ defineEmits({
gap: 8px;
}
.WdsFieldWrapper__title__help {
background-color: transparent;
border: none;
border-radius: 50%;
cursor: pointer;
display: flex;
align-items: center;
}
.WdsFieldWrapper__title__help:hover {
color: var(--primaryColor);
}
.WdsFieldWrapper__title__label {
font-size: 14px;
font-weight: 400;
Expand Down
Loading