Skip to content

Commit ade5a78

Browse files
committed
feat: implement initial components
1 parent 09651cb commit ade5a78

24 files changed

+16195
-2052
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React from 'react';
2+
import {Story as StoryType, StoryContext} from '@storybook/react';
3+
import {useTheme} from '@yandex-cloud/uikit';
4+
5+
export function withTheme(Story: StoryType, context: StoryContext) {
6+
const themeValue = context.globals.theme;
7+
const [theme, setTheme] = useTheme();
8+
9+
React.useEffect(() => {
10+
if (theme !== themeValue) {
11+
setTheme(themeValue);
12+
}
13+
}, [theme, themeValue, setTheme]);
14+
15+
return <Story {...context} />;
16+
}

.storybook/main.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
3+
addons: ['@storybook/preset-scss', '@storybook/addon-essentials'],
4+
typescript: {
5+
check: true,
6+
checkOptions: {},
7+
reactDocgen: 'react-docgen-typescript',
8+
reactDocgenTypescriptOptions: {
9+
setDisplayName: false,
10+
shouldExtractLiteralValuesFromEnum: true,
11+
compilerOptions: {
12+
allowSyntheticDefaultImports: true,
13+
esModuleInterop: true,
14+
},
15+
},
16+
},
17+
};

.storybook/preview.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import '@yandex-cloud/uikit/styles/styles.scss';
2+
3+
import React from 'react';
4+
import {ThemeProvider} from '@yandex-cloud/uikit';
5+
import {withTheme} from './decorators/withTheme';
6+
7+
const withContextProvider = (Story, context) => {
8+
const theme = context.globals.theme;
9+
10+
context.parameters.backgrounds.default = theme;
11+
context.globals.backgrounds = {
12+
value: theme === 'light' ? 'white' : 'black',
13+
};
14+
15+
context.globals.background = theme;
16+
17+
return (
18+
<ThemeProvider>
19+
<Story {...context} />
20+
</ThemeProvider>
21+
);
22+
};
23+
24+
export const decorators = [withTheme, withContextProvider];
25+
26+
export const parameters = {
27+
jsx: {showFunctions: true},
28+
backgrounds: {
29+
default: 'light',
30+
values: [
31+
{name: 'light', value: 'white'},
32+
{name: 'dark', value: 'rgba(45, 44, 51, 1)'},
33+
],
34+
},
35+
};
36+
37+
export const globalTypes = {
38+
theme: {
39+
name: 'Theme',
40+
description: 'Global theme for components',
41+
defaultValue: 'light',
42+
toolbar: {
43+
items: [
44+
{value: 'light', icon: 'circlehollow', title: 'Light'},
45+
{value: 'dark', icon: 'circle', title: 'Dark'},
46+
],
47+
},
48+
},
49+
};

package-lock.json

Lines changed: 15311 additions & 2051 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,37 @@
55
"license": "MIT",
66
"main": "index.js",
77
"scripts": {
8-
"test": "echo \"Error: no test specified\" && exit 1"
8+
"test": "echo \"Error: no test specified\" && exit 1",
9+
"start": "start-storybook -p 7002"
10+
},
11+
"dependencies": {
12+
"bem-cn-lite": "^4.1.0"
913
},
1014
"devDependencies": {
15+
"@storybook/addon-essentials": "^6.4.19",
16+
"@storybook/preset-scss": "^1.0.3",
17+
"@storybook/react": "^6.4.19",
18+
"@types/react-treeview": "^0.4.3",
1119
"@yandex-cloud/eslint-config": "^1.0.0",
1220
"@yandex-cloud/prettier-config": "^1.0.0",
1321
"@yandex-cloud/stylelint-config": "^1.1.0",
1422
"@yandex-cloud/tsconfig": "^1.0.0",
23+
"@yandex-cloud/uikit": "^1.8.0",
24+
"css-loader": "^5.2.7",
1525
"eslint": "^8.11.0",
1626
"prettier": "^2.5.1",
27+
"react": "^16.14.0",
28+
"react-docgen-typescript": "^2.2.2",
29+
"react-dom": "^16.14.0",
30+
"react-treeview": "^0.4.7",
31+
"sass": "^1.49.9",
32+
"sass-loader": "^10.2.1",
33+
"style-loader": "^2.0.0",
1734
"stylelint": "^14.5.3",
1835
"typescript": "^4.6.2"
36+
},
37+
"peerDependencies": {
38+
"react": "^16.0.0",
39+
"react-dom": "^16.0.0"
1940
}
2041
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.ydb-navigation-tree-view-empty {
2+
color: var(--yc-color-text-secondary);
3+
font-style: italic;
4+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import block from 'bem-cn-lite';
3+
4+
import {TreeView} from '../../TreeView/TreeView';
5+
6+
import './EmptyView.scss';
7+
8+
const b = block('ydb-navigation-tree-view-empty');
9+
10+
export function EmptyView() {
11+
return <TreeView name={<span className={b()}>Нет данных</span>} />;
12+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.ydb-navigation-tree-view-error {
2+
color: var(--yc-color-text-danger);
3+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import block from 'bem-cn-lite';
3+
4+
import {TreeView} from '../../TreeView/TreeView';
5+
6+
import './ErrorView.scss';
7+
8+
const b = block('ydb-navigation-tree-view-error');
9+
10+
export function ErrorView() {
11+
return <TreeView name={<span className={b()}>Ошибка</span>} />;
12+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.ydb-navigation-tree-view-loader {
2+
display: flex;
3+
align-items: center;
4+
justify-content: center;
5+
width: 20px;
6+
height: 24px;
7+
}

0 commit comments

Comments
 (0)