-
Notifications
You must be signed in to change notification settings - Fork 1
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
Display delete action when hovering over read-only term-input entries #249
base: main
Are you sure you want to change the base?
Conversation
eba0e21
to
86e2e36
Compare
asset/css/search-base.less
Outdated
@@ -273,12 +284,19 @@ fieldset:disabled .term-input-area [data-drag-initiator] { | |||
outline-offset: ~"calc(-@{labelPad} + 3px)"; | |||
} | |||
|
|||
&:not(.vertical) { | |||
--delete-action-height: ~"calc(2em + 1.75px)"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment, what is calculated here?
As this rule should only apply when read only, you can add it down below.
And you do't need to create a var. you can apply as follows:
&.read-only {
...
&:not(.vertical) .delete-action {
height: ~"calc(2em + 1.75px)";
}
}
asset/css/variables.less
Outdated
@@ -162,6 +164,8 @@ | |||
--search-term-highlighted-bg: var(--primary-button-bg); | |||
--search-term-highlighted-color: var(--default-text-color-inverted); | |||
--search-term-drag-border-color: var(--base-gray); | |||
--search-term-delete-action-color: var(--base-remove-bg); | |||
--search-term-delete-action-color-bg: var(--default-text-color-inverted); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please name the variable same as the less variable (--search-term-delete-action-bg
).
asset/css/variables.less
Outdated
@@ -66,6 +66,8 @@ | |||
@search-term-highlighted-bg: @base-primary-bg; | |||
@search-term-highlighted-color: @default-text-color-inverted; | |||
@search-term-drag-border-color: @base-gray; | |||
@search-term-delete-action-bg: @state-critical; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please introduce @default-remove-bg
and @default-delete-bg
and initialize these to @state-critical.
Then use the @default-remove-bg
instead of @state-critical
here.
As we have the Remove
button for now, please change @search-term-**delete**-action-bg
to remove
.
Please do the same for css variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see the benefit here, as long as there's no multiple references to it. Same could be said about line 61 and 62 🤔
); | ||
$label->addHtml(new HtmlElement('span', Attributes::create(['class' => 'invalid-reason']))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add it in the above addHtml
call, after .delete-action
element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would add it as a children of remove-action
, which I don't want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the addHtml accepts multiple parameters, so you can add it like this:
$label->addHtml(
... .delete-button,
new HtmlElement('span', Attributes::create(['class' => 'invalid-reason']))
);
But that's optional, it's fine the way it is.
src/FormElement/TermInput.php
Outdated
@@ -384,7 +384,8 @@ protected function termContainer(): TermContainer | |||
{ | |||
if ($this->termContainer === null) { | |||
$this->termContainer = (new TermContainer($this)) | |||
->setAttribute('id', $this->getName() . '-terms'); | |||
->setAttribute('id', $this->getName() . '-terms') | |||
->setAttribute('delete-action-label', $this->translate('Remove')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an internal thing for TermContainer
and it is only required when the input is read-only
.
Please add it in the TermContainer::assemble() as follows:
...
if ($this->input->getReadOnly()) {
$removeLabel = $this->translate('Remove');
$this->setAttribute('delete-action-label', $removeLabel);
....
new Icon('trash'),
new HtmlElement(
'span',
Attributes::create(['class' => 'delete-action-label']),
new Text($removeLabel)
)
...
}
86e2e36
to
282600b
Compare
asset/css/variables.less
Outdated
@@ -36,11 +36,17 @@ | |||
@base-primary-bg: #00C3ED; | |||
@base-primary-dark: #0081a6; | |||
@base-primary-light: fade(@base-primary-bg, 50%); | |||
@base-remove-bg: @state-critical; | |||
@base-delete-bg: @base-remove-bg; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need @base-*-bg
, @default-*-bg
is sufficient, as these are only used to initialise @default-
vars.
Please remove these variables.
asset/css/search-base.less
Outdated
background: var(--search-term-remove-action-bg, @search-term-remove-action-bg); | ||
color: var(--search-term-remove-action-color, @search-term-remove-action-color); | ||
border: none; | ||
border-radius: 0.25em; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have .rounded-corners()
mixin for radius.
@@ -33,6 +38,11 @@ public function __construct(TermInput $input) | |||
|
|||
protected function assemble() | |||
{ | |||
if ($this->input->getReadOnly()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already have the same if condition below, please add it there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not going to set that attribute for each loop iteration...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh, somehow I overlooked the loop scope. You're right.
Optional: I would still omit the call getAttribute()->getValue()
for the label.
new HtmlElement( | ||
'span', | ||
Attributes::create(['class' => 'remove-action-label']), | ||
new Text($this->getAttribute('remove-action-label')->getValue()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This becomes superfluous once you have merged the if condition above. You can save the translated version in a variable and use it for attribute value and as $content for new Text()
. This is what I have already suggested here.
Attributes::create([ | ||
'class' => 'delete-action-content' | ||
]), | ||
...Html::wantHtmlList([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have overlooked this.
asset/css/search-base.less
Outdated
align-items: center; | ||
background: var(--search-term-remove-action-bg, @search-term-remove-action-bg); | ||
color: var(--search-term-remove-action-color, @search-term-remove-action-color); | ||
border: none; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not required, as you have never defined a border, so you do not need to remove it.
asset/css/search-base.less
Outdated
@@ -264,6 +276,10 @@ fieldset:disabled .term-input-area [data-drag-initiator] { | |||
} | |||
} | |||
} | |||
|
|||
&.read-only [data-index] > .remove-action { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not set a higher specificity here. It should be the same as the rule for non-vertical. So please remove >
.
asset/css/search-base.less
Outdated
@@ -277,8 +293,11 @@ fieldset:disabled .term-input-area [data-drag-initiator] { | |||
[data-index] { | |||
position: relative; | |||
|
|||
&:not(:hover) > .remove-action { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move it a few lines down, after or before the definition of .remove-action
for better readability.
asset/css/search-base.less
Outdated
@@ -75,6 +75,18 @@ fieldset:disabled .term-input-area [data-drag-initiator] { | |||
} | |||
} | |||
|
|||
.remove-action { | |||
display: flex; | |||
text-align: center; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text-align
seems to be superfluous.
visibility: visible; | ||
position: absolute; | ||
z-index: 1; | ||
width: 100%; | ||
top: 0; | ||
left: 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can move all these properties, which are always required (vertical or not), to the above definition for better readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even better, the above definition can be merged into this one, as the ‘Remove’ button is only needed if the input field is read-only
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What definitions are you referring to with "above definition"? The one starting on line 78? I placed it there because it's considered to be style relevant and not layout relevant.
This PR changes the way by which the user gets hinted about the possibility to remove an entry out of a read-only list of term-input values.
Resolves: #243