Эх сурвалжийг харах

[demo]Add NumKeyboard demo

dufu1991 3 жил өмнө
parent
commit
f3432d5d06

+ 1 - 1
.gitignore

@@ -24,7 +24,7 @@ pnpm-lock.yaml
 /demo/public/fonts
 /demo/.svelte-kit
 /demo/build
-/demo/static/fonts
+/demo/static/fonts/symbol.svg
 /demo/npm-lock.yaml
 /demo/package-lock.json
 

+ 1 - 0
demo/package.json

@@ -91,6 +91,7 @@
 		"rollup-plugin-stdf-icon": "file:../packages/rollup-plugin-stdf-icon",
 		"stdf": "file:../packages/stdf",
 		"svelte": "^4.1.1",
+		"svelte-confetti": "^1.3.0",
 		"tailwindcss": "^3.3.3",
 		"vite": "^4.4.6"
 	},

+ 5 - 0
demo/src/app.css

@@ -2,6 +2,11 @@
 @tailwind components;
 @tailwind utilities;
 
+@font-face {
+	font-family: 'Trueno';
+	src: url('/fonts/Trueno.otf') format('opentype');
+}
+
 *::-webkit-scrollbar {
 	width: 6px;
 }

+ 10 - 0
demo/src/data/menuList.js

@@ -207,6 +207,16 @@ export default [
 				alias:
 					'input|输入框|输入|input输入框|input 输入框|Textarea|textarea|文本域|文本框|文本|textarea文本域|textarea 文本域|多行输入框|多行输入|多行|textarea多行输入框|textarea 多行输入框',
 			},
