Skip to content

Commit

Permalink
fix(modal): use contextual layer tokens (#16860)
Browse files Browse the repository at this point in the history
* fix(modal): use contextual layer tokens

* fix(modal): restore fluid input overwrites

* fix(composed-modal): use contextual layer tokens
  • Loading branch information
janhassel authored Jun 25, 2024
1 parent 5e000ea commit db0978e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 49 deletions.
10 changes: 6 additions & 4 deletions packages/react/src/components/ComposedModal/ComposedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import React, {
} from 'react';
import { isElement } from 'react-is';
import PropTypes from 'prop-types';
import { Layer } from '../Layer';
import { ModalHeader, type ModalHeaderProps } from './ModalHeader';
import { ModalFooter, type ModalFooterProps } from './ModalFooter';
import debounce from 'lodash.debounce';
Expand Down Expand Up @@ -96,13 +97,13 @@ export const ModalBody = React.forwardRef<HTMLDivElement, ModalBodyProps>(
: {};

return (
<div
<Layer
className={contentClass}
{...hasScrollingContentProps}
{...rest}
ref={mergeRefs(contentRef, ref)}>
{children}
</div>
</Layer>
);
}
);
Expand Down Expand Up @@ -415,8 +416,9 @@ const ComposedModal = React.forwardRef<HTMLDivElement, ComposedModalProps>(
}

return (
<div
<Layer
{...rest}
level={0}
role="presentation"
ref={ref}
aria-hidden={!open}
Expand Down Expand Up @@ -453,7 +455,7 @@ const ComposedModal = React.forwardRef<HTMLDivElement, ComposedModalProps>(
</button>
)}
</div>
</div>
</Layer>
);
}
);
Expand Down
10 changes: 6 additions & 4 deletions packages/react/src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import toggleClass from '../../tools/toggleClass';
import Button from '../Button';
import ButtonSet from '../ButtonSet';
import InlineLoading from '../InlineLoading';
import { Layer } from '../Layer';
import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsTruthy';
import wrapFocus, {
wrapFocusWithoutSentinels,
Expand Down Expand Up @@ -528,13 +529,13 @@ const Modal = React.forwardRef(function Modal(
{normalizedSlug}
{!passiveModal && modalButton}
</div>
<div
<Layer
ref={contentRef}
id={modalBodyId}
className={contentClasses}
{...hasScrollingContentProps}>
{children}
</div>
</Layer>
{!passiveModal && (
<ButtonSet className={footerClasses} aria-busy={loadingActive}>
{Array.isArray(secondaryButtons) && secondaryButtons.length <= 2
Expand Down Expand Up @@ -581,8 +582,9 @@ const Modal = React.forwardRef(function Modal(
);

return (
<div
<Layer
{...rest}
level={0}
onKeyDown={handleKeyDown}
onMouseDown={handleMousedown}
onBlur={!focusTrapWithoutSentinels ? handleBlur : () => {}}
Expand Down Expand Up @@ -610,7 +612,7 @@ const Modal = React.forwardRef(function Modal(
Focus sentinel
</span>
)}
</div>
</Layer>
);
});

Expand Down
41 changes: 0 additions & 41 deletions packages/styles/scss/components/modal/_modal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,47 +51,6 @@
}
}

// V11: Question for design: do we have an updated tokens for fields that exist on `layer`?
.#{$prefix}--pagination,
.#{$prefix}--pagination__control-buttons,
.#{$prefix}--text-input,
.#{$prefix}--text-area,
.#{$prefix}--search-input,
.#{$prefix}--select-input,
.#{$prefix}--dropdown,
.#{$prefix}--dropdown-list,
.#{$prefix}--number input[type='number'],
.#{$prefix}--date-picker__input,
.#{$prefix}--multi-select,
.#{$prefix}--number__control-btn::before,
.#{$prefix}--number__control-btn::after,
.#{$prefix}--list-box input[role='combobox'] {
background-color: $field-02;
}

// Override to align layer token with field
.#{$prefix}--list-box__menu {
background-color: $layer-02;
}

.#{$prefix}--number__rule-divider {
background-color: $border-subtle-02;
}

.#{$prefix}--list-box__menu-item__option {
border-block-start-color: $border-subtle-02;
}

.#{$prefix}--list-box__menu-item:hover
.#{$prefix}--list-box__menu-item__option {
border-block-start-color: $layer-hover-02;
}

.#{$prefix}--list-box__menu-item--active:hover
.#{$prefix}--list-box__menu-item__option {
border-block-start-color: $layer-selected-hover-02;
}

// Fluid inputs
.#{$prefix}--text-input--fluid .#{$prefix}--text-input,
.#{$prefix}--text-area--fluid .#{$prefix}--text-area__wrapper,
Expand Down

0 comments on commit db0978e

Please sign in to comment.