Page MenuHomePhabricator

[WtC-M3] [QB] Port OptionsMenu component to Query Builder
Closed, ResolvedPublic

Assigned To
Authored By
Sarai-WMDE
Jul 12 2024, 1:40 PM
Referenced Files
F58300370: image.png
Jan 28 2025, 4:48 PM
F58299644: image.png
Jan 28 2025, 4:39 PM
F58299634: image.png
Jan 28 2025, 4:39 PM
F56641626: image.png
Jul 24 2024, 11:55 AM
F56621934: image.png
Jul 23 2024, 6:08 PM

Description

Problem

The OptionsMenu component was implemented to allow the presentation and selection of results and options from inputs like Lookup or Select. We need to port the former, LookupInput, to the Query builder repository in order to deprecate WiKit.

Solution

In order to unblock the migration to Codex and the deprecation of WiKit, we'll port the WiKit OptionsMenu component to the Query Builder repository. We'll apply all necessary changes to make the element compatible with the new version of the tool and Codex styles.

Considerations
  • Styles: We should also replace all WiKit tokens used currently to style the Input. We could use both discrete values or Codex tokens. It might be a slightly better idea to do the later in order to ensure consistency.

image.png (1×2 px, 297 KB)

Creating design specs to indicate style adjustments sounded like a limited and error-prone handover method. Replacing WiKit tokens by Codex's directly seemed like a more effective way to proceed in this case:

<style lang="scss">
$base: '.wikit-OptionsMenu';

#{$base} {
	min-width: $size-full;
	/* Uses CSS min, Falls back on 95vw when max-width > viewport width */
	max-width: #{min}($size-double, 95vw);
	width: max-content;
	background-color: $background-color-base;
        border-radius: $border-radius-sharp $border-radius-sharp $border-radius-base $border-radius-base;
	border: $border-base;
	box-shadow: $box-shadow-drop-medium;
	overflow-y: auto;
	box-sizing: $box-sizing-base;
	z-index: $z-index-dropdown;

	&__item {
		position: relative;
		padding: $spacing-50 $spacing-75;
		transition-property: $transition-property-base;
		transition-duration: $transition-duration-base;

		&:hover,
		&--hovered {
			background-color: $background-color-interactive;
			cursor: $cursor-base--hover;
		}

		&--active,
		&--active:hover,
		&:active {
			background-color: $background-color-progressive-subtle;

			#{$base}__item__label, #{$base}__item__description {
				color: $color-progressive;
			}
		}

		&--selected {
			#{$base}__item__label, #{$base}__item__description {
				color: $color-base;
			}
		}

		&--selected,
		&--selected:hover,
		&--selected#{$base}__item--hovered, {
			background-color: $background-color-progressive-subtle;
		}

		&--selected:hover,
		&--selected#{$base}__item--hovered, {
			#{$base}__item__label, #{$base}__item__description {
				color: $color-progressive;
			}
		}

		&__label {
			font-family: $font-family-system-sans;
			font-size: $font-size-medium;
			font-weight: $font-weight-normal;
			color: $color-base;
			line-height: $line-height-xx-small;

			&--bold {
				font-weight: $font-weight-bold;
			}

			&-wrapper {
				display: flex;
			}
		}

		&__description {
			font-family: $font-family-system-sans;
			font-size: $font-size-medium;
			font-weight: $font-weight-normal;
			color: $color-subtle;
			line-height: $line-height-xx-small;
		}

		&__tag {
			font-family: $font-family-system-sans;
			font-size: $font-size-medium;
			font-weight: $font-weight-normal;
			color: $color-subtle;
			line-height: $line-height-xx-small;
			padding-inline-start: $spacing-25;
			display: inline;
			white-space: nowrap;
		}
	}

	&__no-results {
		font-family: $font-family-system-sans;
		font-size: $font-size-medium;
		font-weight: $font-weight-normal;
		color: $color-base;
		line-height: $line-height-medium;
		padding: $spacing-50 $spacing-75;
	}
}
</style>

⚠️ Menu max-width: The Codex's Menu component has a default (min/max) width of 100%, while in WiKit we allowed menus to grow up to 200% of the size of the input they accompany. This was decided to make room for Wikidata Entity descriptions, which can be quite long and push further options out of sight in case they wrap into a few lines. It sounds sensible to keep that custom width for now, specially considering the use case for menu in the QuantityInput's Lookup, which would be too small if we adopted the default 100%.

⚠️ Menu interaction: There are certain interaction details that will be make the behavior of the Codex and WiKit menus inconsistent. These are acceptable because it's unlikely for these differences to have an impact over the users' experience within the Query Builder. Moreover, applying changes to the ported component to ensure full parity sounds like a hard to justify effort, given the momentary nature of this situation.

⚠️ Missing properties: All deletion is intentional and motivated by the need to bring WiKit components' appearance closer to Codex's.

Acceptance criteria
  • OptionsMenu is ported to Query builder for its reusage by other components
  • Any necessary adjustments are applied to make the component compatible with Vue3
  • Any WiKit building blocks, dependencies or styles are replaced or ported too if necessary

Details

Related Changes in Gerrit:
Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
Fix UI/UX issues for final releaserepos/wmde/wikidata-query-builder!5haakui-cleanupmaster
Customize query in GitLab

Event Timeline

Sarai-WMDE renamed this task from [SW] Port OptionsMenu component to Query Builder to [SW] [WtC-M3] [QB] Port OptionsMenu component to Query Builder.Jul 16 2024, 11:26 AM
Arian_Bozorg renamed this task from [SW] [WtC-M3] [QB] Port OptionsMenu component to Query Builder to [WtC-M3] [QB] Port OptionsMenu component to Query Builder.Jul 30 2024, 8:45 AM

Change #1087176 had a related patch set uploaded (by Hasan Akgün (WMDE); author: Hasan Akgün (WMDE)):

[wikidata/query-builder@master] Port WikitOptionsMenu component

https://gerrit.wikimedia.org/r/1087176

Change #1087176 merged by jenkins-bot:

[wikidata/query-builder@master] Port WikitOptionsMenu component

https://gerrit.wikimedia.org/r/1087176

Could you please provide me with a netlify link so that i can review the changes?

  1. it seems like the menu width does not expant up to 200% of the input size to accomodate longer content

"old" QB:

image.png (642×1 px, 126 KB)

with proposed changes:
image.png (508×626 px, 55 KB)

  1. I'm not super sure if i'm getting the right information form the dev tools but for me it says that the line height is 1.428 instead of the 1.375 that Sarai specified. Could you please check if that is indeed the current line height?

Other than that it looks good to me!

sorry just noticed one more thing: the description of a selected menu item should be blue as well according to codex

image.png (274×518 px, 19 KB)
. Currently only the title color changes and the description remains black/grey.

Change #1126027 had a related patch set uploaded (by Hasan Akgün (WMDE); author: Hasan Akgün (WMDE)):

[wikidata/query-builder@master] Update codex version to fix colors and styles

https://gerrit.wikimedia.org/r/1126027

Had a look together with @HasanAkgun_WMDE and everything looks good now 🎉