Skip to content

Commit

Permalink
feat: get rid of view=component for text
Browse files Browse the repository at this point in the history
  • Loading branch information
fulcanellee committed Feb 11, 2025
1 parent 165b14b commit 29f49f9
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 38 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-ties-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@alfalab/core-components-typography': major
---

Удален тип пропса `view` - `component`. Используйте `component-primary`
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ Object {
class="container"
>
<span
class="title primary component"
class="title primary component-primary"
>
title
</span>
Expand Down Expand Up @@ -210,7 +210,7 @@ Object {
class="container"
>
<span
class="title primary component"
class="title primary component-primary"
>
title
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const Content = () => {
[styles.truncate]: truncate,
[styles.restore]: showRestore,
})}
view='component'
view='component-primary'
color='primary'
>
{title}
Expand Down
2 changes: 1 addition & 1 deletion packages/gallery/src/components/info-bar/Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const InfoBar = () => {
<Text
className={styles.description}
tag='div'
view='component'
view='component-primary'
color='static-primary-light'
>
{image?.name}
Expand Down
2 changes: 1 addition & 1 deletion packages/modal/src/__snapshots__/Component.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ exports[`ModalMobile snapshots tests should match snapshot 1`] = `
</svg>
</div>
<span
class="text component medium"
class="text component-primary medium"
style="opacity: 1;"
>
Назад
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const BackArrowAddon: React.FC<BackArrowAddonProps> = ({
{textOpacity > 0 && text && (
<Text
className={styles.text}
view={view === 'desktop' ? 'primary-large' : 'component'}
view={view === 'desktop' ? 'primary-large' : 'component-primary'}
weight='medium'
style={{ opacity: textOpacity }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const ActionTextAddon: React.FC<ActionTextAddonProps> = ({
>
<Text
className={styles.text}
view='component'
view='component-primary'
weight={action === 'primary' ? 'medium' : 'regular'}
>
{text}
Expand Down
4 changes: 2 additions & 2 deletions packages/pure-cell/src/components/amount/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Props = {
/**
* Размер денежного значения
*/
textView?: 'component' | 'primary-small';
textView?: 'component-primary' | 'primary-small';

/**
* Цвет денежного значения
Expand All @@ -40,7 +40,7 @@ type Props = {

export const Amount: React.FC<Props> = ({
weight = 'normal',
textView = 'component',
textView = 'component-primary',
color = 'primary',
minority,
minorUnits = 100,
Expand Down
1 change: 0 additions & 1 deletion packages/pure-cell/src/components/text/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type Props = {
| 'primary-large'
| 'primary-medium'
| 'primary-small'
| 'component'
| 'component-primary'
| 'secondary-large';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ exports[`SidePanelMobile snapshots tests should match snapshot 1`] = `
</svg>
</div>
<span
class="text component medium"
class="text component-primary medium"
style="opacity: 1;"
>
Назад
Expand Down
1 change: 0 additions & 1 deletion packages/typography/src/text/component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe('Text', () => {
'secondary-large',
'secondary-medium',
'secondary-small',
'component',
'caps',
'tagline',
];
Expand Down
22 changes: 0 additions & 22 deletions packages/typography/src/text/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type TextBaseProps = {
| 'secondary-large'
| 'secondary-medium'
| 'secondary-small'
| 'component'
| 'component-primary'
| 'component-secondary'
| 'caps'
Expand Down Expand Up @@ -91,23 +90,6 @@ type TextPTagProps = Omit<TextBaseProps, 'tag' | 'defaultMargins'> & {

export type TextProps = Omit<NativeProps, 'color'> & (TextBaseProps | TextPTagProps);

const logWarning = (view: Required<TextBaseProps>['view']) => {
if (process.env.NODE_ENV !== 'development') {
return;
}

const viewsMap: { [key: string]: string } = {
component: 'component-primary',
};

// eslint-disable-next-line no-console
console.warn(
// eslint-disable-next-line prefer-template
`@alfalab/core-components/typography: view='${view}' будет удален в следующих мажорных версиях. ` +
`Используйте view='${viewsMap[view]}'.`,
);
};

export const Text = forwardRef<TextElementType, TextProps>(
(
{
Expand All @@ -127,10 +109,6 @@ export const Text = forwardRef<TextElementType, TextProps>(
},
ref,
) => {
if (view === 'component') {
logWarning(view);
}

const { renderSkeleton, textRef } = useSkeleton(showSkeleton, skeletonProps);

const skeleton = renderSkeleton({
Expand Down
4 changes: 0 additions & 4 deletions packages/typography/src/text/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
@mixin paragraph_secondary_small;
}

.component {
@mixin paragraph_component;
}

.component-primary {
@mixin paragraph_component_primary;
}
Expand Down

0 comments on commit 29f49f9

Please sign in to comment.