Skip to content

Commit

Permalink
feat!: update to uikit@5, node@18, storybook@7; remove assets
Browse files Browse the repository at this point in the history
  • Loading branch information
d3m1d0v committed Jul 28, 2023
1 parent 1d87e38 commit 0ecd7eb
Show file tree
Hide file tree
Showing 30 changed files with 18,866 additions and 16,563 deletions.
16 changes: 16 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"sourceType": "unambiguous",
"presets": [
[
"@babel/preset-env",
{
"targets": {
"chrome": 100
}
}
],
"@babel/preset-typescript",
"@babel/preset-react"
],
"plugins": []
}
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
node-version: '18.x'
cache: 'npm'
- name: Install Packages
run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 18
- name: Install Packages
run: npm ci
shell: bash
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr-preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: yandex-cloud/ui-preview-build-action@main
with:
node-version: 18
env:
TS_NODE_PROJECT: .storybook/tsconfig.json
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
with:
github-token: ${{ secrets.YC_UI_BOT_GITHUB_TOKEN }}
npm-token: ${{ secrets.YC_UI_BOT_NPM_TOKEN }}
node-version: 14
node-version: 18
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.20
18
59 changes: 0 additions & 59 deletions .storybook/main.js

This file was deleted.

18 changes: 18 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type {StorybookConfig} from '@storybook/react-webpack5';

const config:StorybookConfig = {
framework: {
name: '@storybook/react-webpack5',
options: {fastRefresh: true},
},
stories: ['../demo/**/*.stories.@(js|jsx|ts|tsx)'],
addons: [
'@storybook/preset-scss',
{name: '@storybook/addon-essentials', options: {backgrounds: false}},
],
typescript: {
check: true,
},
};

export default config;
39 changes: 0 additions & 39 deletions .storybook/preview.js

This file was deleted.

42 changes: 42 additions & 0 deletions .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import type {Preview} from '@storybook/react';
import {MINIMAL_VIEWPORTS} from '@storybook/addon-viewport';

import {withThemeProvider, withLang, backgrounds} from '../demo/utils/preview';

const preview: Preview = {
decorators: [withThemeProvider, withLang],
parameters: {
jsx: {showFunctions: true}, // To show functions in sources
viewport: {
viewports: MINIMAL_VIEWPORTS,
},
},
globalTypes: {
theme: {
defaultValue: 'light',
toolbar: {
title: 'Theme',
icon: 'mirror',
items: [
{value: 'light', right: '☼', title: 'Light'},
{value: 'dark', right: '☾', title: 'Dark'},
{value: 'light-hc', right: '☼', title: 'High Contrast Light (beta)'},
{value: 'dark-hc', right: '☾', title: 'High Contrast Dark (beta)'},
],
},
},
lang: {
defaultValue: 'en',
toolbar: {
title: 'Language',
icon: 'globe',
items: [
{value: 'en', right: '🇬🇧', title: 'En'},
{value: 'ru', right: '🇷🇺', title: 'Ru'},
],
},
},
},
};

export default preview;
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ npm install @doc-tools/yfm-editor
Ensure that peer dependencies are installed in your project

```shell
npm install react@17 react-dom@17 @doc-tools/transform@2 @gravity-ui/uikit@4 lodash@4
npm install react@17 react-dom@17 @doc-tools/transform@3 @gravity-ui/uikit@5 @gravity-ui/components@2 lodash@4
```

## Usage
Expand Down
1 change: 0 additions & 1 deletion assets/icons/dots.svg

This file was deleted.

3 changes: 0 additions & 3 deletions assets/icons/ye-chevron.svg

This file was deleted.

2 changes: 1 addition & 1 deletion demo/Playground.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
}

&__markup {
background-color: var(--yc-color-base-generic);
background-color: var(--g-color-base-generic);
}

&__editor-view {
Expand Down
5 changes: 2 additions & 3 deletions demo/Playground.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import block from 'bem-cn-lite';
import {useUpdate} from 'react-use';
import {Button, RadioButton, TextInput} from '@gravity-ui/uikit';
import {Button, RadioButton, TextArea} from '@gravity-ui/uikit';

import {
BaseNode,
Expand Down Expand Up @@ -183,9 +183,8 @@ const Playground = React.memo<PlaygroundProps>((props) => {

<div className={b('preview')}>
{previewType === PreviewType.Markup && (
<TextInput
<TextArea
size="s"
multiline
minRows={10}
value={yfmRaw}
onUpdate={(value) => {
Expand Down
33 changes: 9 additions & 24 deletions demo/utils/preview.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import {Story, StoryContext} from '@storybook/react/types-6-0';
import {configure as configureUikit, useTheme, ThemeProvider, Theme} from '@gravity-ui/uikit';
import type {Decorator} from '@storybook/react';
import {configure as configureUikit, ThemeProvider} from '@gravity-ui/uikit';
import {configure as configureComponents} from '@gravity-ui/components';
import {configure as configureYfmEditor} from '../../src';

import '@gravity-ui/uikit/styles/styles.scss';
Expand All @@ -12,35 +13,19 @@ export const backgrounds = {
values: [light, dark],
};

/* eslint-disable react-hooks/rules-of-hooks */
export function withTheme(StoryItem: Story, context: StoryContext) {
const {value} = context.globals.backgrounds;
const themeValue = value === dark.value ? dark.name : light.name;

const [theme, setTheme] = useTheme();

React.useEffect(() => {
if (theme !== themeValue) {
setTheme((themeValue as Theme) || 'system');
}
}, [theme, themeValue, setTheme]);

return <StoryItem {...context} />;
}
/* eslint-enable react-hooks/rules-of-hooks */

export function withThemeProvider(StoryItem: Story, context: StoryContext) {
export const withThemeProvider: Decorator = (StoryItem, context) => {
return (
<ThemeProvider>
<ThemeProvider theme={context.globals.theme}>
<StoryItem {...context} />
</ThemeProvider>
);
}
};

export function withLang(StoryItem: Story, context: StoryContext) {
export const withLang: Decorator = (StoryItem, context) => {
const lang = context.globals.lang;
configureUikit({lang});
configureComponents({lang});
configureYfmEditor({lang});

return <StoryItem {...context} />;
}
};
Loading

0 comments on commit 0ecd7eb

Please sign in to comment.