Skip to content

Commit

Permalink
chore(react): improve theme styles
Browse files Browse the repository at this point in the history
  • Loading branch information
janryWang committed Oct 4, 2021
1 parent bac67cf commit f45572d
Show file tree
Hide file tree
Showing 28 changed files with 461 additions and 347 deletions.
2 changes: 1 addition & 1 deletion formily/antd/playground/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const App = () => {
[]
)
return (
<Designer engine={engine}>
<Designer engine={engine} theme="dark">
<StudioPanel logo={<LogoWidget />} actions={<ActionsWidget />}>
<CompositePanel>
<CompositePanel.Item title="panels.Component" icon="Component">
Expand Down
8 changes: 4 additions & 4 deletions formily/antd/playground/webpack.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fs from 'fs-extra'
import { GlobSync } from 'glob'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import autoprefixer from 'autoprefixer'
//import { getThemeVariables } from 'antd/dist/theme'
import { getThemeVariables } from 'antd/dist/theme'

const getWorkspaceAlias = () => {
const basePath = path.resolve(__dirname, '../../../')
Expand Down Expand Up @@ -80,9 +80,9 @@ export default {
{
loader: 'less-loader',
options: {
// modifyVars: getThemeVariables({
// dark: true, // 开启暗黑模式
// }),
modifyVars: getThemeVariables({
dark: true, // 开启暗黑模式
}),
javascriptEnabled: true,
},
},
Expand Down
31 changes: 6 additions & 25 deletions formily/antd/src/common/LoadTemplate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import React from 'react'
import { Space, Typography, Divider } from 'antd'
import { usePrefix, TextWidget } from '@designable/react'
import cls from 'classnames'
import './styles.less'
import { NodeActionsWidget } from '@designable/react'

export interface ITemplateAction {
title: React.ReactNode
Expand All @@ -18,27 +15,11 @@ export interface ILoadTemplateProps {
}

export const LoadTemplate: React.FC<ILoadTemplateProps> = (props) => {
const prefix = usePrefix('load-template')
return (
<div className={cls(prefix, props.className)} style={props.style}>
<div className={prefix + '-actions'}>
<Space split={<Divider type="vertical" />}>
{props.actions?.map((action, key) => {
return (
<Typography.Link
key={key}
data-click-stop-propagation="true"
onClick={(e) => {
e.stopPropagation()
action?.onClick?.()
}}
>
<TextWidget>{action.title}</TextWidget>
</Typography.Link>
)
})}
</Space>
</div>
</div>
<NodeActionsWidget>
{props.actions?.map((action, key) => {
return <NodeActionsWidget.Action {...action} key={key} />
})}
</NodeActionsWidget>
)
}
2 changes: 2 additions & 0 deletions formily/antd/src/components/ArrayCards/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export const ArrayCards: DnFC<CardProps> = observer((props) => {
actions={[
{
title: node.getMessage('addIndex'),
icon: 'AddIndex',
onClick: () => {
if (
hasNodeByComponentPath(node, [
Expand All @@ -176,6 +177,7 @@ export const ArrayCards: DnFC<CardProps> = observer((props) => {

{
title: node.getMessage('addOperation'),
icon: 'AddOperation',
onClick: () => {
const oldAdditionNode = findNodeByComponentPath(node, [
'ArrayCards',
Expand Down
4 changes: 4 additions & 0 deletions formily/antd/src/components/ArrayTable/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ export const ArrayTable: DnFC<TableProps<any>> = observer((props) => {
actions={[
{
title: node.getMessage('addSortHandle'),
icon: 'AddSort',
onClick: () => {
if (
hasNodeByComponentPath(node, [
Expand Down Expand Up @@ -277,6 +278,7 @@ export const ArrayTable: DnFC<TableProps<any>> = observer((props) => {
},
{
title: node.getMessage('addIndex'),
icon: 'AddIndex',
onClick: () => {
if (
hasNodeByComponentPath(node, [
Expand Down Expand Up @@ -321,6 +323,7 @@ export const ArrayTable: DnFC<TableProps<any>> = observer((props) => {
},
{
title: node.getMessage('addColumn'),
icon: 'AddColumn',
onClick: () => {
const operationNode = findNodeByComponentPath(node, [
'ArrayTable',
Expand Down Expand Up @@ -353,6 +356,7 @@ export const ArrayTable: DnFC<TableProps<any>> = observer((props) => {
},
{
title: node.getMessage('addOperation'),
icon: 'AddOperation',
onClick: () => {
const oldOperationNode = findNodeByComponentPath(node, [
'ArrayTable',
Expand Down
4 changes: 2 additions & 2 deletions formily/antd/src/components/Field/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const createVoidFieldSchema = (
'x-reactions': {
fulfill: {
state: {
visible: '{{$form.values["x-decorator"] === "FormItem"}}',
hidden: '{{$form.values["x-decorator"] === "FormItem"}}',
},
},
},
Expand All @@ -181,7 +181,7 @@ export const createVoidFieldSchema = (
'x-reactions': {
fulfill: {
state: {
visible: '{{$form.values["x-decorator"] === "FormItem"}}',
hidden: '{{$form.values["x-decorator"] === "FormItem"}}',
},
},
},
Expand Down
1 change: 1 addition & 0 deletions formily/antd/src/components/FormCollapse/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export const FormCollapse: DnFC<CollapseProps> & {
actions={[
{
title: node.getMessage('addCollapsePanel'),
icon: 'AddPanel',
onClick: () => {
const tabPane = new TreeNode({
componentName: 'Field',
Expand Down
1 change: 1 addition & 0 deletions formily/antd/src/components/FormGrid/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const FormGrid: DnFC<React.ComponentProps<formilyGrid>> & {
actions={[
{
title: node.getMessage('addGridColumn'),
icon: 'AddColumn',
onClick: () => {
const column = new TreeNode({
componentName: 'Field',
Expand Down
1 change: 1 addition & 0 deletions formily/antd/src/components/FormTab/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const FormTab: DnFC<TabsProps> & {
actions={[
{
title: node.getMessage('addTabPane'),
icon: 'AddPanel',
onClick: () => {
const tabPane = new TreeNode({
componentName: 'Field',
Expand Down
1 change: 0 additions & 1 deletion formily/antd/src/locales/ArrayBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const ArrayAddition = {
title: '添加按钮',
settings: {
'x-component-props': {
title: '标题',
method: '方法',
defaultValue: '默认值',
},
Expand Down
8 changes: 0 additions & 8 deletions formily/antd/src/schemas/ArrayTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,6 @@ const Column: ISchema = {
const Addition: ISchema = {
type: 'object',
properties: {
title: {
type: 'string',
'x-decorator': 'FormItem',
'x-component': 'Input',
'x-component-props': {
defaultValue: 'Addition',
},
},
method: {
type: 'string',
enum: ['push', 'unshift'],
Expand Down
31 changes: 6 additions & 25 deletions formily/next/src/common/LoadTemplate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import React from 'react'
import { Space, Typography, Divider } from 'antd'
import { usePrefix, TextWidget } from '@designable/react'
import cls from 'classnames'
import './styles.less'
import { NodeActionsWidget } from '@designable/react'

export interface ITemplateAction {
title: React.ReactNode
Expand All @@ -18,27 +15,11 @@ export interface ILoadTemplateProps {
}

export const LoadTemplate: React.FC<ILoadTemplateProps> = (props) => {
const prefix = usePrefix('load-template')
return (
<div className={cls(prefix, props.className)} style={props.style}>
<div className={prefix + '-actions'}>
<Space split={<Divider type="vertical" />}>
{props.actions?.map((action, key) => {
return (
<Typography.Link
key={key}
data-click-stop-propagation="true"
onClick={(e) => {
e.stopPropagation()
action?.onClick?.()
}}
>
<TextWidget>{action.title}</TextWidget>
</Typography.Link>
)
})}
</Space>
</div>
</div>
<NodeActionsWidget>
{props.actions?.map((action, key) => {
return <NodeActionsWidget.Action {...action} key={key} />
})}
</NodeActionsWidget>
)
}
35 changes: 0 additions & 35 deletions formily/next/src/common/LoadTemplate/styles.less

This file was deleted.

2 changes: 2 additions & 0 deletions formily/next/src/components/ArrayCards/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export const ArrayCards: DnFC<CardProps> = observer((props) => {
actions={[
{
title: node.getMessage('addIndex'),
icon: 'AddIndex',
onClick: () => {
if (
hasNodeByComponentPath(node, [
Expand All @@ -178,6 +179,7 @@ export const ArrayCards: DnFC<CardProps> = observer((props) => {

{
title: node.getMessage('addOperation'),
icon: 'AddOperation',
onClick: () => {
const oldAdditionNode = findNodeByComponentPath(node, [
'ArrayCards',
Expand Down
3 changes: 3 additions & 0 deletions formily/next/src/components/ArrayTable/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ export const ArrayTable: DnFC<TableProps> = observer((props) => {
actions={[
{
title: node.getMessage('addIndex'),
icon: 'AddIndex',
onClick: () => {
if (
hasNodeByComponentPath(node, [
Expand Down Expand Up @@ -257,6 +258,7 @@ export const ArrayTable: DnFC<TableProps> = observer((props) => {
},
{
title: node.getMessage('addColumn'),
icon: 'AddColumn',
onClick: () => {
const operationNode = findNodeByComponentPath(node, [
'ArrayTable',
Expand Down Expand Up @@ -289,6 +291,7 @@ export const ArrayTable: DnFC<TableProps> = observer((props) => {
},
{
title: node.getMessage('addOperation'),
icon: 'AddOperation',
onClick: () => {
const oldOperationNode = findNodeByComponentPath(node, [
'ArrayTable',
Expand Down
1 change: 1 addition & 0 deletions formily/next/src/components/FormCollapse/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export const FormCollapse: DnFC<CollapseProps> & {
actions={[
{
title: node.getMessage('addCollapsePanel'),
icon: 'AddPanel',
onClick: () => {
const collapsePanel = new TreeNode({
componentName: 'Field',
Expand Down
1 change: 1 addition & 0 deletions formily/next/src/components/FormGrid/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const FormGrid: DnFC<React.ComponentProps<formilyGrid>> & {
actions={[
{
title: node.getMessage('addGridColumn'),
icon: 'AddColumn',
onClick: () => {
const column = new TreeNode({
componentName: 'Field',
Expand Down
1 change: 1 addition & 0 deletions formily/next/src/components/FormTab/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export const FormTab: DnFC<TabProps> & {
actions={[
{
title: node.getMessage('addTabPane'),
icon: 'AddPanel',
onClick: () => {
const tabPane = new TreeNode({
componentName: 'Field',
Expand Down
2 changes: 1 addition & 1 deletion packages/react-settings-form/src/SettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const SettingsForm: React.FC<ISettingFormProps> = observer(
const form = useMemo(() => {
return createForm({
initialValues: node?.designerProps?.defaultProps,
values: node.props,
values: node?.props,
effects(form) {
useLocales(node)
useSnapshot(operation)
Expand Down
Loading

0 comments on commit f45572d

Please sign in to comment.