Skip to content

Commit

Permalink
feat!: next version (#181)
Browse files Browse the repository at this point in the history
* feat: use i18n instance from uikit (#179)

* feat: reafctor transformPost interface (#180)

* feat: update storybook (#182)

* feat: remove metrika goals (#177)

---------

Co-authored-by: Nik Tverd <[email protected]>
  • Loading branch information
NikitaCG and niktverd authored Mar 6, 2024
1 parent e739f1c commit 2a1e33a
Show file tree
Hide file tree
Showing 61 changed files with 4,980 additions and 3,252 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ node_modules
/build
/storybook-static
/server
/configure
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ node_modules
/build
/storybook-static
/server
/configure

*.tgz
.env
Expand Down
1 change: 0 additions & 1 deletion .mocks/forms.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"yandex": {
"theme": "default",
"id": "61a4e639d4d24e0dbba36f5c",
"metrikaGoals": ["events_form_submit"],
"customFormSection": "cloud"
}
}
Expand Down
1 change: 0 additions & 1 deletion .mocks/page.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@
"yandex": {
"theme": "default",
"id": "61a4e639d4d24e0dbba36f5c",
"metrikaGoals": ["events_form_submit"],
"customFormSection": "cloud"
}
}
Expand Down
1 change: 0 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
# Build
build/
server/
configure/
storybook-static/
/styles/*.css

Expand Down
14 changes: 9 additions & 5 deletions .storybook/addons/addon-yaml/register.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React, {useMemo} from 'react';
import {ClipboardButton, ThemeProvider} from '@gravity-ui/uikit';
import {addons, types} from '@storybook/addons';
import {AddonPanel} from '@storybook/components';
import {useGlobals} from '@storybook/manager-api';
import {useArgs} from '@storybook/api';
import yaml from 'js-yaml';
import {ClipboardButton} from '@gravity-ui/uikit';

import './AddonYaml.css';

Expand All @@ -12,6 +13,7 @@ const PANEL_ID = `${ADDON_ID}/panel`;

const YamlPanel = () => {
const [params] = useArgs();
const [globals] = useGlobals();

const content = useMemo(
() =>
Expand All @@ -25,10 +27,12 @@ const YamlPanel = () => {
);

return (
<div className="addon-yaml">
<ClipboardButton text={content} />
<pre>{content}</pre>
</div>
<ThemeProvider theme={globals.theme}>
<div className="addon-yaml">
<ClipboardButton text={content} />
<pre>{content}</pre>
</div>
</ThemeProvider>
);
};

Expand Down
2 changes: 1 addition & 1 deletion .storybook/addons/theme-addon/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {API} from '@storybook/api';

import {themes} from '../../theme';

const ADDON_ID = 'yc-theme-addon';
const ADDON_ID = 'g-theme-addon';
const TOOL_ID = `${ADDON_ID}tool`;

addons.register(ADDON_ID, (api) => {
Expand Down
2 changes: 1 addition & 1 deletion .storybook/decorators/DocsDecorator/DocsDecorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type {DocsContainerProps} from '@storybook/addon-docs';

import {themes} from '../../../.storybook/theme';
import {MobileContext} from '../../../src/contexts/MobileContext';
import {ThemeProvider} from '../../../src/contexts/theme';
import {cn} from '../../../src/utils/cn';
import {ThemeProvider} from '@gravity-ui/uikit';

import './DocsDecorator.scss';

Expand Down
4 changes: 1 addition & 3 deletions .storybook/decorators/withLang.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react';
import {StoryFn, StoryContext} from '@storybook/react';

import {Lang} from '../../src/models/locale';

import {configure} from '../../src/configure';
import {Lang, configure} from '@gravity-ui/uikit';

configure({lang: Lang.En});

Expand Down
17 changes: 8 additions & 9 deletions .storybook/decorators/withMobile.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React from 'react';

import {MobileProvider} from '@gravity-ui/uikit';
import {StoryFn, StoryContext} from '@storybook/react';
import {useMobile} from '@gravity-ui/uikit';

export function withMobile(Story: StoryFn, context: StoryContext) {
const mobileValue = context.globals.platform === 'mobile';

const [mobile, setMobile] = useMobile(); // eslint-disable-line react-hooks/rules-of-hooks

if (mobile !== mobileValue) {
setMobile(mobileValue);
}
const platform = context.globals.platform;

return <Story {...context} />;
return (
<MobileProvider mobile={platform === 'mobile'} platform={platform}>
<Story {...context} />
</MobileProvider>
);
}
3 changes: 2 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ const config: StorybookConfig = {
},
addons: [
'@storybook/preset-scss',
{name: '@storybook/addon-essentials', options: {backgrounds: false}},
{name: '@storybook/addon-essentials', options: {backgrounds: false, actions: false}},
'./addons/addon-yaml/preset',
'./addons/theme-addon/register.tsx',
'@storybook/addon-mdx-gfm',
],
};

Expand Down
5 changes: 2 additions & 3 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../styles/styles.scss';
import '../styles/storybook/index.scss';
import '@gravity-ui/uikit/styles/styles.scss';
import '../styles/styles.scss';
import '../styles/root.scss';

import React from 'react';
Expand All @@ -11,8 +11,7 @@ import {withTheme} from './decorators/withTheme';
import {withLang} from './decorators/withLang';
import {withMobile} from './decorators/withMobile';
import {DocsDecorator} from './decorators/DocsDecorator/DocsDecorator';
import {MobileProvider, Platform} from '@gravity-ui/uikit';
import {ThemeProvider} from '../src/contexts/theme/ThemeProvider';
import {MobileProvider, ThemeProvider} from '@gravity-ui/uikit';

const withContextProvider: Decorator = (Story, context) => (
<React.StrictMode>
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ import {
} from '@gravity-ui/blog-constructor/server';
```

## i18n

To make sure the i18n library used in your project runs properly, perform its initialization and set the project's current locale value in `lang`. For example:
The `blog-constructor` is a `uikit-based` library, and we use an instance of `i18n` from uikit. To set up internationalization, you just need to use the `configure` from uikit:

```typescript
import {configure, Lang} from '@gravity-ui/blog-constructor';
import {configure} from '@gravity-ui/uikit';

configure({lang: Lang.En});
configure({
lang: 'ru',
});
```

## Development
Expand Down
Loading

0 comments on commit 2a1e33a

Please sign in to comment.