Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add dir and writing mode #6703

Merged
merged 1 commit into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/vkui/.storybook/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,27 @@ const preview: Preview = {
description: 'Hide "after" prop of PanelHeader for custom floating "after" element',
defaultValue: false,
},
direction: {
name: 'Direction',
description: "Attribute indicating the directionality of the element's text",
defaultValue: 'ltr',
toolbar: {
items: [
{ value: 'ltr', icon: 'menu', title: 'ltr' },
{ value: 'rtl', icon: 'menualt', title: 'rtl' },
],
},
},
writingMode: {
name: 'Writing mode',
description:
'Sets whether lines of text are laid out horizontally or vertically, as well as the direction in which blocks progress',
defaultValue: 'horizontal-tb',
toolbar: {
icon: 'redirect',
items: ['horizontal-tb', 'vertical-rl', 'vertical-lr'],
},
},
},
argTypes: {
getRef: { control: false },
Expand Down
3 changes: 2 additions & 1 deletion packages/vkui/scripts/postcss.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function makePostcssPlugins({
isProduction = process.env.NODE_ENV === 'production',
isCssModulesFile = false,
isESNext = false,
isStorybook = process.env.SANDBOX === '.storybook',
} = {}) {
const plugins = [
// Обработка css импортов
Expand Down Expand Up @@ -55,7 +56,7 @@ function makePostcssPlugins({
// Обработка CSS Logical
//
// https://caniuse.com/css-logical-props
if (!isESNext) {
if (!isESNext && !isStorybook) {
plugins.push(postcssLogical());
}

Expand Down
1 change: 1 addition & 0 deletions packages/vkui/src/components/AppRoot/AppRoot.module.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.AppRoot {
block-size: 100%;
inline-size: 100%;
}

.AppRoot--pointer-has-not {
Expand Down
16 changes: 14 additions & 2 deletions packages/vkui/src/storybook/VKUIDecorators.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ const CenteredStyle: React.CSSProperties = {
const channel = addons.getChannel();

export const withVKUIWrapper: Decorator = (Component, context) => {
const { platform, appearance, hasPointer = false, hasCustomPanelHeaderAfter } = context.globals;
const {
platform,
appearance,
hasPointer = false,
hasCustomPanelHeaderAfter,
direction,
writingMode,
} = context.globals;

// eslint-disable-next-line no-restricted-properties, react-hooks/rules-of-hooks
React.useLayoutEffect(() => {
Expand All @@ -38,14 +45,19 @@ export const withVKUIWrapper: Decorator = (Component, context) => {

const { centered } = context.parameters;

const style: React.CSSProperties = {
writingMode,
...(centered ? CenteredStyle : {}),
};

return (
<ConfigProvider
platform={platform}
appearance={appearance}
hasCustomPanelHeaderAfter={hasCustomPanelHeaderAfter}
>
<AdaptivityProvider hasPointer={hasPointer}>
<AppRoot style={centered ? CenteredStyle : undefined}>
<AppRoot style={style} dir={direction}>
<Component />
</AppRoot>
</AdaptivityProvider>
Expand Down
Loading