Skip to content

Commit

Permalink
style(ListBox): adjust border-subtle styles to account for proper layer
Browse files Browse the repository at this point in the history
  • Loading branch information
tw15egan committed Jun 21, 2023
1 parent 1fe4029 commit 2e051a6
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/react/src/components/Layer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import cx from 'classnames';
import { usePrefix } from '../../internal/usePrefix';
import { LayerContext } from './LayerContext';

const levels = ['one', 'two', 'three', 'four'];
const levels = ['one', 'two', 'three'];
const MAX_LEVEL = levels.length - 1;

/**
Expand Down
14 changes: 5 additions & 9 deletions packages/react/src/components/ListBox/ListBoxMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import React, { ForwardedRef, useEffect, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import { usePrefix } from '../../internal/usePrefix';
import { ForwardRefReturn, ReactAttr } from '../../types/common';
import { Layer } from '../Layer';

function useIsTruncated(ref) {
const [isTruncated, setIsTruncated] = useState(false);
Expand Down Expand Up @@ -70,14 +69,11 @@ const ListBoxMenuItem = React.forwardRef<HTMLDivElement, ListBoxMenuItemProps>(
className={className}
title={isTruncated ? title : undefined}
tabIndex={-1}>
{/* @ts-ignore Layer is not typed yet*/}
<Layer>
<div
className={`${prefix}--list-box__menu-item__option`}
ref={forwardedRef?.menuItemOptionRef || ref}>
{children}
</div>
</Layer>
<div
className={`${prefix}--list-box__menu-item__option`}
ref={forwardedRef?.menuItemOptionRef || ref}>
{children}
</div>
</div>
);
}
Expand Down
4 changes: 0 additions & 4 deletions packages/styles/scss/_layer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,3 @@
.#{$prefix}--layer-three {
@include layer-tokens.emit-layer-tokens(3);
}

.#{$prefix}--layer-four {
@include layer-tokens.emit-layer-tokens(2);
}
84 changes: 74 additions & 10 deletions packages/styles/scss/components/list-box/_list-box.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,15 @@ $list-box-menu-width: rem(300px);
}

.#{$prefix}--list-box--expanded {
border-bottom-color: $border-subtle;
border-bottom-color: $border-subtle-01;
}

.#{$prefix}--layer-two .#{$prefix}--list-box--expanded {
border-bottom-color: $border-subtle-02;
}

.#{$prefix}--layer-three .#{$prefix}--list-box--expanded {
border-bottom-color: $border-subtle-03;
}

.#{$prefix}--list-box--expanded:hover {
Expand Down Expand Up @@ -582,7 +590,19 @@ $list-box-menu-width: rem(300px);

.#{$prefix}--list-box--disabled
.#{$prefix}--list-box__menu-item__option:hover {
border-top-color: $border-subtle;
border-top-color: $border-subtle-01;
}

.#{$prefix}--layer-two
.#{$prefix}--list-box--disabled
.#{$prefix}--list-box__menu-item__option:hover {
border-top-color: $border-subtle-02;
}

.#{$prefix}--layer-three
.#{$prefix}--list-box--disabled
.#{$prefix}--list-box__menu-item__option:hover {
border-top-color: $border-subtle-03;
}

.#{$prefix}--list-box__menu-item:first-of-type
Expand All @@ -595,17 +615,35 @@ $list-box-menu-width: rem(300px);
color: $text-primary;
}

.#{$prefix}--list-box__menu-item:hover
.#{$prefix}--list-box--disabled
.#{$prefix}--list-box__menu-item:hover
+ .#{$prefix}--list-box__menu-item
.#{$prefix}--list-box__menu-item__option {
border-top-color: transparent;
border-top-color: $border-subtle-01;
}

.#{$prefix}--list-box--disabled
.#{$prefix}--layer-two
.#{$prefix}--list-box--disabled
.#{$prefix}--list-box__menu-item:hover
+ .#{$prefix}--list-box__menu-item
.#{$prefix}--list-box__menu-item__option {
border-top-color: $border-subtle;
border-top-color: $border-subtle-02;
}

.#{$prefix}--layer-three
.#{$prefix}--list-box--disabled
.#{$prefix}--list-box__menu-item:hover
+ .#{$prefix}--list-box__menu-item
.#{$prefix}--list-box__menu-item__option {
border-top-color: $border-subtle-03;
}

.#{$prefix}--layer-two .#{$prefix}--list-box__menu-item__option {
border-top-color: $border-subtle-02;
}

.#{$prefix}--layer-three .#{$prefix}--list-box__menu-item__option {
border-top-color: $border-subtle-03;
}

.#{$prefix}--list-box__menu-item__option {
Expand All @@ -617,7 +655,7 @@ $list-box-menu-width: rem(300px);
padding: rem(11px) 0;
padding-right: $spacing-06;
border-top: 1px solid transparent;
border-top-color: $border-subtle;
border-top-color: $border-subtle-01;
border-bottom: 1px solid transparent;
margin: 0 $spacing-05;
color: $text-secondary;
Expand Down Expand Up @@ -682,14 +720,40 @@ $list-box-menu-width: rem(300px);
}

.#{$prefix}--list-box__menu-item[disabled]
.#{$prefix}--list-box__menu-item__option,
.#{$prefix}--list-box__menu-item[disabled]:hover
+ .#{$prefix}--list-box__menu-item
.#{$prefix}--list-box__menu-item__option {
border-top-color: $border-subtle;
border-top-color: $border-subtle-01;
}

.#{$prefix}--list-box__menu-item[disabled]:hover
.#{$prefix}--layer-two
.#{$prefix}--list-box__menu-item[disabled]
.#{$prefix}--list-box__menu-item__option,
.#{$prefix}--layer-two
.#{$prefix}--list-box__menu-item[disabled]:hover
+ .#{$prefix}--list-box__menu-item
.#{$prefix}--list-box__menu-item__option {
border-top-color: $border-subtle;
border-top-color: $border-subtle-02;
}

.#{$prefix}--layer-three
.#{$prefix}--list-box__menu-item[disabled]
.#{$prefix}--list-box__menu-item__option,
.#{$prefix}--layer-three
.#{$prefix}--list-box__menu-item[disabled]:hover
+ .#{$prefix}--list-box__menu-item
.#{$prefix}--list-box__menu-item__option {
border-top-color: $border-subtle-03;
}

.#{$prefix}--list-box__menu-item--active
+ .#{$prefix}--list-box__menu-item[disabled]
.#{$prefix}--list-box__menu-item__option,
.#{$prefix}--list-box__menu-item:hover
+ .#{$prefix}--list-box__menu-item
.#{$prefix}--list-box__menu-item__option {
border-top-color: transparent;
}

.#{$prefix}--list-box.#{$prefix}--list-box--inline
Expand Down

0 comments on commit 2e051a6

Please sign in to comment.