Skip to content

Commit

Permalink
Merge branch 'master' of github.com:oceanbase/oceanbase-design into w…
Browse files Browse the repository at this point in the history
…angdongya-dev
  • Loading branch information
wdy01684395 committed Sep 25, 2023
2 parents f25196e + d07096c commit dd8f9a6
Show file tree
Hide file tree
Showing 314 changed files with 12,168 additions and 4,294 deletions.
2 changes: 1 addition & 1 deletion .dumi/pages/index/components/SiteContext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';

export interface SiteContextProps {
isMobile: boolean;
Expand Down
3 changes: 2 additions & 1 deletion .dumi/theme/SiteThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ConfigProvider, token } from '@oceanbase/design';
import { ChartProvider } from '@oceanbase/charts';
import type { ThemeProviderProps } from 'antd-style';
import { ThemeProvider } from 'antd-style';
import type { FC } from 'react';
Expand Down Expand Up @@ -40,7 +41,7 @@ const SiteThemeProvider: FC<ThemeProviderProps> = ({ children, theme, ...rest })
direction={direction}
locale={lang === 'cn' ? zhCN : undefined}
>
{children}
<ChartProvider theme={theme.isDark ? 'dark' : 'light'}>{children}</ChartProvider>
</ConfigProvider>
</ThemeProvider>
);
Expand Down
5 changes: 4 additions & 1 deletion .dumi/theme/builtins/ComponentOverview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ const useStyle = () => {
cursor: pointer;
transition: all 0.5s;
&:hover {
box-shadow: 0 6px 16px -8px #00000014, 0 9px 28px #0000000d, 0 12px 48px 16px #00000008;
box-shadow:
0 6px 16px -8px #00000014,
0 9px 28px #0000000d,
0 12px 48px 16px #00000008;
}
`,
componentsOverviewAffix: css`
Expand Down
39 changes: 21 additions & 18 deletions .dumi/theme/builtins/DemoWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,29 @@ const DemoWrapper: typeof DumiDemoGrid = ({ items }) => {

const demos = React.useMemo(
() =>
items.reduce((acc, item) => {
const { previewerProps } = item;
const { debug } = previewerProps;
items.reduce(
(acc, item) => {
const { previewerProps } = item;
const { debug } = previewerProps;

if (debug && !showDebug) return acc;
if (debug && !showDebug) return acc;

return acc.concat({
...item,
previewerProps: {
...previewerProps,
expand: expandAll,
// always override debug property, because dumi will hide debug demo in production
debug: false,
/**
* extra marker for the original debug
*/
originDebug: debug,
},
});
}, [] as typeof items),
return acc.concat({
...item,
previewerProps: {
...previewerProps,
expand: expandAll,
// always override debug property, because dumi will hide debug demo in production
debug: false,
/**
* extra marker for the original debug
*/
originDebug: debug,
},
});
},
[] as typeof items
),
[expandAll, showDebug]
);

Expand Down
4 changes: 3 additions & 1 deletion .dumi/theme/common/styles/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export default () => {
background-color: inherit;
border-radius: 4px;
cursor: pointer;
transition: color 0.3s ease-in-out, background-color 0.3s ease-in-out;
transition:
color 0.3s ease-in-out,
background-color 0.3s ease-in-out;
.rtl & {
margin: 3px 0;
Expand Down
6 changes: 6 additions & 0 deletions .dumi/theme/common/styles/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,12 @@ const GlobalStyle: React.FC = () => {
}
}
td {
&:nth-child(3) {
color: ${token.magenta7};
}
}
th {
color: #5c6b77;
font-weight: 500;
Expand Down
4 changes: 3 additions & 1 deletion .dumi/theme/common/styles/NProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export default () => {
}
.peg {
box-shadow: 0 0 10px ${token.colorPrimary}, 0 0 5px ${token.colorPrimary};
box-shadow:
0 0 10px ${token.colorPrimary},
0 0 5px ${token.colorPrimary};
}
.spinner-icon {
Expand Down
8 changes: 6 additions & 2 deletions .dumi/theme/common/styles/PreviewImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,12 @@ export default () => {
.preview-image-boxes.preview-image-boxes-with-carousel img {
padding: 0;
box-shadow: 0 1px 0 0 #ddd, 0 3px 0 0 ${token.colorBgContainer}, 0 4px 0 0 #ddd,
0 6px 0 0 ${token.colorBgContainer}, 0 7px 0 0 #ddd;
box-shadow:
0 1px 0 0 #ddd,
0 3px 0 0 ${token.colorBgContainer},
0 4px 0 0 #ddd,
0 6px 0 0 ${token.colorBgContainer},
0 7px 0 0 #ddd;
}
.preview-image-box img:hover {
Expand Down
9 changes: 6 additions & 3 deletions .dumi/theme/common/styles/Reset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export default () => {
@font-face {
font-weight: normal;
font-family: AlibabaPuHuiTi;
src: url('//at.alicdn.com/t/webfont_6e11e43nfj.woff2') format('woff2'),
src:
url('//at.alicdn.com/t/webfont_6e11e43nfj.woff2') format('woff2'),
url('//at.alicdn.com/t/webfont_6e11e43nfj.woff') format('woff'),
/* chrome、firefox */ url('//at.alicdn.com/t/webfont_6e11e43nfj.ttf') format('truetype'); /* chrome、firefox、opera、Safari, Android, iOS 4.2+ */
font-display: swap;
Expand All @@ -20,7 +21,8 @@ export default () => {
@font-face {
font-weight: bold;
font-family: AlibabaPuHuiTi;
src: url('//at.alicdn.com/t/webfont_exesdog9toj.woff2') format('woff2'),
src:
url('//at.alicdn.com/t/webfont_exesdog9toj.woff2') format('woff2'),
url('//at.alicdn.com/t/webfont_exesdog9toj.woff') format('woff'),
/* chrome、firefox */ url('//at.alicdn.com/t/webfont_exesdog9toj.ttf')
format('truetype'); /* chrome、firefox、opera、Safari, Android, iOS 4.2+ */
Expand All @@ -32,7 +34,8 @@ export default () => {
@font-face {
font-weight: 900;
font-family: 'AliPuHui';
src: url('//at.alicdn.com/wf/webfont/exMpJIukiCms/Gsw2PSKrftc1yNWMNlXgw.woff2')
src:
url('//at.alicdn.com/wf/webfont/exMpJIukiCms/Gsw2PSKrftc1yNWMNlXgw.woff2')
format('woff2'),
url('//at.alicdn.com/wf/webfont/exMpJIukiCms/vtu73by4O2gEBcvBuLgeu.woff') format('woff');
font-display: swap;
Expand Down
7 changes: 6 additions & 1 deletion .dumi/theme/layouts/GlobalLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from '@ant-design/cssinjs';
import { App, theme as obTheme } from '@oceanbase/design';
import type { DirectionType } from '@oceanbase/design/es/config-provider';
import { createSearchParams, useOutlet, useSearchParams } from 'dumi';
import { usePrefersColor, createSearchParams, useOutlet, useSearchParams } from 'dumi';
import React, { useCallback, useEffect, useMemo } from 'react';
import useLayoutState from '../../hooks/useLayoutState';
import SiteThemeProvider from '../SiteThemeProvider';
Expand Down Expand Up @@ -42,6 +42,7 @@ const GlobalLayout: React.FC = () => {
const outlet = useOutlet();
const { pathname } = useLocation();
const [searchParams, setSearchParams] = useSearchParams();
const [, , setPrefersColor] = usePrefersColor();
const [{ theme = [], direction, isMobile }, setSiteState] = useLayoutState<SiteState>({
isMobile: false,
direction: 'ltr',
Expand Down Expand Up @@ -69,6 +70,8 @@ const GlobalLayout: React.FC = () => {
...nextSearchParams,
theme: value.filter(t => t !== 'light'),
});
// Set theme of dumi site
setPrefersColor(value?.filter(t => t === 'dark' || t === 'light')?.[0]);
}
});

Expand All @@ -88,6 +91,8 @@ const GlobalLayout: React.FC = () => {
const _direction = searchParams.get('direction') as DirectionType;

setSiteState({ theme: _theme, direction: _direction === 'rtl' ? 'rtl' : 'ltr' });
// Set theme of dumi site
setPrefersColor(_theme?.filter(t => t === 'dark' || t === 'light')?.[0]);
// Handle isMobile
updateMobileMode();

Expand Down
2 changes: 1 addition & 1 deletion .dumi/theme/slots/SiteContext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as React from 'react';
import React from 'react';
import type { DirectionType } from '@oceanbase/design/es/config-provider';
import type { ThemeName } from '../common/ThemeSwitch';

Expand Down
13 changes: 8 additions & 5 deletions .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export default defineConfig({
// 默认重定向到子包的 src 文件夹
// ref: https://d.umijs.org/config#monoreporedirect
monorepoRedirect: {},
ssr: process.env.NODE_ENV === 'production' ? {} : false,
// umi.server.js build error, disable it for now
// ssr: process.env.NODE_ENV === 'production' ? {} : false,
hash: true,
crossorigin: {},
// ref: https://d.umijs.org/config#sitemap
Expand Down Expand Up @@ -131,6 +132,7 @@ export default defineConfig({
{ title: 'Modal 对话框', link: '/components/modal' },
{ title: 'Notification 通知提醒框', link: '/components/notification' },
{ title: 'Spin 加载中', link: '/components/spin' },
{ title: 'Badge 徽标数', link: '/components/badge' },
],
},
{
Expand Down Expand Up @@ -175,10 +177,7 @@ export default defineConfig({
title: 'BackgroundTaskManager 后台任务管理器',
link: '/biz-components/background-task-manager',
},
{ title: 'SideTip 悬浮操作按钮', link: '/biz-components/side-tip' },
{ title: 'FullscreenBox 全屏盒子', link: '/biz-components/fullscreen-box' },
{ title: 'Highlight 代码高亮', link: '/biz-components/highlight' },
{title: 'TagSelect 标签式单选/多选', link: '/biz-components/tag-select'}
{ title: 'TagSelect 标签式单选/多选', link: '/biz-components/tag-select' },
],
},
],
Expand All @@ -189,6 +188,10 @@ export default defineConfig({
title: 'Stat 数字统计',
link: '/charts/stat',
},
{
title: 'Score 得分图',
link: '/charts/score',
},
{
title: 'Line 折线图',
link: '/charts/line',
Expand Down
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ packages/design/src/theme/style/*.less
packages/icons/src
.secignore
LICENSE
es
lib
dist
/site
/server
/public
__testfixtures__

33 changes: 25 additions & 8 deletions docs/charts/charts-theme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,33 @@ group: 可视化图表

OceanBase Charts 的设计体系遵循 AntV 设计规范,并在此基础上扩展出了很多具备 OceanBase 产品风格的设计规范模式,包括但不限于全局样式(色板、圆角、边框)和特定图表的视觉定制,以传递 OceanBase 科技、活力、专注和关怀的品牌特点。

## 使用主题 Token
## 使用主题配置

```ts
import { theme } from '@oceanbase/charts';
```tsx | pure
import { ChartProvider, useTheme } from '@oceanbase/charts';

// 主题色
console.log(theme.defaultColor);

// 折线图线宽
console.log(theme.styleSheet.lineBorder);
export default () {
// 获取主题配置
const themeConfig = useTheme();
// 主题色
console.log(themeConfig.defaultColor);
// 折线图线宽
console.log(themeConfig.styleSheet.lineBorder);
// 设置主题
return (
<>
<ChartProvider theme="light">
{...}
</ChartProvider>
<ChartProvider theme="dark">
{...}
</ChartProvider>
<ChartProvider theme={{ defaultColor: '#ff0000', subColor: '#00ff00' }}>
{...}
</ChartProvider>
</>
);
};
```

- 主题的全量 Token 可参考 https://github.com/oceanbase/charts/blob/master/src/theme/index.ts#L29
1 change: 1 addition & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const pkgList = readdirSync(join(__dirname, './packages')).filter(

const moduleNameMapper = {
'^react$': require.resolve('react'),
'^.+\\.svg$': require.resolve('jest-svg-transformer'),
'\\.(css|less|sass|scss)$': require.resolve('identity-obj-proxy'),
};

Expand Down
Loading

0 comments on commit dd8f9a6

Please sign in to comment.