Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(PanelHeaderButton): add Badge support in label prop #7526

Merged
merged 1 commit into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/vkui/src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface BadgeProps extends RootComponentProps<HTMLSpanElement> {
export const Badge = ({ mode = 'new', children, ...restProps }: BadgeProps): React.ReactNode => (
<RootComponent
Component="span"
baseClassName={classNames(styles['Badge'], stylesMode[mode])}
baseClassName={classNames(styles['Badge'], 'vkuiInternalBadge', stylesMode[mode])}
{...restProps}
>
{children && <VisuallyHidden>{children}</VisuallyHidden>}
Expand Down
12 changes: 0 additions & 12 deletions packages/vkui/src/components/Counter/Counter.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,6 @@
color: var(--vkui_internal--counter_inherit_color, var(--vkui--color_text_contrast_themed));
}

/**
* CMP:
* PanelHeaderButton
*/
/* stylelint-disable-next-line selector-pseudo-class-disallowed-list */
:global(.vkuiInternalPanelHeaderButton) .Counter {
position: absolute;
padding: 0;
inset-block-start: 8px;
inset-inline-end: 2px;
}

/**
* CMP:
* TabbarItem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Icon28AddOutline } from '@vkontakte/icons';
import { Icon24AddOutline, Icon28AddOutline } from '@vkontakte/icons';
import { ComponentPlayground, type ComponentPlaygroundProps } from '@vkui-e2e/playground-helpers';
import { Badge } from '../Badge/Badge';
import { Counter } from '../Counter/Counter';
import { PanelHeaderBack } from '../PanelHeaderBack/PanelHeaderBack';
import { PanelHeaderClose } from '../PanelHeaderClose/PanelHeaderClose';
import { PanelHeaderEdit, type PanelHeaderEditProps } from '../PanelHeaderEdit/PanelHeaderEdit';
Expand All @@ -16,6 +18,15 @@ export const PanelHeaderButtonPlayground = (props: ComponentPlaygroundProps) =>
primary: [true, false],
label: [undefined, 'label', <span key="label">label</span>],
},
{
children: [<Icon28AddOutline key="icon-28" />, <Icon24AddOutline key="icon-24" />],
label: [
<Counter size="s" mode="prominent" key="counter">
33
</Counter>,
<Badge mode="prominent" key="badge" />,
],
},
]}
>
{(props: PanelHeaderButtonProps) => <PanelHeaderButton {...props} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,16 @@
}

/* stylelint-disable-next-line selector-pseudo-class-disallowed-list */
.PanelHeaderButton--vkcom > :not(:global(.vkuiInternalCounter)) {
.PanelHeaderButton--vkcom > :not(:global(.vkuiInternalBadge)):not(:global(.vkuiInternalCounter)) {
transition: opacity 0.3s;
opacity: 0.7;
}

/* stylelint-disable-next-line selector-pseudo-class-disallowed-list */
.PanelHeaderButton--vkcom.PanelHeaderButton--hover > :not(:global(.vkuiInternalCounter)),
.PanelHeaderButton--vkcom.PanelHeaderButton--active > :not(:global(.vkuiInternalCounter)) {
.PanelHeaderButton--vkcom.PanelHeaderButton--hover
> :not(:global(.vkuiInternalCounter)):not(:global(.vkuiInternalBadge)),
.PanelHeaderButton--vkcom.PanelHeaderButton--active
> :not(:global(.vkuiInternalCounter)):not(:global(.vkuiInternalBadge)) {
opacity: 1;
}

Expand Down Expand Up @@ -119,3 +121,42 @@
display: none;
}
}

/*
* CMP:
* Counter
*/

/* stylelint-disable-next-line selector-pseudo-class-disallowed-list */
.PanelHeaderButton :global(.vkuiInternalCounter) {
position: absolute;
padding: 0;
inset-block-start: 4px;
inset-inline-end: 4px;
}

/* stylelint-disable-next-line selector-pseudo-class-disallowed-list */
.PanelHeaderButton :global(.vkuiIcon--24) ~ :global(.vkuiInternalCounter),
.PanelHeaderButton--ios :global(.vkuiInternalCounter) {
inset-block-start: 2px;
inset-inline-end: 2px;
}

/*
* CMP:
* Badge
*/

/* stylelint-disable-next-line selector-pseudo-class-disallowed-list */
.PanelHeaderButton :global(.vkuiInternalBadge) {
position: absolute;
inset-block-start: 8px;
inset-inline-end: 8px;
}

/* stylelint-disable-next-line selector-pseudo-class-disallowed-list */
.PanelHeaderButton :global(.vkuiIcon--24) ~ :global(.vkuiInternalBadge),
.PanelHeaderButton--ios :global(.vkuiInternalBadge) {
inset-block-start: 6px;
inset-inline-end: 6px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const platformClassNames = {

export interface PanelHeaderButtonProps extends Omit<TappableProps, 'label'> {
primary?: boolean;
// TODO [>=7]: добавить св-во `indicator`, чтобы разграничить кейсы
label?: React.ReactNode;
}

Expand Down Expand Up @@ -90,7 +91,6 @@ export const PanelHeaderButton = ({
activeEffectDelay={200}
activeMode={activeMode}
className={classNames(
'vkuiInternalPanelHeaderButton',
styles['PanelHeaderButton'],
platformClassNames.hasOwnProperty(platform)
? platformClassNames[platform]
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