Skip to content

Commit

Permalink
BREAKING CHANGE(AppearanceProvider): replace appearance with value (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackySoul authored Nov 28, 2023
1 parent 88fab5f commit b8991d3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/vkui/src/components/AppRoot/AppRootPortal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const AppRootPortal = ({

return shouldUsePortal && portalContainer ? (
createPortal(
<AppearanceProvider appearance={appearance}>
<AppearanceProvider value={appearance}>
<div className={className}>{children}</div>
</AppearanceProvider>,
portalContainer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import { TokensClassProvider } from '../../lib/tokensClassProvider';
import { ConfigProviderOverride } from '../ConfigProvider/ConfigProviderOverride';

export interface AppearanceProviderProps {
appearance: AppearanceType;
value: AppearanceType;
children: React.ReactNode;
}

/**
* @see https://vkcom.github.io/VKUI/#/AppearanceProvider
*/
export const AppearanceProvider = ({ appearance, children }: AppearanceProviderProps) => {
export const AppearanceProvider = ({ value, children }: AppearanceProviderProps) => {
const platform = usePlatform();

return (
<ConfigProviderOverride appearance={appearance}>
<TokensClassProvider platform={platform} appearance={appearance}>
<ConfigProviderOverride appearance={value}>
<TokensClassProvider platform={platform} appearance={value}>
{children}
</TokensClassProvider>
</ConfigProviderOverride>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const TextareaStatePlayground = ({ appearance }: ComponentPlaygroundProps
width: BREAKPOINTS.MOBILE,
}}
>
<AppearanceProvider appearance={appearance}>
<AppearanceProvider value={appearance}>
<AdaptivityProvider sizeY="regular">
<Div style={{ padding: 10 }}>
<Textarea id="textarea" />
Expand Down
2 changes: 1 addition & 1 deletion styleguide/Components/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Preview extends PreviewParent {
return (
<Profiler id={exampleId} onRender={logPerf}>
<PlatformProvider value={styleGuideContext.platform}>
<AppearanceProvider appearance={styleGuideContext.appearance}>
<AppearanceProvider value={styleGuideContext.appearance}>
<div
className={classNames(
'Preview',
Expand Down
6 changes: 6 additions & 0 deletions styleguide/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,12 @@ const baseConfig = {
name: 'Migration',
content: './pages/migration_v5.md',
},

{
title: 'Миграция с v5 на v6',
name: 'Migrations',
content: './pages/migration_v6.md',
},
{
name: 'Unstable',
content: './pages/unstable.md',
Expand Down
9 changes: 9 additions & 0 deletions styleguide/pages/migration_v6.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@
- `webviewType={WebviewType.INTERNAL}` -> `hasCustomPanelHeaderAfter={false}`.
- `webviewType={WebviewType.VKAPPS}` -> `hasCustomPanelHeaderAfter={true}`. При необходимости передайте `customPanelHeaderAfterMinWidth={<value>}` (по умолчанию `90`).

## [AppearanceProvider](#/AppearanceProvider)

По аналогии с остальными провайдерами свойство `appearance` заменено на `value`

```diff
- <AppearanceProvider appearance={appearance}>...</AppearanceProvider>
+ <AppearanceProvider value={appearance}>...</AppearanceProvider>
```

## ~`withInsets`~

Используйте вместо него хук `useInsets()` из [@vkontakte/vk-bridge-react](https://www.npmjs.com/package/@vkontakte/vk-bridge-react).
Expand Down
4 changes: 2 additions & 2 deletions styleguide/pages/platforms_and_themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
Если вам необходимо переопределить тему для отдельных компонентов приложения, то это можно сделать через `AppearanceProvider`.

```jsx static
<AppearanceProvider appearance="dark">
<AppearanceProvider value="dark">
<Snackbar action="Поделиться">Поделиться</Snackbar>
</AppearanceProvider>
```
Expand All @@ -85,4 +85,4 @@ const appearance = useAppearance();
<Div>{appearance === 'light' ? 'Out of the blue' : 'And into the black'}</Div>;
```

Appearance можно пригодиться для замены изображений на инвертированную версию в темных темах.
`Appearance` может пригодиться для замены изображений на инвертированную версию в темных темах.

0 comments on commit b8991d3

Please sign in to comment.