forked from jd-opensource/nutui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(button): split taro demo & doc (jd-opensource#2729)
- Loading branch information
Showing
21 changed files
with
282 additions
and
240 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<template> | ||
<nut-button block type="primary">Block</nut-button> | ||
</template> |
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,5 @@ | ||
<template> | ||
<nut-button color="#7232dd">Pure</nut-button> | ||
<nut-button color="#7232dd" plain>Pure</nut-button> | ||
<nut-button color="linear-gradient(to right, #ff6034, #ee0a24)"> Gradient </nut-button> | ||
</template> |
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,5 @@ | ||
<template> | ||
<nut-button disabled type="primary">Disabled</nut-button> | ||
<nut-button plain disabled type="info">Disabled</nut-button> | ||
<nut-button plain disabled type="primary">Disabled</nut-button> | ||
</template> |
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,16 @@ | ||
<template> | ||
<nut-button shape="square" plain type="primary"> | ||
<template #icon> | ||
<StarFill /> | ||
</template> | ||
</nut-button> | ||
<nut-button shape="square" type="primary"> | ||
<template #icon> | ||
<Star /> | ||
</template> | ||
Star | ||
</nut-button> | ||
</template> | ||
<script setup lang="ts"> | ||
import { StarFill, Star } from '@nutui/icons-vue'; | ||
</script> |
155 changes: 64 additions & 91 deletions
155
packages/nutui-taro-demo/src/basic/pages/button/index.vue
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
16 changes: 16 additions & 0 deletions
16
packages/nutui-taro-demo/src/basic/pages/button/loading.vue
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,16 @@ | ||
<template> | ||
<nut-button loading type="info"></nut-button> | ||
<nut-button loading type="warning">Loading...</nut-button> | ||
<nut-button :loading="isLoading" type="success" @click="onChange">Click me!</nut-button> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue'; | ||
const isLoading = ref(false); | ||
const onChange = () => { | ||
isLoading.value = true; | ||
setTimeout(() => { | ||
isLoading.value = false; | ||
}, 3000); | ||
}; | ||
</script> |
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,4 @@ | ||
<template> | ||
<nut-button plain type="primary">Plain</nut-button> | ||
<nut-button plain type="info">Plain</nut-button> | ||
</template> |
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,4 @@ | ||
<template> | ||
<nut-button shape="square" type="primary">Square</nut-button> | ||
<nut-button shape="round" type="info">Round</nut-button> | ||
</template> |
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,6 @@ | ||
<template> | ||
<nut-button size="large" type="primary">Large</nut-button> | ||
<nut-button type="primary">Normal</nut-button> | ||
<nut-button size="small" type="primary">Small</nut-button> | ||
<nut-button size="mini" type="primary">Mini</nut-button> | ||
</template> |
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,8 @@ | ||
<template> | ||
<nut-button type="primary">Primary</nut-button> | ||
<nut-button type="info">Info</nut-button> | ||
<nut-button type="default">Default</nut-button> | ||
<nut-button type="danger">Danger</nut-button> | ||
<nut-button type="warning">Warning</nut-button> | ||
<nut-button type="success">Success</nut-button> | ||
</template> |
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 @@ | ||
export * from './useTranslate'; |
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,37 @@ | ||
import Locale from '@/packages/locale'; | ||
import { useLocale } from '@/packages/utils/useLocale'; | ||
export const currentLang = Locale.currentLang; | ||
|
||
export const useTranslate = < | ||
T1 extends { | ||
[key: string]: any; | ||
}, | ||
T2 extends T1 | ||
>(object: { | ||
'zh-CN': T1; | ||
'en-US': T2; | ||
}) => { | ||
for (const [key, value] of Object.entries(object)) { | ||
Locale.merge(key, value); | ||
} | ||
return useLocale<Exclude<Extract<keyof T1, keyof T2>, number | symbol>>(); | ||
}; | ||
|
||
export const translateChange = () => { | ||
let href = ''; | ||
const location = window.parent.location; | ||
const currentLang = Locale.currentLang; | ||
if (currentLang.value == 'zh-CN') { | ||
href = location.href.replace('zh-CN', 'en-US'); | ||
Locale.use('en-US'); | ||
} else { | ||
href = location.href.replace('en-US', 'zh-CN'); | ||
Locale.use('zh-CN'); | ||
} | ||
location.href = href; | ||
}; | ||
|
||
export const initSiteLang = () => { | ||
const lang = location.href.includes('zh-CN') ? 'zh-CN' : 'en-US'; | ||
Locale.use(lang); | ||
}; |
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
Oops, something went wrong.