+			{
+				title: '数字键盘 NumKeyboard',
+				title_zh: '数字键盘',
+				title_en: 'NumKeyboard',
+				nav: 'numKeyboard',
+				tip: '按下 1,勇敢迈出第一步,成功不自来。',
+				tip_en: 'Press 1, take the first step bravely, success does not come naturally.',
+				alias:
+					'numKeyboard|数字键盘|数字|键盘|numKeyboard数字键盘|numKeyboard 数字键盘|金额键盘|numKeyboard金额键盘|numKeyboard 金额键盘|number|keyboard|amount|money|',
+			},
 			{
 				title: '选择器 Picker',
 				title_zh: '选择器',

+ 1 - 0
demo/src/lib/icons/ri-delete-back-2-line.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M6.53451 3H20.9993C21.5516 3 21.9993 3.44772 21.9993 4V20C21.9993 20.5523 21.5516 21 20.9993 21H6.53451C6.20015 21 5.88792 20.8329 5.70246 20.5547L0.369122 12.5547C0.145189 12.2188 0.145189 11.7812 0.369122 11.4453L5.70246 3.4453C5.88792 3.1671 6.20015 3 6.53451 3ZM7.06969 5L2.40302 12L7.06969 19H19.9993V5H7.06969ZM12.9993 10.5858L15.8277 7.75736L17.242 9.17157L14.4135 12L17.242 14.8284L15.8277 16.2426L12.9993 13.4142L10.1709 16.2426L8.75668 14.8284L11.5851 12L8.75668 9.17157L10.1709 7.75736L12.9993 10.5858Z"></path></svg>

+ 1 - 0
demo/src/lib/icons/ri-skip-down-line.svg

@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12.0001 10.0859L7.20718 5.29297L5.79297 6.70718L12.0001 12.9143L18.2072 6.70718L16.793 5.29297L12.0001 10.0859ZM18.0001 17.0001L6.00007 17.0001L6.00007 15.0001L18.0001 15.0001V17.0001Z"></path></svg>

+ 2 - 0
demo/src/routes/en_US/icon/allIcon.md

@@ -47,6 +47,7 @@ Demo 中用到的所有 svg 图标
 - discuss-fill
 - discuss-line
 - drag-move-line
+- delete-back-2-line
 - emotion-line
 - emotion-sad-fill
 - emotion-sad-line
@@ -104,6 +105,7 @@ Demo 中用到的所有 svg 图标
 - survey-fill
 - survey-line
 - switch-fill
+- skip-down-line
 - tablet-line
 - thumb-up-fill
 - train-line

+ 128 - 0
demo/src/routes/en_US/numKeyboard/+page.svelte

@@ -0,0 +1,128 @@
+<!-- NumKeyboard Demo -->
+<script>
+	import { NumKeyboard, Cell, Toast } from 'stdf';
+	import { Confetti } from 'svelte-confetti';
+
+	let visible1 = false;
+	let visible2 = false;
+	let visible3 = false;
+	let visible4 = false;
+	let visible5 = false;
+	let visible6 = false;
+	let visible7 = false;
+	let visible8 = false;
+	let visible9 = false;
+	let visible10 = false;
+	let visible11 = false;
+	let visible12 = false;
+	let visible13 = false;
+	let visible14 = false;
+	let visible15 = false;
+	let visible16 = false;
+	let visible17 = false;
+	let visible18 = false;
+	let visible19 = false;
+
+	// Demonstrate listening for click events
+	let visibleToast = false;
+	let key = '';
+	const clickFunc = e => {
+		key = e.detail.key;
+		visibleToast = true;
+	};
+
+	// Demonstrate listening for open and close events
+	let loveDom = null;
+	// The distance from loveDom to the bottom of the window
+	let loveDomBottom = 0;
+	let value = '0';
+	$: doneDisabled = value !== '5201314';
+	let top = 0;
+	const loveFunc = e => {
+		value = e.detail.numStr || '0';
+	};
+	const openFunc = e => {
+		// If the distance from loveDom to the bottom of the window is less than the height of the keyboard, move loveDom up to the height of the keyboard
+		loveDomBottom = window.innerHeight - loveDom.getBoundingClientRect().bottom;
+		if (loveDomBottom < e.detail.keyboardHeight) {
+			top = -(e.detail.keyboardHeight - loveDomBottom) - 50;
+		} else {
+			top = 0;
+		}
+	};
+	const closeFunc = () => {
+		top = 0;
+	};
+</script>
+
+<Cell title="Basic" on:click={() => (visible1 = true)} />
+<NumKeyboard bind:visible={visible1} />
+
+<Cell title="No show done" on:click={() => (visible2 = true)} />
+<NumKeyboard bind:visible={visible2} done={false} />
+
+<Cell title="Show close" on:click={() => (visible3 = true)} />
+<NumKeyboard bind:visible={visible3} close />
+
+<Cell title="Show close and not show done" subTitle="Must hidden dot" on:click={() => (visible9 = true)} />
+<NumKeyboard bind:visible={visible9} close dot={false} done={false} />
+
+<Cell title="Digit up and down" on:click={() => (visible4 = true)} />
+<NumKeyboard bind:visible={visible4} reverse />
+
+<Cell title="Increase key height" on:click={() => (visible5 = true)} />
+<NumKeyboard bind:visible={visible5} height="16" />
+
+<Cell title="Increase spacing" on:click={() => (visible6 = true)} />
+<NumKeyboard bind:visible={visible6} gap="4" p="4" />
+
+<Cell title="The decimal point is not displayed" on:click={() => (visible7 = true)} />
+<NumKeyboard bind:visible={visible7} dot={false} />
+
+<Cell title="Unnecessary all are not displayed" on:click={() => (visible8 = true)} />
+<NumKeyboard bind:visible={visible8} done={false} dot={false} />
+
+<Cell title="Block type" on:click={() => (visible10 = true)} />
+<NumKeyboard bind:visible={visible10} type="block" height="14" p="0" />
+
+<Cell title="Customize the doneText" on:click={() => (visible18 = true)} />
+<NumKeyboard bind:visible={visible18} doneText="Transfer" />
+
+<Cell title="Listen click event" on:click={() => (visible11 = true)} />
+<NumKeyboard bind:visible={visible11} on:click={clickFunc} />
+<Toast bind:visible={visibleToast} duration={500} message={`clicked ${key}`}></Toast>
+
+<div
+	class="relative text-center text-xl mx-16 rounded-full py-3 bg-primary text-white dark:bg-dark dark:text-black backdrop-blur transition-all"
+	style="top:{top}px"
+	bind:this={loveDom}
+>
+	{value}
+	{#if !doneDisabled}
+		<span class="absolute left-1/2"><Confetti rounded amount="100" /></span>
+	{/if}
+</div>
+<Cell title="Please enter 5201314" on:click={() => (visible12 = true)} />
+<NumKeyboard bind:visible={visible12} bind:doneDisabled on:click={loveFunc} on:open={openFunc} on:close={closeFunc} />
+
+<Cell title="Increase key corners" on:click={() => (visible13 = true)} />
+<NumKeyboard bind:visible={visible13} radius="2xl" />
+
+<Cell title="Done key injection Class" on:click={() => (visible14 = true)} />
+<NumKeyboard bind:visible={visible14} doneClass="!bg-gradient-to-r from-[#9820a8] to-[#d16b98]" />
+
+<Cell title="Panel and key injection Class" on:click={() => (visible15 = true)} />
+<NumKeyboard
+	bind:visible={visible15}
+	panelClass="bg-gradient-to-r from-[#CE9FFC] to-[#7367F0]"
+	keyClass="!bg-transparent border border-white/40 !text-white"
+/>
+
+<Cell title="Custom transition animations" subTitle="By popup" on:click={() => (visible16 = true)} />
+<NumKeyboard bind:visible={visible16} popup={{ duration: 1000, easeType: 'bounceOut' }} />
+
+<Cell title="Opaque background when open" subTitle="By mask in popup" on:click={() => (visible17 = true)} />
+<NumKeyboard bind:visible={visible17} popup={{ mask: 0.4 }} />
+
+<Cell title="Customize key fonts" subTitle="Needs imported and config in tailwind.config.js" on:click={() => (visible19 = true)} />
+<NumKeyboard bind:visible={visible19} keyClass="font-Trueno" />

+ 2 - 0
demo/src/routes/zh_CN/icon/allIcon.md

@@ -47,6 +47,7 @@ Demo 中用到的所有 svg 图标
 - discuss-fill
 - discuss-line
 - drag-move-line
+- delete-back-2-line
 - emotion-line
 - emotion-sad-fill
 - emotion-sad-line
@@ -104,6 +105,7 @@ Demo 中用到的所有 svg 图标
 - survey-fill
 - survey-line
 - switch-fill
+- skip-down-line
 - tablet-line
 - thumb-up-fill
 - train-line

+ 128 - 0
demo/src/routes/zh_CN/numKeyboard/+page.svelte

@@ -0,0 +1,128 @@
+<!-- NumKeyboard Demo -->
+<script>
+	import { NumKeyboard, Cell, Toast } from 'stdf';
+	import { Confetti } from 'svelte-confetti';
+
+	let visible1 = false;
+	let visible2 = false;
+	let visible3 = false;
+	let visible4 = false;
+	let visible5 = false;
+	let visible6 = false;
+	let visible7 = false;
+	let visible8 = false;
+	let visible9 = false;
+	let visible10 = false;
+	let visible11 = false;
+	let visible12 = false;
+	let visible13 = false;
+	let visible14 = false;
+	let visible15 = false;
+	let visible16 = false;
+	let visible17 = false;
+	let visible18 = false;
+	let visible19 = false;
+
+	// 演示监听点击事件
+	let visibleToast = false;
+	let key = '';
+	const clickFunc = e => {
+		key = e.detail.key;
+		visibleToast = true;
+	};
+
+	// 演示监听开启与关闭事件
+	let loveDom = null;
+	// loveDom 距离窗口底部的距离
+	let loveDomBottom = 0;
+	let value = '0';
+	$: doneDisabled = value !== '5201314';
+	let top = 0;
+	const loveFunc = e => {
+		value = e.detail.numStr || '0';
+	};
+	const openFunc = e => {
+		// 如果 loveDom 距离窗口底部小于键盘高度,就把 loveDom 向上移动键盘高度
+		loveDomBottom = window.innerHeight - loveDom.getBoundingClientRect().bottom;
+		if (loveDomBottom < e.detail.keyboardHeight) {
+			top = -(e.detail.keyboardHeight - loveDomBottom) - 50;
+		} else {
+			top = 0;
+		}
+	};
+	const closeFunc = () => {
+		top = 0;
+	};
+</script>
+
+<Cell title="基础用法" on:click={() => (visible1 = true)} />
+<NumKeyboard bind:visible={visible1} />
+
+<Cell title="不显示完成" on:click={() => (visible2 = true)} />
+<NumKeyboard bind:visible={visible2} done={false} />
+
+<Cell title="显示关闭" on:click={() => (visible3 = true)} />
+<NumKeyboard bind:visible={visible3} close />
+
+<Cell title="显示关闭不显示完成" subTitle="必须隐藏小数点" on:click={() => (visible9 = true)} />
+<NumKeyboard bind:visible={visible9} close dot={false} done={false} />
+
+<Cell title="数字上下反向" on:click={() => (visible4 = true)} />
+<NumKeyboard bind:visible={visible4} reverse />
+
+<Cell title="增高按键高度" on:click={() => (visible5 = true)} />
+<NumKeyboard bind:visible={visible5} height="16" />
+
+<Cell title="增大间距" on:click={() => (visible6 = true)} />
+<NumKeyboard bind:visible={visible6} gap="4" p="4" />
+
+<Cell title="不显示小数点" on:click={() => (visible7 = true)} />
+<NumKeyboard bind:visible={visible7} close dot={false} />
+
+<Cell title="不必要的全部不显示" on:click={() => (visible8 = true)} />
+<NumKeyboard bind:visible={visible8} done={false} dot={false} />
+
+<Cell title="块式" on:click={() => (visible10 = true)} />
+<NumKeyboard bind:visible={visible10} type="block" height="14" p="0" />
+
+<Cell title="自定义完成文字" on:click={() => (visible18 = true)} />
+<NumKeyboard bind:visible={visible18} doneText="转账" />
+
+<Cell title="监听点击事件" on:click={() => (visible11 = true)} />
+<NumKeyboard bind:visible={visible11} on:click={clickFunc} />
+<Toast bind:visible={visibleToast} duration={500} message={`点击了 ${key}`}></Toast>
+
+<div
+	class="relative text-center text-xl mx-16 rounded-full py-3 bg-primary text-white dark:bg-dark dark:text-black backdrop-blur transition-all"
+	style="top:{top}px"
+	bind:this={loveDom}
+>
+	{value}
+	{#if !doneDisabled}
+		<span class="absolute left-1/2"><Confetti rounded amount="100" /></span>
+	{/if}
+</div>
+<Cell title="请输入 5201314" on:click={() => (visible12 = true)} />
+<NumKeyboard bind:visible={visible12} bind:doneDisabled on:click={loveFunc} on:open={openFunc} on:close={closeFunc} />
+
+<Cell title="增大按键圆角" on:click={() => (visible13 = true)} />
+<NumKeyboard bind:visible={visible13} radius="2xl" />
+
+<Cell title="完成按键注入 Class" on:click={() => (visible14 = true)} />
+<NumKeyboard bind:visible={visible14} doneClass="!bg-gradient-to-r from-[#9820a8] to-[#d16b98]" />
+
+<Cell title="面板与按键注入 Class" on:click={() => (visible15 = true)} />
+<NumKeyboard
+	bind:visible={visible15}
+	panelClass="bg-gradient-to-r from-[#CE9FFC] to-[#7367F0]"
+	keyClass="!bg-transparent border border-white/40 !text-white"
+/>
+
+<Cell title="自定义过渡动画" subTitle="通过 popup" on:click={() => (visible16 = true)} />
+<NumKeyboard bind:visible={visible16} popup={{ duration: 1000, easeType: 'bounceOut' }} />
+
+<Cell title="激活时背景不透明" subTitle="通过 popup 内的 mask" on:click={() => (visible17 = true)} />
+<NumKeyboard bind:visible={visible17} popup={{ mask: 0.4 }} />
+
+<Cell title="自定义按键字体" subTitle="需要引入并在 tailwind.config.js 中配置" on:click={() => (visible19 = true)} />
+<NumKeyboard bind:visible={visible19} keyClass="font-Trueno" />

BIN
demo/static/fonts/Trueno.otf


+ 5 - 1
demo/tailwind.config.js

@@ -39,7 +39,11 @@ export default {
 			gray10: '#FAFAFB',
 			transparent: 'transparent',
 		},
-		extend: {},
+		extend: {
+			fontFamily: {
+				Trueno: 'Trueno',
+			},
+		},
 	},
 	darkMode: 'class',
 	plugins: [],