diff --git a/CHANGELOG.md b/CHANGELOG.md index 704e077..2fdf259 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [2.23.1](https://github.com/gravity-ui/navigation/compare/v2.23.0...v2.23.1) (2024-09-10) + + +### Bug Fixes + +* **Logo:** fix condition display logo ([#306](https://github.com/gravity-ui/navigation/issues/306)) ([38f234a](https://github.com/gravity-ui/navigation/commit/38f234a98f2d526e04f1d85ad6907e015cd81315)) + ## [2.23.0](https://github.com/gravity-ui/navigation/compare/v2.22.0...v2.23.0) (2024-08-30) diff --git a/package-lock.json b/package-lock.json index 35831c0..3039c09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gravity-ui/navigation", - "version": "2.23.0", + "version": "2.23.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@gravity-ui/navigation", - "version": "2.23.0", + "version": "2.23.1", "license": "MIT", "dependencies": { "react-transition-group": "^4.4.1", diff --git a/package.json b/package.json index 1a6731f..f3f9beb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gravity-ui/navigation", - "version": "2.23.0", + "version": "2.23.1", "description": "Gravity UI Navigation components", "license": "MIT", "repository": { diff --git a/scripts/playwright-docker.sh b/scripts/playwright-docker.sh index 3507309..7674751 100755 --- a/scripts/playwright-docker.sh +++ b/scripts/playwright-docker.sh @@ -7,20 +7,34 @@ IMAGE_TAG="v1.45.3-jammy" # This version have to be synchronized with playwright NODE_MODULES_CACHE_DIR="$HOME/.cache/navigation-playwright-docker-node-modules" +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + run_command() { - docker run --rm --network host -it -w /work \ + $CONTAINER_TOOL run --rm --network host -it -w /work \ -v $(pwd):/work \ -v "$NODE_MODULES_CACHE_DIR:/work/node_modules" \ "$IMAGE_NAME:$IMAGE_TAG" \ /bin/bash -c "$1" } +if command_exists docker; then + CONTAINER_TOOL="docker" +elif command_exists podman; then + CONTAINER_TOOL="podman" +else + echo "Neither Docker nor Podman is installed on the system." + exit 1 +fi + if [[ "$1" = "clear-cache" ]]; then rm -rf "$NODE_MODULES_CACHE_DIR" exit 0 fi if [[ ! -d "$NODE_MODULES_CACHE_DIR" ]]; then + mkdir -p "$NODE_MODULES_CACHE_DIR" run_command 'npm ci' fi diff --git a/src/components/AllPagesPanel/AllPagesListItem/AllPagesListItem.scss b/src/components/AllPagesPanel/AllPagesListItem/AllPagesListItem.scss index 85596f4..9753187 100644 --- a/src/components/AllPagesPanel/AllPagesListItem/AllPagesListItem.scss +++ b/src/components/AllPagesPanel/AllPagesListItem/AllPagesListItem.scss @@ -1,6 +1,9 @@ @use '../../variables'; +@use '../../../../styles/mixins'; .#{variables.$ns}all-pages-list-item { + @include mixins.accessibility-button; + display: flex; align-items: center; @@ -11,6 +14,7 @@ &__text { flex: 1; + text-align: initial; } &__icon { diff --git a/src/components/AllPagesPanel/AllPagesListItem/AllPagesListItem.tsx b/src/components/AllPagesPanel/AllPagesListItem/AllPagesListItem.tsx index dfa6bcb..1cf76b1 100644 --- a/src/components/AllPagesPanel/AllPagesListItem/AllPagesListItem.tsx +++ b/src/components/AllPagesPanel/AllPagesListItem/AllPagesListItem.tsx @@ -27,14 +27,17 @@ export const AllPagesListItem: React.FC = (props) => { [onToggle], ); - const onItemClick = (e: MouseEvent) => { + const onItemClick = (e: MouseEvent) => { if (editMode) { e.stopPropagation(); e.preventDefault(); } }; + + const [Tag, tagProps] = item.link ? ['a' as const, {href: item.link}] : ['button' as const, {}]; + return ( -
+ {item.icon ? ( ) : null} @@ -47,6 +50,6 @@ export const AllPagesListItem: React.FC = (props) => { {item.hidden ? : } )} -
+ ); }; diff --git a/src/components/AsideHeader/AsideHeader.scss b/src/components/AsideHeader/AsideHeader.scss index da11730..b24daa7 100644 --- a/src/components/AsideHeader/AsideHeader.scss +++ b/src/components/AsideHeader/AsideHeader.scss @@ -182,20 +182,14 @@ $block: '.#{variables.$ns}aside-header'; } } - &__logo-button-wrapper { + &__logo-button &__logo-icon-place { + height: var( + --gn-aside-header-item-icon-background-size, + var(--_--item-icon-background-size) + ); width: var(--gn-aside-header-min-width); } - &__logo-button[class] { - &, - .g-button__icon { - height: var( - --gn-aside-header-item-icon-background-size, - var(--_--item-icon-background-size) - ); - } - } - &__menu-items { flex-grow: 1; } diff --git a/src/components/AsideHeader/AsideHeaderContext.ts b/src/components/AsideHeader/AsideHeaderContext.ts index 37a8a33..b59ea82 100644 --- a/src/components/AsideHeader/AsideHeaderContext.ts +++ b/src/components/AsideHeader/AsideHeaderContext.ts @@ -10,7 +10,7 @@ export interface AsideHeaderInnerContextType extends AsideHeaderInnerProps { onItemClick: ( item: MenuItem, collapsed: boolean, - event: React.MouseEvent, + event: React.MouseEvent, ) => void; } diff --git a/src/components/AsideHeader/components/FirstPanel.tsx b/src/components/AsideHeader/components/FirstPanel.tsx index f50c7a7..759d0dc 100644 --- a/src/components/AsideHeader/components/FirstPanel.tsx +++ b/src/components/AsideHeader/components/FirstPanel.tsx @@ -25,7 +25,6 @@ export const FirstPanel = React.forwardRef((_props, ref) => { customBackgroundClassName, className, hideCollapseButton, - logo, qa, } = useAsideHeaderInnerContext(); const visibleMenuItems = useVisibleMenuItems(); @@ -47,8 +46,7 @@ export const FirstPanel = React.forwardRef((_props, ref) => { {customBackground} )} - {/* TODO add new prop for hiding Header */} - {logo &&
} +
{visibleMenuItems?.length ? ( { [onClosePanel, logo], ); - if (!logo) { - return null; - } - return (
- + {logo && ( + + )} , - ) => { + (item: MenuItem, collapsed: boolean, event: React.MouseEvent) => { if (item.id === ALL_PAGES_MENU_ITEM.id) { onClosePanel?.(); setInnerVisiblePanel((prev) => diff --git a/src/components/CompositeBar/CompositeBar.tsx b/src/components/CompositeBar/CompositeBar.tsx index 3124fa7..0c28a0f 100644 --- a/src/components/CompositeBar/CompositeBar.tsx +++ b/src/components/CompositeBar/CompositeBar.tsx @@ -35,7 +35,7 @@ export type CompositeBarProps = CompositeBarItems & { onItemClick?: ( item: MenuItem, collapsed: boolean, - event: React.MouseEvent, + event: React.MouseEvent, ) => void; multipleTooltip?: boolean; menuMoreTitle?: string; diff --git a/src/components/CompositeBar/HighlightedItem/HighlightedItem.tsx b/src/components/CompositeBar/HighlightedItem/HighlightedItem.tsx index 8c7bfe3..fefb77e 100644 --- a/src/components/CompositeBar/HighlightedItem/HighlightedItem.tsx +++ b/src/components/CompositeBar/HighlightedItem/HighlightedItem.tsx @@ -13,7 +13,7 @@ const b = block('composite-bar-highlighted-item'); interface ItemInnerProps { iconRef: React.RefObject; iconNode: React.ReactNode; - onClick?: (event: React.MouseEvent) => void; + onClick?: (event: React.MouseEvent) => void; onClickCapture?: (event: React.SyntheticEvent) => void; } diff --git a/src/components/CompositeBar/Item/Item.scss b/src/components/CompositeBar/Item/Item.scss index 8defac9..89c0862 100644 --- a/src/components/CompositeBar/Item/Item.scss +++ b/src/components/CompositeBar/Item/Item.scss @@ -1,8 +1,11 @@ @use '../../variables'; +@use '../../../../styles/mixins'; $block: '.#{variables.$ns}composite-bar-item'; #{$block} { + @include mixins.accessibility-button; + $class: &; --gn-composite-bar-item-action-size: 36px; @@ -24,6 +27,7 @@ $block: '.#{variables.$ns}composite-bar-item'; height: 100%; align-items: center; cursor: pointer; + padding: 0; &__icon { color: var(--gn-aside-header-item-icon-color, var(--_--item-icon-color)); @@ -94,6 +98,8 @@ $block: '.#{variables.$ns}composite-bar-item'; } &__collapse-item { + @include mixins.accessibility-button; + --_--item-icon-color: var(--g-color-text-misc); display: flex; diff --git a/src/components/CompositeBar/Item/Item.tsx b/src/components/CompositeBar/Item/Item.tsx index 830d0c6..094dd2a 100644 --- a/src/components/CompositeBar/Item/Item.tsx +++ b/src/components/CompositeBar/Item/Item.tsx @@ -36,7 +36,7 @@ export interface ItemProps extends ItemPopup { onItemClick?: ( item: MenuItem, collapsed: boolean, - event: React.MouseEvent, + event: React.MouseEvent, ) => void; onItemClickCapture?: (event: React.SyntheticEvent) => void; bringForward?: boolean; @@ -92,7 +92,7 @@ export const Item: React.FC = (props) => { const [open, toggleOpen] = React.useState(false); - const ref = React.useRef(null); + const ref = React.useRef(null); const anchorRef = popupAnchor || ref; const highlightedRef = React.useRef(null); @@ -158,13 +158,18 @@ export const Item: React.FC = (props) => { }; const makeNode = ({icon: iconEl, title: titleEl}: MakeItemParams) => { + const [Tag, tagProps] = item.link + ? ['a' as const, {href: item.link}] + : ['button' as const, {}]; + const createdNode = ( -
) => { + onClick={(event: React.MouseEvent) => { if (collapsedItem) { /** * If we call onItemClick for collapsedItem then: @@ -198,7 +203,7 @@ export const Item: React.FC = (props) => { > {titleEl}
-
+ {renderPopupContent && Boolean(anchorRef?.current) && ( = (props) => { ); - return item.link ? ( - - {createdNode} - - ) : ( - createdNode - ); + return createdNode; }; const iconNode = icon ? ( @@ -255,7 +254,7 @@ export const Item: React.FC = (props) => { ) => + onClick={(event: React.MouseEvent) => onItemClick?.(item, false, event) } onClickCapture={onItemClickCapture} @@ -301,26 +300,21 @@ function CollapsedPopup({ title: titleEl, icon: iconEl, }: MakeItemParams) => { - const res = ( -
, - ) => { + onClick={(event: React.MouseEvent) => { onItemClick?.(collapseItem, true, event); }} > {iconEl} {titleEl} -
- ); - - return collapseItem.link ? ( - - {res} - - ) : ( - res + ); }; diff --git a/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-ManyItems-dark-webkit-linux.png b/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-ManyItems-dark-webkit-linux.png index e124f96..854b612 100644 Binary files a/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-ManyItems-dark-webkit-linux.png and b/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-ManyItems-dark-webkit-linux.png differ diff --git a/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-ManyItems-light-webkit-linux.png b/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-ManyItems-light-webkit-linux.png index f01b595..3bceef8 100644 Binary files a/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-ManyItems-light-webkit-linux.png and b/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-ManyItems-light-webkit-linux.png differ diff --git a/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-Showcase-dark-webkit-linux.png b/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-Showcase-dark-webkit-linux.png index e278fa9..53fbedd 100644 Binary files a/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-Showcase-dark-webkit-linux.png and b/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-Showcase-dark-webkit-linux.png differ diff --git a/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-Showcase-light-webkit-linux.png b/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-Showcase-light-webkit-linux.png index 28b4a51..9184da0 100644 Binary files a/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-Showcase-light-webkit-linux.png and b/src/components/Footer/desktop/__snapshots__/Footer.visual.test.tsx-snapshots/Footer-render-story-Showcase-light-webkit-linux.png differ diff --git a/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-ManyItems-dark-webkit-linux.png b/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-ManyItems-dark-webkit-linux.png index be90ed5..f30114d 100644 Binary files a/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-ManyItems-dark-webkit-linux.png and b/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-ManyItems-dark-webkit-linux.png differ diff --git a/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-ManyItems-light-webkit-linux.png b/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-ManyItems-light-webkit-linux.png index 29c7685..c39e4f1 100644 Binary files a/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-ManyItems-light-webkit-linux.png and b/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-ManyItems-light-webkit-linux.png differ diff --git a/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-Showcase-dark-webkit-linux.png b/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-Showcase-dark-webkit-linux.png index 3070363..3e93101 100644 Binary files a/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-Showcase-dark-webkit-linux.png and b/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-Showcase-dark-webkit-linux.png differ diff --git a/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-Showcase-light-webkit-linux.png b/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-Showcase-light-webkit-linux.png index d26de28..44f9dbe 100644 Binary files a/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-Showcase-light-webkit-linux.png and b/src/components/Footer/mobile/__snapshots__/MobileFooter.visual.test.tsx-snapshots/MobileFooter-render-story-Showcase-light-webkit-linux.png differ diff --git a/src/components/Logo/Logo.scss b/src/components/Logo/Logo.scss index aca66b9..27a302a 100644 --- a/src/components/Logo/Logo.scss +++ b/src/components/Logo/Logo.scss @@ -7,28 +7,14 @@ $block: '.#{variables.$ns}logo'; #{$block} { display: flex; align-items: center; - flex-shrink: 0; height: 40px; - &__logo-btn-place { - flex-shrink: 0; + &__btn-logo { display: flex; align-items: center; + flex-shrink: 0; justify-content: center; - cursor: pointer; - - & .g-button::before { - background-color: transparent; - } - } - - &__logo { - @include text-body-2; - vertical-align: middle; - cursor: pointer; - } - &__logo-link { &, &:hover, &:active, @@ -38,9 +24,17 @@ $block: '.#{variables.$ns}logo'; outline: none; color: inherit; } + &:focus-visible { + outline: solid var(--g-color-line-misc); + outline-offset: -2px; + } } - .g-root &__btn-logo.button2_theme_flat.button2_hovered_yes::before { - background-color: transparent; + &__logo-icon-place { + width: 36px; + + display: flex; + align-items: center; + justify-content: center; } } diff --git a/src/components/Logo/Logo.tsx b/src/components/Logo/Logo.tsx index 30924a8..abc4ab6 100644 --- a/src/components/Logo/Logo.tsx +++ b/src/components/Logo/Logo.tsx @@ -1,6 +1,6 @@ import React from 'react'; -import {Button, Icon} from '@gravity-ui/uikit'; +import {Icon} from '@gravity-ui/uikit'; import {LogoProps} from '../types'; import {block} from '../utils/cn'; @@ -10,12 +10,13 @@ import './Logo.scss'; const b = block('logo'); export const Logo: React.FC< - LogoProps & {compact?: boolean; buttonClassName?: string; buttonWrapperClassName?: string} + LogoProps & {compact?: boolean; buttonClassName?: string; iconPlaceClassName?: string} > = ({ text, icon, iconSrc, iconClassName, + iconPlaceClassName, iconSize = 24, textSize = 15, href, @@ -24,7 +25,6 @@ export const Logo: React.FC< onClick, compact, className, - buttonWrapperClassName, buttonClassName, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, @@ -35,33 +35,14 @@ export const Logo: React.FC< if (iconSrc) { buttonIcon = ( - + logo icon - + ); } else if (icon) { buttonIcon = ; } - const button = ( - - ); - let logo: React.ReactNode; if (typeof text === 'function') { @@ -74,25 +55,24 @@ export const Logo: React.FC< ); } + const button = ( + + {buttonIcon} + {!compact && logo} + + ); + return (
-
- {hasWrapper ? wrapper(button, Boolean(compact)) : button} -
- {!compact && - (hasWrapper ? ( -
{wrapper(logo, Boolean(compact))}
- ) : ( - - {logo} - - ))} + {hasWrapper ? wrapper(button, Boolean(compact)) : button}
); }; diff --git a/src/components/types.ts b/src/components/types.ts index 6a333eb..30c7a79 100644 --- a/src/components/types.ts +++ b/src/components/types.ts @@ -26,7 +26,7 @@ export interface MenuItem extends QAProps { onItemClick?: ( item: MenuItem, collapsed: boolean, - event: React.MouseEvent, + event: React.MouseEvent, ) => void; onItemClickCapture?: (event: React.SyntheticEvent) => void; itemWrapper?: ( diff --git a/styles/mixins.scss b/styles/mixins.scss index e9d06f1..e2c54d8 100644 --- a/styles/mixins.scss +++ b/styles/mixins.scss @@ -9,3 +9,17 @@ background-color: var(--g-color-base-selection-hover); } } + +@mixin accessibility-button() { + background: none; + color: inherit; + border: none; + font: inherit; + outline: inherit; + text-decoration: inherit; + + &:focus-visible { + outline: solid var(--g-color-line-misc); + outline-offset: -2px; + } +}