-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
862 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
``` |
Oops, something went wrong.