Skip to content

Commit

Permalink
feat!: migration on uikit 5 (#71)
Browse files Browse the repository at this point in the history
* feat!: migration on uikit 5

* fix: github workflow node.js version

* fix(AsideHeader): background color

* chore: update logo for storybook
  • Loading branch information
DarkGenius authored Jul 26, 2023
1 parent 6eedc4b commit a032d42
Show file tree
Hide file tree
Showing 62 changed files with 24,499 additions and 23,210 deletions.
16 changes: 16 additions & 0 deletions .babelrc.json
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": []
}
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
cache: 'npm'
node-version: 18
cache: npm
- name: Install Packages
run: npm ci
- name: Lint Files
Expand All @@ -38,8 +38,8 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14.x'
cache: 'npm'
node-version: 18
cache: npm
- name: Install Packages
run: npm ci
- name: Unit Tests
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: gravity-ui/preview-build-action@v1
with:
node-version: 18
env:
TS_NODE_PROJECT: .storybook/tsconfig.json
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ jobs:
with:
github-token: ${{ secrets.GRAVITY_UI_BOT_GITHUB_TOKEN }}
npm-token: ${{ secrets.GRAVITY_UI_BOT_NPM_TOKEN }}
node-version: 18
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14
18
34 changes: 23 additions & 11 deletions .storybook/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions .storybook/decorators/withLang.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import type {Decorator} from '@storybook/react';
import {Lang, configure} from '../../src';

export const withLang: Decorator = (Story, context) => {
const lang = context.globals.lang;

configure({
lang: lang as Lang,
});

return <Story key={lang} {...context} />;
};
15 changes: 15 additions & 0 deletions .storybook/decorators/withMobile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import type {Decorator} from '@storybook/react';
import {useMobile} from '@gravity-ui/uikit';

export const withMobile: Decorator = (Story, context) => {
const mobileValue = context.globals.platform === 'mobile';

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

React.useEffect(() => {
setMobile(mobileValue);
}, [mobileValue]);

return <Story {...context} />;
};
11 changes: 0 additions & 11 deletions .storybook/decorators/withTheme.tsx

This file was deleted.

21 changes: 16 additions & 5 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
module.exports = {
import type {StorybookConfig} from '@storybook/react-webpack5';

const config: StorybookConfig = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(ts|tsx)'],
addons: [
'@storybook/addon-links',
'@storybook/addon-essentials',
{name: '@storybook/addon-essentials', options: {backgrounds: false}},
'@storybook/addon-interactions',
'@storybook/preset-scss',
'storybook-preset-inline-svg',
'./theme-addon/register.tsx'
],
framework: '@storybook/react',
features: {
postcss: false,
framework: {
name: '@storybook/react-webpack5',
options: {}
},
docs: {
autodocs: false,
},
core: {
disableTelemetry: true,
},
};

export default config;
6 changes: 6 additions & 0 deletions .storybook/manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import {addons} from '@storybook/addons';
import {themes} from './theme';

addons.setConfig({
theme: themes.light,
});
32 changes: 0 additions & 32 deletions .storybook/preview.ts

This file was deleted.

84 changes: 84 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import './styles.scss';
import '@gravity-ui/uikit/styles/styles.css';

import React from 'react';
import type {Decorator, Preview} from '@storybook/react';
import {ThemeProvider, MobileProvider, Lang, configure as uiKitConfigure} from '@gravity-ui/uikit';
import {configure as componentsConfigure} from '@gravity-ui/components';
import {configure} from '../src';
import {withMobile} from './decorators/withMobile';
import {withLang} from './decorators/withLang';

configure({
lang: Lang.En,
});
uiKitConfigure({
lang: Lang.En,
});
componentsConfigure({
lang: Lang.En,
});

const withContextProvider: Decorator = (Story, context) => {
return (
<React.StrictMode>
<ThemeProvider theme={context.globals.theme}>
<MobileProvider>
<Story {...context} />
</MobileProvider>
</ThemeProvider>
</React.StrictMode>
);
};

const preview: Preview = {
decorators: [withMobile, withLang, withContextProvider],
parameters: {
jsx: {showFunctions: true},
options: {
storySort: {
order: ['Theme', 'Components', ['Basic']],
method: 'alphabetical',
},
},
layout: 'fullscreen',
},
globalTypes: {
theme: {
name: 'Theme',
defaultValue: 'light',
toolbar: {
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: {
name: 'Language',
defaultValue: 'en',
toolbar: {
icon: 'globe',
items: [
{value: 'en', right: '🇬🇧', title: 'En'},
{value: 'ru', right: '🇷🇺', title: 'Ru'},
],
},
},
platform: {
name: 'Platform',
defaultValue: 'desktop',
toolbar: {
items: [
{value: 'desktop', title: 'Desktop', icon: 'browser'},
{value: 'mobile', title: 'Mobile', icon: 'mobile'},
],
},
},
},
};

export default preview;
5 changes: 5 additions & 0 deletions .storybook/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import '~@doc-tools/transform/dist/css/yfm.css';

body {
padding: 0;
}
26 changes: 26 additions & 0 deletions .storybook/theme-addon/register.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react';
import {addons, types} from '@storybook/addons';
import {useGlobals, type API} from '@storybook/api';
import {getThemeType} from '@gravity-ui/uikit';
import {themes} from '../theme';

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

addons.register(ADDON_ID, (api) => {
addons.add(TOOL_ID, {
type: types.TOOL,
title: 'Theme',
render: () => {
return <Tool api={api} />;
},
});
});

function Tool({api}: {api: API}) {
const [{theme}] = useGlobals();
React.useEffect(() => {
api.setOptions({theme: themes[getThemeType(theme)]});
}, [theme]);
return null;
}
41 changes: 41 additions & 0 deletions .storybook/theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import {create} from '@storybook/theming';

export const CloudThemeLight = create({
base: 'light',

colorPrimary: '#027bf3',
colorSecondary: 'rgba(2, 123, 243, 0.6)',

// Typography
fontBase: '"Helvetica Neue", Arial, Helvetica, sans-serif',
fontCode:
'"SF Mono", "Menlo", "Monaco", "Consolas", "Ubuntu Mono", "Liberation Mono", "DejaVu Sans Mono", "Courier New", "Courier", monospace',

// Text colors
textColor: 'black',
textInverseColor: 'black',

// Toolbar default and active colors
barTextColor: 'silver',
barSelectedColor: '#027bf3',
// barBg: '#027bf3',

// Form colors
inputBg: 'white',
inputBorder: 'silver',
inputTextColor: 'black',
inputBorderRadius: 4,

brandUrl: 'https://github.com/gravity-ui/uikit',
brandTitle: `<div style="font-size: 18px; color: #027bf3; font-weight: 600; margin-top: -6px; margin-bottom: 2px;">Gravity UI</div>
<div style="font-size: 14px;color: #7d7d7d;font-weight: 400;">Components</div>`,
});

export const CloudThemeDark = create({
base: 'dark',
});

export const themes = {
light: CloudThemeLight,
dark: CloudThemeDark,
};
Loading

0 comments on commit a032d42

Please sign in to comment.