Skip to content

Commit

Permalink
feat: add collapse
Browse files Browse the repository at this point in the history
  • Loading branch information
xsf0105 committed Dec 8, 2022
1 parent fa2978a commit 70e345f
Show file tree
Hide file tree
Showing 13 changed files with 862 additions and 24 deletions.
16 changes: 13 additions & 3 deletions example/src/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"cName": "跑马灯",
"type": "component",
"show": true,
"desc": "动作面板",
"desc": "跑马灯",
"author": "yhy"
},
{
Expand All @@ -107,7 +107,7 @@
"cName": "通知栏",
"type": "component",
"show": true,
"desc": "动作面板",
"desc": "通知栏",
"author": "yhy"
},
{
Expand All @@ -117,7 +117,7 @@
"cName": "进度条",
"type": "component",
"show": true,
"desc": "动作面板",
"desc": "进度条",
"author": "yhy"
},
{
Expand Down Expand Up @@ -221,6 +221,16 @@
"desc": "动作面板",
"author": "MrZhao"
},
{
"version": "1.0.29",
"name": "Collapse",
"sort": 1,
"cName": "折叠面板",
"type": "component",
"show": true,
"desc": "折叠面板",
"author": "xsf"
},
{
"version": "0.0.1",
"name": "Dialog",
Expand Down
14 changes: 3 additions & 11 deletions example/src/sites/doc/views/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,6 @@
<doc-nav></doc-nav>

<div id="doc-content" class="doc-content">
<div class="doc-title" v-if="isShow()">
<div class="doc-title-position" :class="{ fixed: fixed, hidden: hidden }">
<div class="title">
{{ componentName.name }}&nbsp;{{
isZhLang ? componentName.cName : ""
}}
</div>
</div>
</div>

<div
class="doc-content-document"
:class="{ isComponent: isShow(), full: !isShow() }"
Expand Down Expand Up @@ -162,7 +152,9 @@ export default defineComponent({
const routename = to.path.toLocaleLowerCase().split("/").pop() || "";
state.componentName.name = routename.split("-")[0];
for (let i = 0; i < nav.length; i++) {
const activePackage: any = nav[i].packages.find((item: any) => item.name.toLowerCase() == state.componentName.name);
const activePackage: any = nav[i].packages.find(
(item: any) => item.name.toLowerCase() == state.componentName.name
);
if (activePackage) {
state.componentName.name = activePackage.name;
state.componentName.cName = activePackage.cName;
Expand Down
37 changes: 27 additions & 10 deletions packages/quark/src/button/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@

<h2>{{ translate("title.plain") }}</h2>
<div class="demo-buttons">
<quark-button plain type="primary">{{ translate("type.primary") }}</quark-button>
<quark-button plain type="success">{{ translate("type.success") }}</quark-button>
<quark-button plain type="primary">{{
translate("type.primary")
}}</quark-button>
<quark-button plain type="success">{{
translate("type.success")
}}</quark-button>
</div>

<h2>{{ translate("title.size") }}</h2>
<div class="demo-buttons">
<quark-button type="primary" size="big">{{ translate("size.big") }}</quark-button>
<quark-button type="primary" size="big">{{
translate("size.big")
}}</quark-button>
<quark-button type="primary">{{ translate("size.normal") }}</quark-button>
<quark-button type="primary" size="small">{{ translate("size.small") }}</quark-button>
<quark-button type="primary" size="small">{{
translate("size.small")
}}</quark-button>
</div>

<h2>{{ translate("title.disabled") }}</h2>
Expand All @@ -41,33 +49,42 @@

<h2>{{ translate("title.shape") }}</h2>
<div class="demo-buttons">
<quark-button shape="square" type="danger">{{ translate("shape.square") }}</quark-button>
<quark-button shape="square" type="danger">{{
translate("shape.square")
}}</quark-button>
<quark-button style="--button-border-radius: 6px" type="primary">{{
translate("shape.round")
}}</quark-button>
</div>

<h2>{{ translate("title.loading") }}</h2>
<div class="demo-buttons flex">
<quark-button loading loadtype="circular" type="danger">{{ translate("loading") }}</quark-button>
<quark-button loading type="warning">{{ translate("loading") }}</quark-button>
<quark-button loading loadtype="circular" type="danger">{{
translate("loading")
}}</quark-button>
<quark-button loading type="warning">{{
translate("loading")
}}</quark-button>
<quark-button
@click="changeLoading"
:loading="isLoading"
type="success"
>{{ translate("click") }}</quark-button>
>{{ translate("click") }}</quark-button
>
</div>

<h2>{{ translate("title.icon") }}</h2>
<div class="demo-buttons">
<quark-button
type="danger"
icon="https://m.hellobike.com/resource/helloyun/16682/Agnve_tel%20(1).png"
>{{ translate("like") }}</quark-button>
>{{ translate("like") }}</quark-button
>
<quark-button
type="primary"
icon="https://m.hellobike.com/resource/helloyun/16682/_pay6_setting%20(1).png"
>{{ translate("name") }}</quark-button>
>{{ translate("name") }}</quark-button
>
</div>
</div>
</template>
Expand Down
10 changes: 10 additions & 0 deletions packages/quark/src/collapse/demo.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.action-sheet-demo {
.demo-buttons quark-button {
margin-right: 6px;
margin-top: 6px;
}

.demo-buttons {
margin-bottom: 24px;
}
}
79 changes: 79 additions & 0 deletions packages/quark/src/collapse/demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<template>
<div class="demo no-padding action-sheet-demo">
<h2>{{ translate("basic") }}</h2>
<div>
<quark-collapse :title="translate('title1')">
生命远不止连轴转和忙到极限,人类的体验远比这辽阔、丰富得多。
</quark-collapse>
<quark-collapse :title="translate('title2')">
生命远不止连轴转和忙到极限,人类的体验远比这辽阔、丰富得多。
</quark-collapse>
</div>

<h2>{{ translate("hideicon") }}</h2>
<div>
<quark-collapse :title="translate('title1')" hideicon>
生命远不止连轴转和忙到极限,人类的体验远比这辽阔、丰富得多。
</quark-collapse>
</div>

<h2>{{ translate("customTitile") }}</h2>
<div>
<quark-collapse :title="translate('title1')">
<div slot="title">
<span style="color: blueviolet"
>{{ translate("title1") }}{{ translate("title1") }}</span
>
</div>
生命远不止连轴转和忙到极限,人类的体验远比这辽阔、丰富得多。
</quark-collapse>
</div>

<h2>{{ translate("customIcon") }}</h2>
<div>
<quark-collapse :title="translate('title1')">
生命远不止连轴转和忙到极限,人类的体验远比这辽阔、丰富得多。
<span slot="icon" class="collapse-icon">🎉🎉🎉</span>
</quark-collapse>
</div>
</div>
</template>

<script>
import { createComponent } from "@/utils/create";
import { onBeforeMount } from "vue";
const { createDemo, translate } = createComponent("collapse");
import { useTranslate } from "@/sites/assets/util/useTranslate";
export default createDemo({
props: {},
setup() {
onBeforeMount(() => {
useTranslate({
"zh-CN": {
basic: "基本用法",
hideicon: "无icon样式",
customTitile: "自定义标题",
customIcon: "自定义图标",
title1: "标题1",
title2: "标题2",
},
"en-US": {
basic: "Basic Usage",
hideicon: "Custom Style",
customTitile: "Custom titile",
customIcon: "Custom Icon",
title1: "Title1",
title2: "Title2",
},
});
});
return {
translate,
};
},
});
</script>

<style src="./demo.scss"></style>
146 changes: 146 additions & 0 deletions packages/quark/src/collapse/doc-react.en-US.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# Collapse

### Intro

The pop-up modal panel at the bottom contains multiple options related to the current situation.

### Install

```tsx
import { ActionSheet } from "@quarkd/quark-react";
```

### Basic Usage

```js
export default () => {
const showBase = () => {
ActionSheet({
actions: [{ name: 'Option 1' }, { name: 'Option 2' }, { name: 'Option 3' }],
select: (index, action) => {
console.log.(action.name);
},
});
};

return (
<div>
<div onClick={showBase} title="Basic Usage"></div>
</div>
);
}
```

### Show Title

```js
ActionSheet({
title: "This is title message",
actions: [{ name: "Option 1" }, { name: "Option 2" }, { name: "Option 3" }],
select: (index, action) => {},
cancel: () => {},
close: () => {},
});
```

### Show Cancel Button

```js
ActionSheet({
title: "This is title message",
cancelText: "Cancel",
actions: [{ name: "Option 1" }, { name: "Option 2" }, { name: "Option 3" }],
select: (index, action) => {},
cancel: () => {},
close: () => {},
});
```

### Custom Title Style

```js
ActionSheet({
title: "This is title message",
titleColor: "red",
titleFontSize: 20,
actions: [{ name: "Option 1" }, { name: "Option 2" }, { name: "Option 3" }],
select: (index, action) => {},
cancel: () => {},
close: () => {},
});
```

### Custom Options Style

```js
ActionSheet({
title: "This is title message",
titleColor: "red",
titleFontSize: 20,
actions: [
{ name: "Option 1", color: "#999", fontSize: 20 },
{ name: "Option 2" },
{ name: "Option 3" },
],
select: (index, action) => {},
cancel: () => {},
close: () => {},
});
```

### Custom Cancel Button Style

```js
ActionSheet({
title: "This is title message",
cancelText: "Cancel",
cancelTextColor: "red",
cancelTextFontSize: 20,
actions: [{ name: "Option 1" }, { name: "Option 2" }, { name: "Option 3" }],
select: (index, action) => {},
cancel: () => {},
close: () => {},
});
```

## API

### Props

| Attribute | Description | Type | Default |
| ------------------ | ---------------------------- | ----------------------------------------- | --------- |
| title | Title | `string` | |
| actions | Options | `Action []` | `require` |
| cancelText | Text of cancel button | `string ` |
| titleColor | Title color | `string ` | `#969799` |
| titleFontSize | Title font size | `number ` | `14` |
| cancelTextColor | Text color of cancel button | `string ` | `#646566` |
| cancelTextFontSize | Font size of cancel button | `number ` | `16` |
| zIndex | actionsheet z-index | `number ` | `999` |
| select | Selected callback | `(index: number, action: Action) => void` | |
| cancel | Cancel button click callback | `() => void ` | |
| close | Mask click callback | `() => void ` | |

### Data Structure of Action

```js
type Action = {
name: string,
color?: string,
fontSize?: number,
};

type ActionParams = {
title?: string,
actions: Action[],
cancelText?: string,
titleColor?: string,
titleFontSize?: number,
cancelTextColor?: string,
cancelTextFontSize?: number,
select: (index: number, action: Action) => void,
cancel?: () => void,
close?: () => void,
zIndex?: number,
};
```
Loading

0 comments on commit 70e345f

Please sign in to comment.