diff --git a/src/renderer/components/+namespaces/namespace-select-filter.scss b/src/renderer/components/+namespaces/namespace-select-filter.scss new file mode 100644 index 0000000000..da59651ce5 --- /dev/null +++ b/src/renderer/components/+namespaces/namespace-select-filter.scss @@ -0,0 +1,47 @@ +.NamespaceSelectFilter { + --gradientColor: var(--select-menu-bgc); + + .Select { + &.theme-light { + --gradientColor: white; + } + + &__placeholder { + width: 100%; + white-space: nowrap; + overflow: scroll!important; + text-overflow: unset!important; + margin-left: -8px; + padding-left: 8px; + margin-right: -8px; + padding-right: 8px; + + &::-webkit-scrollbar { + display: none; + } + } + + &__value-container { + position: relative; + + &::before, &::after { + content: ' '; + position: absolute; + z-index: 20; + display: block; + width: 8px; + height: var(--font-size); + } + + &::before { + left: 0px; + background: linear-gradient(to right, var(--gradientColor) 0px, transparent); + } + + &::after { + right: 0px; + background: linear-gradient(to left, var(--gradientColor) 0px, transparent); + } + } + } +} diff --git a/src/renderer/components/+namespaces/namespace-select-filter.tsx b/src/renderer/components/+namespaces/namespace-select-filter.tsx index 8f4e9df6da..ad2c1fe87b 100644 --- a/src/renderer/components/+namespaces/namespace-select-filter.tsx +++ b/src/renderer/components/+namespaces/namespace-select-filter.tsx @@ -19,7 +19,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -import "./namespace-select.scss"; +import "./namespace-select-filter.scss"; import React from "react"; import { observer } from "mobx-react"; @@ -28,10 +28,11 @@ import { components, PlaceholderProps } from "react-select"; import { Icon } from "../icon"; import { FilterIcon } from "../item-object-list/filter-icon"; import { FilterType } from "../item-object-list/page-filters.store"; -import type { SelectOption } from "../select"; import { NamespaceSelect } from "./namespace-select"; import { namespaceStore } from "./namespace.store"; +import type { SelectOption, SelectProps } from "../select"; + const Placeholder = observer((props: PlaceholderProps) => { const getPlaceholder = (): React.ReactNode => { const namespaces = namespaceStore.contextNamespaces; @@ -54,9 +55,8 @@ const Placeholder = observer((props: PlaceholderProps) => { ); }); - @observer -export class NamespaceSelectFilter extends React.Component { +export class NamespaceSelectFilter extends React.Component { formatOptionLabel({ value: namespace, label }: SelectOption) { if (namespace) { const isSelected = namespaceStore.hasContext(namespace); @@ -92,6 +92,7 @@ export class NamespaceSelectFilter extends React.Component { placeholder={""} onChange={this.onChange} formatOptionLabel={this.formatOptionLabel} + className="NamespaceSelectFilter" /> ); } diff --git a/src/renderer/components/+namespaces/namespace-select.scss b/src/renderer/components/+namespaces/namespace-select.scss index 72df94a9a7..e348f7025b 100644 --- a/src/renderer/components/+namespaces/namespace-select.scss +++ b/src/renderer/components/+namespaces/namespace-select.scss @@ -25,41 +25,8 @@ } } -.GradientValueContainer { - width: 8px; - height: var(--font-size); - position: absolute; - z-index: 20; - - &.front { - left: 0px; - background: linear-gradient(to right, var(--contentColor) 0px, transparent); - } - - &.back { - right: 0px; - background: linear-gradient(to left, var(--contentColor) 0px, transparent); - } -} - .NamespaceSelect { @include namespaceSelectCommon; - - .Select { - &__placeholder { - width: 100%; - white-space: nowrap; - overflow: scroll; - margin-left: -8px; - padding-left: 8px; - margin-right: -8px; - padding-right: 8px; - - &::-webkit-scrollbar { - display: none; - } - } - } } .NamespaceSelectMenu { diff --git a/src/renderer/components/+namespaces/namespace-select.tsx b/src/renderer/components/+namespaces/namespace-select.tsx index 3a17e791db..7c98323b74 100644 --- a/src/renderer/components/+namespaces/namespace-select.tsx +++ b/src/renderer/components/+namespaces/namespace-select.tsx @@ -29,7 +29,6 @@ import { cssNames } from "../../utils"; import { Icon } from "../icon"; import { namespaceStore } from "./namespace.store"; import { kubeWatchApi } from "../../api/kube-watch-api"; -import { components, ValueContainerProps } from "react-select"; interface Props extends SelectProps { showIcons?: boolean; @@ -43,16 +42,6 @@ const defaultProps: Partial = { showClusterOption: false, }; -function GradientValueContainer({children, ...rest}: ValueContainerProps) { - return ( - -
- {children} -
- - ); -} - @observer export class NamespaceSelect extends React.Component { static defaultProps = defaultProps as object; @@ -98,8 +87,6 @@ export class NamespaceSelect extends React.Component { render() { const { className, showIcons, customizeOptions, components = {}, ...selectProps } = this.props; - components.ValueContainer ??= GradientValueContainer; - return (