Skip to content

Commit

Permalink
feat: add styling for disabled options
Browse files Browse the repository at this point in the history
  • Loading branch information
philippfromme committed Aug 12, 2024
1 parent 0c33ad0 commit 4382fce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/assets/properties-panel.css
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,14 @@ textarea.bio-properties-panel-input {
--input-border-color: var(--input-focus-border-color);
}

.bio-properties-panel-select-option-disabled {
color: var(--input-disabled-color);

option {
color: var(--text-base-color);
}
}

.bio-properties-panel-input:disabled {
border-color: var(--input-disabled-border-color);
background-color: var(--input-disabled-background-color);
Expand Down
7 changes: 5 additions & 2 deletions src/components/entries/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ function Select(props) {
setLocalValue(value);
}, [ value ]);

const selectedOptionDisabled = options.find(option => option.value === value && option.disabled);

return (
<div class="bio-properties-panel-select">
<label for={ prefixId(id) } class="bio-properties-panel-label">
Expand All @@ -78,7 +80,7 @@ function Select(props) {
ref={ ref }
id={ prefixId(id) }
name={ id }
class="bio-properties-panel-input"
class={ classNames('bio-properties-panel-input', { 'bio-properties-panel-select-option-disabled': selectedOptionDisabled }) }
onInput={ handleChange }
onFocus={ onFocus }
onBlur={ onBlur }
Expand All @@ -94,6 +96,7 @@ function Select(props) {
key={ idx }
value={ child.value }
disabled={ child.disabled }
hidden={ child.hidden }
>
{child.label}
</option>
Expand All @@ -103,7 +106,7 @@ function Select(props) {
}

return (
<option key={ idx } value={ option.value } disabled={ option.disabled }>
<option key={ idx } value={ option.value } disabled={ option.disabled } hidden={ option.hidden }>
{option.label}
</option>
);
Expand Down

0 comments on commit 4382fce

Please sign in to comment.