Skip to content

Commit

Permalink
feat(Card): Add outline-tint mode
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackySoul committed Jul 27, 2023
1 parent 29c5b59 commit 47b5a60
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 23 deletions.
2 changes: 1 addition & 1 deletion packages/vkui/src/components/Card/Card.e2e-playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const CardPlayground = (props: ComponentPlaygroundProps) => {
{...props}
propSets={[
{
mode: ['tint', 'shadow', 'outline'],
mode: ['tint', 'shadow', 'outline', 'outline-tint'],
},
]}
>
Expand Down
2 changes: 1 addition & 1 deletion packages/vkui/src/components/Card/Card.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
background: var(--vkui--color_background_modal);
}

.Card--mode-outline::after {
.Card--withBorder::after {
position: absolute;
left: 0;
top: 0;
Expand Down
4 changes: 3 additions & 1 deletion packages/vkui/src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styles from './Card.module.css';
export interface CardProps
extends React.HTMLAttributes<HTMLDivElement>,
HasRootRef<HTMLDivElement> {
mode?: 'tint' | 'shadow' | 'outline';
mode?: 'tint' | 'shadow' | 'outline' | 'outline-tint';
}

/**
Expand All @@ -19,6 +19,7 @@ export const Card = ({
className,
...restProps
}: CardProps) => {
const withBorder = mode === 'outline' || mode === 'outline-tint';
return (
<div
{...restProps}
Expand All @@ -27,6 +28,7 @@ export const Card = ({
styles['Card'],
mode === 'outline' && styles['Card--mode-outline'],
mode === 'shadow' && styles['Card--mode-shadow'],
withBorder && styles['Card--withBorder'],
className,
)}
>
Expand Down
10 changes: 10 additions & 0 deletions packages/vkui/src/components/Card/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
</Card>
</CardGrid>
</Group>
<Group
mode="plain"
header={<Header mode="secondary">С внутренней обводкой и дефолтным фоном</Header>}
>
<CardGrid size="l">
<Card mode="outline-tint">
<div style={{ height: 96 }} />
</Card>
</CardGrid>
</Group>
</Group>
</Panel>
</View>
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.
4 changes: 4 additions & 0 deletions packages/vkui/src/components/Tappable/Tappable.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ https://github.com/VKCOM/VKUI/pull/3641
}
}

.Tappable.Tappable--borderRadiusInherit {
border-radius: inherit;
}

/**
* Animations
*/
Expand Down
7 changes: 7 additions & 0 deletions packages/vkui/src/components/Tappable/Tappable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export interface TappableProps
focusVisibleMode?: LiteralUnion<FocusVisibleMode, string>;
onEnter?(outputEvent: MouseEvent): void;
onLeave?(outputEvent: MouseEvent): void;
/**
* Задает border-radius элементу
* В режиме `auto` на маленьких экранах `border-radius: 0`, иначе определяется токеном `--vkui--size_border_radius--regular`
*/
borderRadiusMode?: 'auto' | 'inherit';
}

interface Wave {
Expand Down Expand Up @@ -195,6 +200,7 @@ export const Tappable = ({
onLeave,
className,
hovered: hoveredProp,
borderRadiusMode = 'auto',
...props
}: TappableProps) => {
Component = Component || ((props.href ? 'a' : 'div') as React.ElementType);
Expand Down Expand Up @@ -330,6 +336,7 @@ export const Tappable = ({
opacity: styles['Tappable--active-opacity'],
}[activeMode],
focusVisible && styles['Tappable--focus-visible'],
borderRadiusMode === 'inherit' && styles['Tappable--borderRadiusInherit'],
);

const handlers: RootComponentProps = {
Expand Down

0 comments on commit 47b5a60

Please sign in to comment.