Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

[terra-folder-tree] Radio button hover updated #2152

Merged
merged 7 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/terra-folder-tree/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

* Changed
* Updated the radio button hover style to be distinct from row hover.

## 1.3.0 - (April 23, 2024)

* Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
.clinical-lowlight-theme {
--terra-folder-tree-item-border-bottom: #181b1d;
--terra-folder-tree-item-background: #1e3a49;
--terra-folder-tree-item-hover-background-color: #232a2d;
--terra-folder-tree-item-hover-background-color: rgb(203, 230, 247, 0.25);

--terra-folder-tree-item-selected-background-color: #232a2d;
--terra-folder-tree-focus-outline: 2px dashed #fff;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:local {
.orion-fusion-theme {
--terra-folder-tree-item-background-color-hover: #f4fafe;
--terra-folder-tree-item-hover-background-color: rgb(203, 230, 247, 0.5);
--terra-folder-tree-focus-box-shadow: inset 0 0 1px 3px rgba(76, 178, 233, 0.5), inset 0 0 7px 4px rgba(76, 178, 233, 0.35);
--terra-folder-tree-focus-outline: none;
--terra-folder-tree-focus-outline-offset: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useRef } from 'react';
import React, { useContext, useRef, useState } from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames/bind';
import { injectIntl } from 'react-intl';
Expand Down Expand Up @@ -103,6 +103,7 @@ const FolderTreeItem = ({
const isFolder = subfolderItems?.length > 0;
const itemNode = useRef();
const subFolderNode = useRef();
const [radioButtonIsHovered, setRadioButtonIsHovered] = useState(false);

const selectableAnnouncement = isSelectable
? intl.formatMessage({ id: 'Terra.folder-tree.item.selectable-announcement' })
Expand Down Expand Up @@ -138,6 +139,8 @@ const FolderTreeItem = ({
<label
className={cx('radio-target')}
onClick={(e) => { e.stopPropagation(); }} // Prevent triggering expand/collapse during selection
onMouseEnter={() => setRadioButtonIsHovered(true)}
onMouseLeave={() => setRadioButtonIsHovered(false)}
>
<input
type="radio"
Expand All @@ -156,6 +159,7 @@ const FolderTreeItem = ({
'folder-tree-item',
{ selected: isSelectable ? isSelected : null },
theme.className,
{ 'hover-within': radioButtonIsHovered },
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,24 @@
width: 100%;

&:hover {
background-color: var(--terra-folder-tree-item-hover-background-color, #f4fafe);
cursor: pointer;

&:not(.hover-within) {
background-color: var(--terra-folder-tree-item-hover-background-color, rgb(203, 230, 247, 0.5));
}
}

&.hover-within {
.radio-target::before {
content: '';
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
background-color: var(--terra-folder-tree-item-hover-background-color, rgb(203, 230, 247, 0.5));
border-radius: 50%;
Copy link
Contributor Author

@adoroshk adoroshk May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: The pseudo class is used to create a circle on hover, as the actual click area needs to stay square.

}
}

&:focus {
Expand All @@ -39,6 +55,11 @@
padding-left: 48px;
}

.radio,
.radio-target {
position: relative;
}

.radio:hover {
cursor: pointer;
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions packages/terra-folder-tree/tests/wdio/folder-tree-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,18 @@ Terra.describeViewports('FolderTree', ['medium'], () => {
Terra.validates.screenshot('reload-focus', { selector: '#folder-tree-reload' });
});
});

describe('Hover styling', () => {
it('applied to the radio button', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/folder-tree/basic-folder-tree');
$('[class*="radio-target"]').moveTo();
Terra.validates.screenshot('hover-over-radio-button', { selector: '#basic-folder-tree' });
});

it('applied to the tree item', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/folder-tree/basic-folder-tree');
$('[role="treeitem"]:nth-of-type(1)').moveTo();
Terra.validates.screenshot('hover-over-tree-item', { selector: '#basic-folder-tree' });
});
});
});
Loading