From f2226d96555ac4a42053693301d83c0b145e5bba Mon Sep 17 00:00:00 2001 From: Angelina Gadzhieva Date: Fri, 8 Dec 2023 13:00:38 +0300 Subject: [PATCH] feat(AsideHeader): add custom background (#163) * feat(AsideHeader): add custom background * chore: fix header decoration addon --- src/components/AsideHeader/AsideHeader.scss | 11 ++++++++++ src/components/AsideHeader/README.md | 8 +++++--- .../__stories__/AsideHeader.stories.tsx | 10 ++++++++++ .../__stories__/AsideHeaderShowcase.scss | 6 ++++++ .../__stories__/AsideHeaderShowcase.tsx | 20 ++++++++++++++++--- .../AsideHeader/components/FirstPanel.tsx | 8 ++++++++ src/components/AsideHeader/types.tsx | 2 ++ src/components/CompositeBar/Item/Item.scss | 2 +- 8 files changed, 60 insertions(+), 7 deletions(-) diff --git a/src/components/AsideHeader/AsideHeader.scss b/src/components/AsideHeader/AsideHeader.scss index fc932b5..9e14cb3 100644 --- a/src/components/AsideHeader/AsideHeader.scss +++ b/src/components/AsideHeader/AsideHeader.scss @@ -7,6 +7,7 @@ $block: '.#{variables.$ns}aside-header'; --gn-aside-header-collapse-button-divider-line-color: var( --gn-aside-header-subheader-divider-line-color ); + --gn-aside-header-menu-item-icon-color: var(--g-color-text-misc); --gn-aside-header-footer-item-icon-color: var(--g-color-text-primary); --gn-aside-header-subheader-item-icon-color: var(--g-color-text-primary); --gn-aside-header-item-icon-background-size: 38px; @@ -94,6 +95,16 @@ $block: '.#{variables.$ns}aside-header'; transparent calc(var(--gradient-height) * 0.88) ); } + + &-custom-background { + position: absolute; + top: 0; + bottom: 0; + + display: flex; + + z-index: -1; + } } &_compact &__aside { diff --git a/src/components/AsideHeader/README.md b/src/components/AsideHeader/README.md index 7fc330a..2f549ab 100644 --- a/src/components/AsideHeader/README.md +++ b/src/components/AsideHeader/README.md @@ -12,6 +12,8 @@ import {AsideHeader} from '@gravity-ui/navigation'; ## Properties -| Name | Description | Type | Default | -| :--- | :--------------------------- | :----------------------------------------------------: | :-----: | -| ref | `ref` to target popup anchor | `React.ForwardedRef` | | +| Name | Description | Type | Default | +| :------------------------ | :--------------------------------------------- | :----------------------------------------------------: | :-----: | --- | +| ref | `ref` to target popup anchor | `React.ForwardedRef` | | +| customBackground | `AsideHeader`` background | `React.ReactNode` | | | +| customBackgroundClassName | Override default background container's styles | `string` | | diff --git a/src/components/AsideHeader/__stories__/AsideHeader.stories.tsx b/src/components/AsideHeader/__stories__/AsideHeader.stories.tsx index e3f61c3..fa11080 100644 --- a/src/components/AsideHeader/__stories__/AsideHeader.stories.tsx +++ b/src/components/AsideHeader/__stories__/AsideHeader.stories.tsx @@ -32,6 +32,16 @@ MultipleTooltip.args = { initialCompact: true, }; +const CustomThemeTemplate: StoryFn = (args) => ; +export const CustomTheme = CustomThemeTemplate.bind({}); +CustomTheme.args = { + headerDecoration: false, + customBackground: ( + + ), + customBackgroundClassName: 'aside-header-showcase__custom-background', +}; + const AdvancedUsageTemplate: StoryFn = (args) => { const [compact, setCompact] = React.useState(args.initialCompact); diff --git a/src/components/AsideHeader/__stories__/AsideHeaderShowcase.scss b/src/components/AsideHeader/__stories__/AsideHeaderShowcase.scss index 3f10888..4e6127a 100644 --- a/src/components/AsideHeader/__stories__/AsideHeaderShowcase.scss +++ b/src/components/AsideHeader/__stories__/AsideHeaderShowcase.scss @@ -83,6 +83,12 @@ body { height: calc(100% - 40px); padding: 20px; } + + &__custom-background { + --gn-aside-header-menu-item-icon-color: var(--g-color-text-primary); + + opacity: 75%; + } } .composite-bar-showcase__tag { diff --git a/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx b/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx index cd89e50..a4b298a 100644 --- a/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx +++ b/src/components/AsideHeader/__stories__/AsideHeaderShowcase.tsx @@ -39,19 +39,27 @@ interface AsideHeaderShowcaseProps { multipleTooltip?: boolean; initialCompact?: boolean; topAlert?: AsideHeaderTopAlertProps; + customBackground?: React.ReactNode; + customBackgroundClassName?: string; + headerDecoration?: boolean; } export const AsideHeaderShowcase: React.FC = ({ multipleTooltip = false, initialCompact = false, topAlert, + customBackground, + customBackgroundClassName, + headerDecoration, }) => { const ref = React.useRef(null); const [popupVisible, setPopupVisible] = React.useState(false); const [subheaderPopupVisible, setSubheaderPopupVisible] = React.useState(false); const [visiblePanel, setVisiblePanel] = React.useState(); const [compact, setCompact] = React.useState(initialCompact); - const [headerDecoration, setHeaderDecoration] = React.useState(BOOLEAN_OPTIONS.Yes); + const [addonHeaderDecoration, setHeaderDecoration] = React.useState( + BOOLEAN_OPTIONS.Yes, + ); const [isModalOpen, setIsModalOpen] = React.useState(false); const openModalSubscriber = (callback: OpenModalSubscriber) => { @@ -92,9 +100,15 @@ export const AsideHeaderShowcase: React.FC = ({ href: '#', onClick: () => alert('click on logo'), }} - headerDecoration={headerDecoration === BOOLEAN_OPTIONS.Yes} + headerDecoration={ + headerDecoration === undefined + ? addonHeaderDecoration === BOOLEAN_OPTIONS.Yes + : headerDecoration + } onMenuItemsChanged={setMenuItems} menuItems={menuItems} + customBackground={customBackground} + customBackgroundClassName={customBackgroundClassName} subheaderItems={[ { item: { @@ -231,7 +245,7 @@ export const AsideHeaderShowcase: React.FC = ({
{placeholderText}
{ setHeaderDecoration(event.target.value); }} diff --git a/src/components/AsideHeader/components/FirstPanel.tsx b/src/components/AsideHeader/components/FirstPanel.tsx index dd5929c..059c466 100644 --- a/src/components/AsideHeader/components/FirstPanel.tsx +++ b/src/components/AsideHeader/components/FirstPanel.tsx @@ -20,6 +20,8 @@ export const FirstPanel = React.forwardRef((_props, ref) => { menuMoreTitle, renderFooter, compact, + customBackground, + customBackgroundClassName, } = useAsideHeaderInnerContext(); const visibleMenuItems = useVisibleMenuItems(); @@ -33,7 +35,13 @@ export const FirstPanel = React.forwardRef((_props, ref) => { <>
+
+ {customBackground && ( +
+ {customBackground} +
+ )}
{visibleMenuItems?.length ? (