Skip to content

Commit

Permalink
Merge pull request #991 from ksc-fe/revision-menu
Browse files Browse the repository at this point in the history
fix some issues
  • Loading branch information
warrior-bing authored Apr 19, 2024
2 parents 910ff86 + cf9af25 commit 78f1727
Show file tree
Hide file tree
Showing 21 changed files with 480 additions and 391 deletions.
2 changes: 1 addition & 1 deletion components/breadcrumb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const typeDefs: Required<TypeDefs<BreadcrumbProps>> = {
};

const defaults = (): Partial<BreadcrumbProps> => ({
separator: '>'
separator: ''
});

export class Breadcrumb extends Component<BreadcrumbProps, BreadcrumbEvents, BreadcrumbBlocks> {
Expand Down
6 changes: 5 additions & 1 deletion components/breadcrumb/index.vdt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {getRestProps, mapChildren} from '../utils';
import {BreadcrumbItem} from './item';
import { makeStyles } from './styles';
import { Icon } from '../icon';

const {children, separator, className} = this.get();
const { k } = this.config;
Expand All @@ -13,7 +14,10 @@ const classNameObj = {

const separatorVNode = (
<span class={`${k}-breadcrumb-separator`}>
<b:separator>{separator}</b:separator>
<template v-if={!$blocks.separator && !separator}>
<Icon class="k-icon-right" />
</template>
<b:separator v-else>{separator}</b:separator>
</span>
);
const vNodes = [];
Expand Down
47 changes: 47 additions & 0 deletions components/config/demos/disableWave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: 控制全局水波纹动效
order: 1
---

通过配置`disableWave`,可以控制是否开启水波纹动效,默认`false`

```vdt
import {ConfigProvider, Button, Input, Checkbox, Radio, Select, Option} from 'kpc';
<ConfigProvider value={{disableWave: true}}>
<Button>Button</Button>
<Input />
<Checkbox v-model="value">checkbox</Checkbox>
<Radio v-model="value">radio</Radio>
<Select v-model="day">
<Option value="Monday">星期一</Option>
<Option value="Tuesday">星期二</Option>
<Option value="Wednesday">星期三</Option>
<Option value="Thursday">星期四</Option>
<Option value="Friday">星期五</Option>
<Option value="Saturday">星期六</Option>
<Option value="Sunday">星期天</Option>
</Select>
</ConfigProvider>
```

```styl
.k-input, .k-input, .k-checkbox, .k-radio
margin 0 10px
```

```ts
interface Props {
value?: boolean,
day?: string | null
}
export default class extends Component<Props> {
static template = template;
static defaults() {
return {
value: false,
day: ''
}
}
}
```
3 changes: 2 additions & 1 deletion components/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ sidebar: doc

```ts
export interface ConfigProps {
classNamePrefix?: string
classNamePrefix?: string
disableWave?: boolean
}
```
4 changes: 3 additions & 1 deletion components/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { createContext, ProviderProps } from '../context';
import { EMPTY_OBJ, Component } from 'intact';

export interface ConfigProps {
classNamePrefix?: string
classNamePrefix?: string,
disableWave?: boolean,
}

const {
Expand All @@ -17,6 +18,7 @@ function useConfigContext() {
return {
cls: (name: string) => `${config.value!.classNamePrefix || 'k'}-${name}`,
get k() { return config.value!.classNamePrefix || 'k' },
get disableWave() { return config.value!.disableWave || false }
}
}

Expand Down
10 changes: 5 additions & 5 deletions components/menu/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const defaults = {

item: {
height: '40px',
padding: '0 17px',
padding: '0 12px',
bodyPadding: '0 4px',
color: '#aeaeb9',
hoverColor: '#fff',
Expand All @@ -30,7 +30,7 @@ const defaults = {

title: {
height: '40px',
padding: '0 17px',
padding: '0 12px',
color: '#fff',
},

Expand Down Expand Up @@ -114,7 +114,7 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
// header
.${k}-menu-header {
height: ${menu.header.height};
padding: 0 21px;
padding: 0 16px;
color: ${menu.header.color};
font-size: ${menu.header.fontSize};
font-weight: bold;
Expand All @@ -125,6 +125,7 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
max-height: calc(100% - ${menu.header.height});
overflow-y: auto;
overflow-x: hidden;
scrollbar-width: none;
}
// menu title
Expand Down Expand Up @@ -169,8 +170,7 @@ export const makeMenuStyles = cache(function makeMenuStyles(k: string) {
// theme light
&.${k}-light {
border: 1px solid ${theme.color.disabledBg};
border-top: 0;
border-right: 1px solid ${theme.color.disabledBg};
background: ${menu.light.bgColor};
.${k}-menu-header {
color: ${menu.light.title.color};
Expand Down
7 changes: 5 additions & 2 deletions components/table/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const defaults = {
thead: {
get bgColor() { return theme.color.bg },
get color() { return theme.color.lightBlack },
padding: `0 5px 0 12px`,
padding: `0 8px 0 12px`,
fontSize: `12px`,
fontWeight: `bold`,
textAlign: 'left',
Expand All @@ -31,7 +31,7 @@ const defaults = {
// tbody
tbody: {
get hoverBgcolor() { return theme.color.bg },
padding: `11px 5px 11px 12px`,
padding: `11px 8px 11px 12px`,
},

// stripe
Expand Down Expand Up @@ -129,6 +129,9 @@ export const makeStyles = cache(function makeStyles(k: string) {
top: 50%;
transform: translateY(-50%);
}
&.${k}-fixed-right:before {
left: -2px;
}
&:first-of-type:before {
display: none;
}
Expand Down
1 change: 0 additions & 1 deletion components/tooltip/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export const makeStyles = cache(function makeStyles(k: string) {
const borderDirection = directionMap[direction as keyof typeof directionMap];
return css`
&.${k}-${direction} {
border-${borderDirection}-color: ${borderColor};
&:before {
border-${borderDirection}-color: ${bgColor};
}
Expand Down
5 changes: 3 additions & 2 deletions components/upload/index.vdt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {UploadFileStatus} from './useUpload';

const {
className, accept, multiple, limit,
files, children, type, directory
files, children, type, directory, disabled
} = this.get();

const drag = this.drag;
Expand All @@ -22,6 +22,7 @@ const classNameObj = {
[`${k}-drag`]: type === 'drag',
[`${k}-dragover`]: drag.dragOver.value,
[`${k}-gallery`]: type === 'gallery',
[`${k}-disabled`]: disabled,
[makeStyles(k)]: true,
};

Expand All @@ -40,7 +41,7 @@ const handle = (
<b:content>
<b:children v-if={children}>{children}</b:children>
<template v-else-if={type !== 'gallery'}>
<Button v-if={type === 'select'}>
<Button disabled={disabled} v-if={type === 'select'}>
<Icon class={`${k}-icon-upload`} />
{_$('点击上传')}
</Button>
Expand Down
11 changes: 11 additions & 0 deletions components/upload/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,17 @@ export const makeStyles = cache(function makeStyles(k: string) {
transform: translateY(-50%);
}
}
&.${k}-disabled {
.${k}-upload-add, .${k}-upload-handle {
cursor: auto;
a {
color: ${upload.color};
}
&:hover {
border-color: ${theme.color.border}
}
}
}
`;
});

Expand Down
3 changes: 3 additions & 0 deletions components/wave/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export class Wave extends Component<WaveProps> {
const {disabled} = this.get();
const node = e.target as HTMLElement;

// configProvider全局禁用动效
if (this.config.disableWave) return;

// 点击输入框中的icon时,此时输入框不需要动效
const isInput = instance!.classList.contains('k-input-wrapper');
if (disabled || isInput && node!.classList.contains(this.config.cls('icon'))) return;
Expand Down
Loading

0 comments on commit 78f1727

Please sign in to comment.