Skip to content

Commit

Permalink
feat: remove feature flags (#3434)
Browse files Browse the repository at this point in the history
  • Loading branch information
HelenaIsh committed Jun 18, 2024
1 parent 5d19e6e commit 26676a3
Show file tree
Hide file tree
Showing 463 changed files with 1,091 additions and 2,626 deletions.
1 change: 0 additions & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ function foo() {}

Примеры:
- validationsRemoveExtraSpans - Избавиться от обертки span в ValidationContainer, ValidationWrapper и ValidationText
- tokenInputRemoveWhitespaceFromDefaultDelimiters - В TokenInput изменили разделитель по умолчанию

2) Добавьте флаг в ReactUIFeatureFlags в файл ReactUIFeatureFlagsContext.tsx и в документацию FEATUREFLAGSCONTEXT.md

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.

This file was deleted.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion packages/react-ui-validations/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const config: StorybookConfig = {
framework: {
name: '@storybook/react-webpack5',
options: {
fastRefresh: true,
strictMode: true,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
## Доступные флаги

export interface ValidationsFeatureFlags {
validationsRemoveExtraSpans?: boolean;
fixedValidationTextColors?: boolean;
darkTheme?: boolean;
}

Expand All @@ -14,30 +12,11 @@

import { ValidationsFeatureFlagsContext } from '@skbkontur/react-ui-validations'

<ValidationsFeatureFlagsContext.Provider value={{ validationsRemoveExtraSpans: true }}>{/* ... */}</ValidationsFeatureFlagsContext.Provider>;
<ValidationsFeatureFlagsContext.Provider value={{ darkTheme: true }}>{/* ... */}</ValidationsFeatureFlagsContext.Provider>;

## Использование

### validationsRemoveExtraSpans

В ValidationContainer, ValidationWrapper и ValidationText из корня удалён лишний span.
В Validations 2.0 фича будет применена по умолчанию.

!!DemoWithCode!!FeatureFlagsExamplevalidationsRemoveExtraSpans


### fixedValidationTextColors

В ValidationText будут использоваться цвета по гайдам для error и warning.

Для кастомизации цветов используйте переменные темы `validationsTextColorWarning` и
`validationsTextColorError`.

В Validations 2.0 фича будет применена по умолчанию.

!!DemoWithCode!!FeatureFlagsExampleFixedValidationTextColors

### darkTheme*
### darkTheme

Работает только в паре с **fixedValidationTextColors: true** и если нет переменных темы `validationsTextColorWarning` и
`validationsTextColorError`.
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

12 changes: 6 additions & 6 deletions packages/react-ui-validations/docs/Pages/Displaying/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ValidationType from './ValidationType/ValidationType.md';
import ErrorMessages from './ErrorMessages/ErrorMessages.md';
import FormValidity from './FormValidity/FormValidity.md';
import ScrollToValidation from './ScrollToValidation/ScrollToValidation.md';
import FeatureFlagsContext from './FeatureFlags/FeatureFlagsContext.md';
// import FeatureFlagsContext from './FeatureFlags/FeatureFlagsContext.md'; // TODO включить когда появятся фиче-флаги

export const Displaying = {
caption: 'Отображение',
Expand Down Expand Up @@ -39,10 +39,10 @@ export const Displaying = {
url: 'scroll-to-validation',
caption: 'Скролл к валидации',
},
{
component: FeatureFlagsContext,
url: 'feature-flags',
caption: 'Фича-флаги',
},
// {
// component: FeatureFlagsContext,
// url: 'feature-flags',
// caption: 'Фича-флаги',
// },
],
};
26 changes: 2 additions & 24 deletions packages/react-ui-validations/src/ValidationContextWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import React from 'react';

import {
ValidationsFeatureFlags,
ValidationsFeatureFlagsContext,
getFullValidationsFlagsContext,
} from './utils/featureFlagsContext';
import { ValidationWrapperInternal } from './ValidationWrapperInternal';
import type { ScrollOffset, ValidateArgumentType } from './ValidationContainer';
import { isNullable } from './utils/isNullable';
Expand Down Expand Up @@ -162,13 +157,7 @@ export class ValidationContextWrapper extends React.Component<ValidationContextW
return FocusMode.None;
}

private featureFlags!: ValidationsFeatureFlags;

private children = (flags: ValidationsFeatureFlags) => {
if (flags.validationsRemoveExtraSpans) {
return this.props.children;
}

private children = () => {
return <span>{this.props.children}</span>;
};

Expand All @@ -183,17 +172,6 @@ export class ValidationContextWrapper extends React.Component<ValidationContextW
};

public render() {
return (
<ValidationsFeatureFlagsContext.Consumer>
{(flags) => {
this.featureFlags = getFullValidationsFlagsContext(flags);
return (
<ValidationContext.Provider value={this}>
{this.renderChildren(this.children(this.featureFlags))}
</ValidationContext.Provider>
);
}}
</ValidationsFeatureFlagsContext.Consumer>
);
return <ValidationContext.Provider value={this}>{this.renderChildren(this.children())}</ValidationContext.Provider>;
}
}
17 changes: 3 additions & 14 deletions packages/react-ui-validations/src/ValidationText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React, { useContext } from 'react';
import { Nullable } from '../typings/Types';
import { ThemeValidations } from '../typings/theme-context';

import { getFullValidationsFlagsContext, ValidationsFeatureFlagsContext } from './utils/featureFlagsContext';
import { TextPosition, Validation } from './ValidationWrapperInternal';
import { getValidationTextColor } from './utils/getValidationTextColor';
import { ThemeContext } from './ReactUiDetection';
Expand All @@ -17,8 +16,7 @@ export interface ValidationTextProps {

export const ValidationText = ({ pos, children, validation, 'data-tid': dataTid }: ValidationTextProps) => {
const theme = useContext<ThemeValidations>(ThemeContext);
const featureFlags = getFullValidationsFlagsContext(useContext(ValidationsFeatureFlagsContext));
const color = getValidationTextColor(featureFlags, theme, validation?.level);
const color = getValidationTextColor(theme, validation?.level);

if (pos === 'right') {
const childrenAndValidationText = (
Expand All @@ -30,11 +28,7 @@ export const ValidationText = ({ pos, children, validation, 'data-tid': dataTid
</>
);

return featureFlags.validationsRemoveExtraSpans ? (
childrenAndValidationText
) : (
<span style={{ display: 'inline-block' }}>{childrenAndValidationText}</span>
);
return <span style={{ display: 'inline-block' }}>{childrenAndValidationText}</span>;
}

const validationText = (
Expand All @@ -54,12 +48,7 @@ export const ValidationText = ({ pos, children, validation, 'data-tid': dataTid
</span>
);

return featureFlags.validationsRemoveExtraSpans ? (
<>
{children}
<span style={{ position: 'absolute', display: 'block' }}>{validationText}</span>
</>
) : (
return (
<span style={{ position: 'relative', display: 'inline-block' }}>
{children}
<span style={{ position: 'absolute', bottom: 0, left: 0, height: 0 }}>{validationText}</span>
Expand Down
Loading

0 comments on commit 26676a3

Please sign in to comment.