Skip to content

Commit

Permalink
feat(Paragraph): Add compact mode (#7565)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey-medvedev-vk authored Sep 11, 2024
1 parent 8b63d63 commit fb6f6df
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const ParagraphPlayground = (props: ComponentPlaygroundProps) => {
{...props}
propSets={[
{
weight: ['3', '2', '1'],
weight: [undefined, '3', '2', '1'],
},
{
normalize: [true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,43 @@
font-weight: var(--vkui--font_paragraph--font_weight--regular);
font-family: var(--vkui--font_paragraph--font_family--regular);
}

.Paragraph--sizeY-compact {
font-size: var(
--vkui--font_paragraph--font_size--compact,
var(--vkui--font_paragraph--font_size--regular)
);
line-height: var(
--vkui--font_paragraph--line_height--compact,
var(--vkui--font_paragraph--line_height--regular)
);
font-weight: var(
--vkui--font_paragraph--font_weight--compact,
var(--vkui--font_paragraph--font_weight--regular)
);
font-family: var(
--vkui--font_paragraph--font_family--compact,
var(--vkui--font_paragraph--font_family--regular)
);
}

@media (--sizeY-compact) {
.Paragraph--sizeY-none {
font-size: var(
--vkui--font_paragraph--font_size--compact,
var(--vkui--font_paragraph--font_size--regular)
);
line-height: var(
--vkui--font_paragraph--line_height--compact,
var(--vkui--font_paragraph--line_height--regular)
);
font-weight: var(
--vkui--font_paragraph--font_weight--compact,
var(--vkui--font_paragraph--font_weight--regular)
);
font-family: var(
--vkui--font_paragraph--font_family--compact,
var(--vkui--font_paragraph--font_family--regular)
);
}
}
14 changes: 13 additions & 1 deletion packages/vkui/src/components/Typography/Paragraph/Paragraph.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { classNames } from '@vkontakte/vkjs';
import { useAdaptivity } from '../../../hooks/useAdaptivity';
import { Typography, type TypographyProps } from '../Typography';
import styles from './Paragraph.module.css';

const sizeYClassNames = {
none: styles['Paragraph--sizeY-none'],
compact: styles['Paragraph--sizeY-compact'],
};

export type ParagraphProps = TypographyProps;

/**
Expand All @@ -16,12 +22,18 @@ export const Paragraph = ({
inline = false,
...restProps
}: ParagraphProps): React.ReactNode => {
const { sizeY = 'none' } = useAdaptivity();

return (
<Typography
Component={Component}
normalize={normalize}
inline={inline}
className={classNames(className, styles['Paragraph'])}
className={classNames(
className,
styles['Paragraph'],
sizeY !== 'regular' && sizeYClassNames[sizeY],
)}
{...restProps}
/>
);
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.

0 comments on commit fb6f6df

Please sign in to comment.